We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
From<Cow<str>> for CowRcStr
1 parent 32733fb commit 8b7191bCopy full SHA for 8b7191b
src/compact_cow_str.rs
@@ -2,7 +2,7 @@
2
* License, v. 2.0. If a copy of the MPL was not distributed with this
3
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5
-use std::borrow::Borrow;
+use std::borrow::{Borrow, Cow};
6
use std::cmp;
7
use std::fmt;
8
use std::hash;
@@ -42,6 +42,16 @@ fn _static_assert_same_size<'a>() {
42
let _ = mem::transmute::<CowRcStr<'a>, Option<CowRcStr<'a>>>;
43
}
44
45
+impl<'a> From<Cow<'a, str>> for CowRcStr<'a> {
46
+ #[inline]
47
+ fn from(s: Cow<'a, str>) -> Self {
48
+ match s {
49
+ Cow::Borrowed(s) => CowRcStr::from(s),
50
+ Cow::Owned(s) => CowRcStr::from(s),
51
+ }
52
53
+}
54
+
55
impl<'a> From<&'a str> for CowRcStr<'a> {
56
#[inline]
57
fn from(s: &'a str) -> Self {
0 commit comments