Implement FromStr for ArrayString
This is very useful for generic code that may want to parse arbitrary input string into arbitrary other types. Limitations of the FromStr trait don't allow us to keep the original string slice inside the CapacityError, unfortunately.
This commit is contained in:
@@ -487,6 +487,14 @@ fn test_string_from() {
|
||||
assert_eq!(u.len(), text.len());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_string_parse_from_str() {
|
||||
let text = "hello world";
|
||||
let u: ArrayString<[_; 11]> = text.parse().unwrap();
|
||||
assert_eq!(&u, text);
|
||||
assert_eq!(u.len(), text.len());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_string_from_bytes() {
|
||||
let text = "hello world";
|
||||
|
||||
Reference in New Issue
Block a user