File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed
Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -212,8 +212,8 @@ impl From<&String> for Classes {
212212 }
213213}
214214
215- impl From < AttrValue > for Classes {
216- fn from ( t : AttrValue ) -> Self {
215+ impl From < & AttrValue > for Classes {
216+ fn from ( t : & AttrValue ) -> Self {
217217 let set = t
218218 . split_whitespace ( )
219219 . map ( ToOwned :: to_owned)
@@ -223,6 +223,23 @@ impl From<AttrValue> for Classes {
223223 }
224224}
225225
226+ impl From < AttrValue > for Classes {
227+ fn from ( t : AttrValue ) -> Self {
228+ match t. contains ( |c : char | c. is_whitespace ( ) ) {
229+ // If the string only contains a single class, we can just use it
230+ // directly (rather than cloning it into a new string). Need to make
231+ // sure it's not empty, though.
232+ false => match t. is_empty ( ) {
233+ true => Self :: new ( ) ,
234+ false => Self {
235+ set : Rc :: new ( IndexSet :: from_iter ( [ t] ) ) ,
236+ } ,
237+ } ,
238+ true => Self :: from ( & t) ,
239+ }
240+ }
241+ }
242+
226243impl < T : Into < Classes > > From < Option < T > > for Classes {
227244 fn from ( t : Option < T > ) -> Self {
228245 t. map ( |x| x. into ( ) ) . unwrap_or_default ( )
You can’t perform that action at this time.
0 commit comments