// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::borrow::Cow;
use std::cmp::Ordering::{Equal, Greater, Less};
use std::str::from_utf8;
assert_eq!(data, data2);
}
+#[test]
+fn test_cow_from() {
+ let borrowed = "borrowed";
+ let owned = String::from("owned");
+ match (Cow::from(owned.clone()), Cow::from(borrowed)) {
+ (Cow::Owned(o), Cow::Borrowed(b)) => assert!(o == owned && b == borrowed),
+ _ => panic!("invalid `Cow::from`"),
+ }
+}
+
mod pattern {
use std::str::pattern::Pattern;
use std::str::pattern::{Searcher, ReverseSearcher};
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::borrow::Cow;
use std::iter::{FromIterator, repeat};
use std::mem::size_of;
assert_eq!(vec![1, 2, 3].into_iter().count(), 3);
}
+#[test]
+fn test_cow_from() {
+ let borrowed: &[_] = &["borrowed", "(slice)"];
+ let owned = vec!["owned", "(vec)"];
+ match (Cow::from(owned.clone()), Cow::from(borrowed)) {
+ (Cow::Owned(o), Cow::Borrowed(b)) => assert!(o == owned && b == borrowed),
+ _ => panic!("invalid `Cow::from`"),
+ }
+}
+
#[bench]
fn bench_new(b: &mut Bencher) {
b.iter(|| {