add From<SmolStr> for String

This commit is contained in:
Aleksey Kladov 2018-12-21 14:16:23 +03:00
parent c6c487ea31
commit 373ca5eda7
2 changed files with 13 additions and 0 deletions

View File

@ -136,6 +136,12 @@ where
}
}
impl From<SmolStr> for String {
fn from(text: SmolStr) -> Self {
text.to_string()
}
}
const INLINE_CAP: usize = 22;
const N_NEWLINES: usize = 32;
const N_SPACES: usize = 128;

View File

@ -20,6 +20,13 @@ fn assert_traits() {
f::<SmolStr>();
}
#[test]
fn conversions() {
let s: SmolStr = "Hello, World!".into();
let s: String = s.into();
assert_eq!(s, "Hello, World!")
}
fn check_props(s: &str) -> Result<(), proptest::test_runner::TestCaseError> {
let smol = SmolStr::new(s);
prop_assert_eq!(smol.as_str(), s);