Rollup merge of #34305 - Aaronepower:master, r=alexcrichton
Added Default trait for Cow. Adds a default implementation for Cow. Which is the Owned's default.
This commit is contained in:
commit
a77a179637
@ -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;
|
||||
@ -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]
|
||||
|
Loading…
Reference in New Issue
Block a user