Skip to content

Commit d5e9acd

Browse files
committed
Merge branch 'master' of https://github.com/bluss/arrayvec
2 parents d336f8c + 0acbba4 commit d5e9acd

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/array_string.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
use std::borrow::Borrow;
22
use std::cmp;
3+
use std::convert::TryFrom;
34
use std::fmt;
45
use std::hash::{Hash, Hasher};
5-
use std::ptr;
66
use std::ops::{Deref, DerefMut};
7+
use std::ptr;
8+
use std::slice;
79
use std::str;
810
use std::str::FromStr;
911
use std::str::Utf8Error;
10-
use std::slice;
1112

1213
use crate::array::Array;
1314
use crate::array::Index;
@@ -580,3 +581,16 @@ impl<'de, A> Deserialize<'de> for ArrayString<A>
580581
deserializer.deserialize_str(ArrayStringVisitor::<A>(PhantomData))
581582
}
582583
}
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+
}

0 commit comments

Comments
 (0)