Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions packages/yew-macro/tests/classes_macro/classes-fail.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ error[E0277]: the trait bound `Classes: From<{integer}>` is not satisfied
| ^^ the trait `From<{integer}>` is not implemented for `Classes`
|
= help: the following other types implement trait `From<T>`:
`Classes` implements `From<&Classes>`
`Classes` implements `From<&Option<T>>`
`Classes` implements `From<&String>`
`Classes` implements `From<&[T]>`
`Classes` implements `From<&implicit_clone::unsync::string::IString>`
`Classes` implements `From<&str>`
`Classes` implements `From<Cow<'_, str>>`
`Classes` implements `From<Option<T>>`
`Classes` implements `From<String>`
and $N others
= note: required for `{integer}` to implement `Into<Classes>`
note: required by a bound in `Classes::push`
Expand All @@ -40,14 +40,14 @@ error[E0277]: the trait bound `Classes: From<{float}>` is not satisfied
| ^^^^ the trait `From<{float}>` is not implemented for `Classes`
|
= help: the following other types implement trait `From<T>`:
`Classes` implements `From<&Classes>`
`Classes` implements `From<&Option<T>>`
`Classes` implements `From<&String>`
`Classes` implements `From<&[T]>`
`Classes` implements `From<&implicit_clone::unsync::string::IString>`
`Classes` implements `From<&str>`
`Classes` implements `From<Cow<'_, str>>`
`Classes` implements `From<Option<T>>`
`Classes` implements `From<String>`
and $N others
= note: required for `{float}` to implement `Into<Classes>`
note: required by a bound in `Classes::push`
Expand All @@ -66,14 +66,14 @@ error[E0277]: the trait bound `Classes: From<{integer}>` is not satisfied
| required by a bound introduced by this call
|
= help: the following other types implement trait `From<T>`:
`Classes` implements `From<&Classes>`
`Classes` implements `From<&Option<T>>`
`Classes` implements `From<&String>`
`Classes` implements `From<&[T]>`
`Classes` implements `From<&implicit_clone::unsync::string::IString>`
`Classes` implements `From<&str>`
`Classes` implements `From<Cow<'_, str>>`
`Classes` implements `From<Option<T>>`
`Classes` implements `From<String>`
and $N others
= note: required for `{integer}` to implement `Into<Classes>`
= note: required for `Classes` to implement `From<Vec<{integer}>>`
Expand All @@ -92,14 +92,14 @@ error[E0277]: the trait bound `Classes: From<{integer}>` is not satisfied
| ^^^^ the trait `From<{integer}>` is not implemented for `Classes`
|
= help: the following other types implement trait `From<T>`:
`Classes` implements `From<&Classes>`
`Classes` implements `From<&Option<T>>`
`Classes` implements `From<&String>`
`Classes` implements `From<&[T]>`
`Classes` implements `From<&implicit_clone::unsync::string::IString>`
`Classes` implements `From<&str>`
`Classes` implements `From<Cow<'_, str>>`
`Classes` implements `From<Option<T>>`
`Classes` implements `From<String>`
and $N others
= note: required for `{integer}` to implement `Into<Classes>`
= note: required for `Classes` to implement `From<Option<{integer}>>`
Expand All @@ -118,14 +118,14 @@ error[E0277]: the trait bound `Classes: From<u32>` is not satisfied
| ^^^^ the trait `From<u32>` is not implemented for `Classes`
|
= help: the following other types implement trait `From<T>`:
`Classes` implements `From<&Classes>`
`Classes` implements `From<&Option<T>>`
`Classes` implements `From<&String>`
`Classes` implements `From<&[T]>`
`Classes` implements `From<&implicit_clone::unsync::string::IString>`
`Classes` implements `From<&str>`
`Classes` implements `From<Cow<'_, str>>`
`Classes` implements `From<Option<T>>`
`Classes` implements `From<String>`
and $N others
= note: required for `u32` to implement `Into<Classes>`
= note: required for `Classes` to implement `From<Option<u32>>`
Expand All @@ -144,14 +144,14 @@ error[E0277]: the trait bound `Classes: From<{integer}>` is not satisfied
| ^^ the trait `From<{integer}>` is not implemented for `Classes`
|
= help: the following other types implement trait `From<T>`:
`Classes` implements `From<&Classes>`
`Classes` implements `From<&Option<T>>`
`Classes` implements `From<&String>`
`Classes` implements `From<&[T]>`
`Classes` implements `From<&implicit_clone::unsync::string::IString>`
`Classes` implements `From<&str>`
`Classes` implements `From<Cow<'_, str>>`
`Classes` implements `From<Option<T>>`
`Classes` implements `From<String>`
and $N others
= note: required for `{integer}` to implement `Into<Classes>`
note: required by a bound in `Classes::push`
Expand Down
1 change: 1 addition & 0 deletions packages/yew-macro/tests/html_macro/element-fail.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,7 @@ error[E0277]: the trait bound `implicit_clone::unsync::string::IString: From<{in
| ^^ the trait `From<{integer}>` is not implemented for `implicit_clone::unsync::string::IString`
|
= help: the following other types implement trait `From<T>`:
`implicit_clone::unsync::string::IString` implements `From<&Classes>`
`implicit_clone::unsync::string::IString` implements `From<&implicit_clone::unsync::string::IString>`
`implicit_clone::unsync::string::IString` implements `From<&str>`
`implicit_clone::unsync::string::IString` implements `From<Arguments<'_>>`
Expand Down
12 changes: 12 additions & 0 deletions packages/yew/src/html/classes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,18 @@ impl<T: Into<Classes>, const SIZE: usize> From<[T; SIZE]> for Classes {
}
}

impl From<&Classes> for Classes {
fn from(c: &Classes) -> Self {
c.clone()
}
}

impl From<&Classes> for AttrValue {
fn from(c: &Classes) -> Self {
c.clone().into_prop_value()
}
}

impl PartialEq for Classes {
fn eq(&self, other: &Self) -> bool {
self.set.len() == other.set.len() && self.set.iter().eq(other.set.iter())
Expand Down
Loading