chaokunyang commented on issue #2658:
URL: https://github.com/apache/fory/issues/2658#issuecomment-3341043912

   @urlyy 
   
   > [@chaokunyang](https://github.com/chaokunyang)
   > 
   > trait OtherSerializer {
   >     fn read() -> Vec<u8>;
   > }
   > impl OtherSerializer for Animal {
   >     fn read() -> Vec<u8> {
   >         todo!()
   >     }
   > }
   > #[derive(Fory, Debug, PartialEq, Default)]
   > struct Animal {
   >     category: String,
   > }
   > this case will compile error:
   > 
   > ```
   > multiple applicable items in scope [E0034]
   > Note: candidate #1 is defined in an impl of the trait `OtherSerializer` 
for the type `complex_struct::Animal`
   > Note: candidate #2 is defined in an impl of the trait `Serializer` for the 
type `complex_struct::Animal`
   > ```
   > 
   > So I think The 3rd point is still important.
   
   I did some tests, this should compile:
   
   ```rust
   trait Greet {
       fn greet(&self);
   }
   
   trait Hi {
       fn greet(&self); // Same name, but in different traits
   }
   
   struct Person;
   
   impl Greet for Person {
       fn greet(&self) {
           println!("Hello!");
       }
   }
   
   impl Hi for Person {
       fn greet(&self) {
           println!("Hi!");
       }
   }
   
   fn main() {
       let person = Person;
   
       // Calling the greet method from the Greet trait
       Greet::greet(&person);
   
       // Calling the greet method from the Hi trait
       Hi::greet(&person);
   }
   
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to