Skip to content

Commit

Permalink
Added Default trait for Cow
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaronepower committed Jun 23, 2016
1 parent a479a6a commit 703d7b5
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/libcollections/borrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use core::clone::Clone;
use core::cmp::{Eq, Ord, Ordering, PartialEq, PartialOrd};
use core::convert::AsRef;
use core::default::Default;
use core::hash::{Hash, Hasher};
use core::marker::Sized;
use core::ops::Deref;
Expand Down Expand Up @@ -248,6 +249,16 @@ impl<'a, B: ?Sized> fmt::Display for Cow<'a, B>
}
}

#[stable(feature = "default", since = "1.11.0")]
impl<'a, B: ?Sized> Default for Cow<'a, B>
where B: ToOwned,
<B as ToOwned>::Owned: Default
{
fn default() -> Cow<'a, B> {
Owned(<B as ToOwned>::Owned::default())
}
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, B: ?Sized> Hash for Cow<'a, B> where B: Hash + ToOwned {
#[inline]
Expand Down

0 comments on commit 703d7b5

Please sign in to comment.