#Why so

25 messages · Page 1 of 1 (latest)

vernal ferry
#

Why is this conflicting.??

pub trait test{
    
}

impl<T> test for T{
    
}
impl<T> test for &T{
    
}
impl<T> test for &mut T{
    
}
fn main(){
    
}```
#

?eval

pub trait test{
    
}

impl<T> test for T{
    
}
impl<T> test for &T{
    
}
impl<T> test for &mut T{
    
}
fn main(){
    
}```
balmy lintelBOT
#
warning: trait `test` should have an upper camel case name
 --> src/main.rs:1:11
  |
1 | pub trait test{
  |           ^^^^ help: convert the identifier to upper camel case: `Test`
  |
  = note: `#[warn(non_camel_case_types)]` on by default

error[E0119]: conflicting implementations of trait `test` for type `&_`
 --> src/main.rs:8:1
  |
5 | impl<T> test for T{
  | ------------------ first implementation here
...
8 | impl<T> test for &T{
  | ^^^^^^^^^^^^^^^^^^^ conflicting implementation for `&_`

error[E0119]: conflicting implementations of trait `test` for type `&mut _`
  --> src/main.rs:11:1
   |
5  | impl<T> test for T{
   | ------------------ first implementation here
...
11 | impl<T> test for &mut T{
   | ^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `&mut _`

For more information about this error, try `rustc --explain E0119`.```
vernal ferry
#

But

#

?eval

pub trait test{
    
}

impl<T> test for &T{
    
}
impl<T> test for &mut T{
    
}
fn main(){
    
}

balmy lintelBOT
vernal ferry
#

Why This is working fine.??

tardy zodiac
vernal ferry
#

?eval

trait Trait {}
struct Struct;
impl Trait for Struct {} // ✅
impl Trait for &Struct {} // ✅
impl Trait for &mut Struct {} // ✅

balmy lintelBOT
#
The operation timed out: deadline has elapsed```
tardy zodiac
#

yeah

#

it's one type

vernal ferry
#

Sorry can you make it clear

tardy zodiac
#

impl<T> test for T { includes all types

vernal ferry
#

Oh

tardy zodiac
#

T = &Foo and T = &mut Foo too

vernal ferry
#

Hmmm

#

It can be an issue

#

I was reading this

tardy zodiac
#

it's a good read

vernal ferry
tardy zodiac
#

it literally says what I said

vernal ferry
tardy zodiac
#
trait Trait { fn foo(self); }
impl<T> Trait for T { fn foo(self) { println!("T"); } }
impl<T> Trait for &T { fn foo(self) { println!("&T"); } } // ❌

let int_ref: &i32 = &1;

int_ref.foo(); // which method should be called?