Into<Cow<'a,T>>

Anybody know if std could add these generic impls?

impl<'a,T: ToOwned> From<<T as ToOwned>::Owned> for Cow<'a,T> {
    fn from(x: <T as ToOwned>::Owned) -> Cow<'a,T> { Cow::Owned(x) }
}

impl<'a,T: ToOwned> From<&'a T> for Cow<'a,T> {
    fn from(x: &'a T) -> Cow<'a,T> { Cow::Borrowed(x) }
}

Oops, I suppose these conflict because someone could've written:

impl ToOwned for Foo {
    type Owned = &'static Foo;

    fn to_owned(&self) -> Self::Owned {
        Box::leak(Box::new(self.clone()))
    }

    fn clone_into(&self, target: &mut Self::Owned) { panic!() }
}

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.