Add constructor ArrayString::from_byte_string(b"abc")

This is an alternative constructor that never has capacity errors.
Unfortunately the error case is invalid UTF-8!
This commit is contained in:
bluss
2016-12-14 15:01:03 +01:00
parent 3d69403dee
commit da459bcf78
3 changed files with 40 additions and 1 deletions
+8
View File
@@ -346,6 +346,14 @@ fn test_string_from() {
assert_eq!(u.len(), text.len());
}
#[test]
fn test_string_from_bytes() {
let text = "hello world";
let u = ArrayString::from_byte_string(b"hello world").unwrap();
assert_eq!(&u, text);
assert_eq!(u.len(), text.len());
}
#[test]
fn test_string_clone() {
let text = "hi";