You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
traitTrait for Sized? {fnmethod(&mutSelf) -> &mutSelf;}impl<T>Traitfor[T]{// This worksfnmethod(s:&mut[T]) -> &mut[T]{
s
}}implTraitforstr{// This doesn't workfnmethod(s:&mutstr) -> &mutstr{
s
}}// But this worksfnfunction(s:&mutstr) -> &mutstr{
s
}fnmain(){}
Output
str.rs:14:5:16:6 error: method `method` has an incompatible type for trait: values differ in mutability [E0053]
str.rs:14fnmethod(s:&mutstr) -> &mutstr{
str.rs:15 s
str.rs:16}
error: aborting due to previous error