File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change 1
1
use std:: borrow:: Borrow ;
2
2
use std:: cmp;
3
+ use std:: convert:: TryFrom ;
3
4
use std:: fmt;
4
5
use std:: hash:: { Hash , Hasher } ;
5
- use std:: ptr;
6
6
use std:: ops:: { Deref , DerefMut } ;
7
+ use std:: ptr;
8
+ use std:: slice;
7
9
use std:: str;
8
10
use std:: str:: FromStr ;
9
11
use std:: str:: Utf8Error ;
10
- use std:: slice;
11
12
12
13
use crate :: array:: Array ;
13
14
use crate :: array:: Index ;
@@ -580,3 +581,16 @@ impl<'de, A> Deserialize<'de> for ArrayString<A>
580
581
deserializer. deserialize_str ( ArrayStringVisitor :: < A > ( PhantomData ) )
581
582
}
582
583
}
584
+
585
+ impl < ' a , A > TryFrom < & ' a str > for ArrayString < A >
586
+ where
587
+ A : Array < Item = u8 > + Copy
588
+ {
589
+ type Error = CapacityError < & ' a str > ;
590
+
591
+ fn try_from ( f : & ' a str ) -> Result < Self , Self :: Error > {
592
+ let mut v = Self :: new ( ) ;
593
+ v. try_push_str ( f) ?;
594
+ Ok ( v)
595
+ }
596
+ }
You can’t perform that action at this time.
0 commit comments