Hi, will that code work at some point in the rust future?
#![feature(specialization)]
#![allow(unused)]
trait Trait1{
fn test(&self);
}
impl Trait1 for u32{
fn test (&self){
println!("Trait1")
}
}
impl Trait2 for u64{
fn test(&self){
println!("Trait2")
}
}
trait Trait2{
fn test(&self);
}
fn mfn<T: Trait1>(val: T){
println!("{:?} u32", val.test())
}
fn mfn<T: Trait2>(val: T){
println!("{:?} u64", val.test())
}
fn main() {
let t = 50_u32;
mfn(t);
}
Errors:
Compiling playground v0.0.1 (/playground)
error[E0428]: the name `mfn` is defined multiple times
--> src/main.rs:25:1
|
22 | fn mfn<T: Trait1>(val: T){
| ------------------------- previous definition of the value `mfn` here
...
25 | fn mfn<T: Trait2>(val: T){
| ^^^^^^^^^^^^^^^^^^^^^^^^^ `mfn` redefined here
|
= note: `mfn` must be defined only once in the value namespace of this module
warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes
--> src/main.rs:1:12
|
1 | #![feature(specialization)]
| ^^^^^^^^^^^^^^
|
= note: see issue #31844 <https://github.com/rust-lang/rust/issues/31844> for more information
= help: consider using `min_specialization` instead, which is more stable and complete
= note: `#[warn(incomplete_features)]` on by default
For more information about this error, try `rustc --explain E0428`.
warning: `playground` (bin "playground") generated 1 warning
error: could not compile `playground` (bin "playground") due to 1 previous error; 1 warning emitted