Implement Error for OccupiedError.
This commit is contained in:
parent
69d95e232a
commit
d85d82ab22
4 changed files with 45 additions and 0 deletions
|
@ -93,6 +93,19 @@ impl<K: Debug + Ord, V: Debug> Debug for OccupiedError<'_, K, V> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[unstable(feature = "map_try_insert", issue = "none")]
|
||||||
|
impl<'a, K: Debug + Ord, V: Debug> fmt::Display for OccupiedError<'a, K, V> {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
write!(
|
||||||
|
f,
|
||||||
|
"failed to insert {:?}, key {:?} already exists with value {:?}",
|
||||||
|
self.value,
|
||||||
|
self.entry.key(),
|
||||||
|
self.entry.get(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<'a, K: Ord, V> Entry<'a, K, V> {
|
impl<'a, K: Ord, V> Entry<'a, K, V> {
|
||||||
/// Ensures a value is in the entry by inserting the default if empty, and returns
|
/// Ensures a value is in the entry by inserting the default if empty, and returns
|
||||||
/// a mutable reference to the value in the entry.
|
/// a mutable reference to the value in the entry.
|
||||||
|
|
|
@ -1907,6 +1907,19 @@ impl<K: Debug, V: Debug> Debug for OccupiedError<'_, K, V> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[unstable(feature = "map_try_insert", issue = "none")]
|
||||||
|
impl<'a, K: Debug, V: Debug> fmt::Display for OccupiedError<'a, K, V> {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
write!(
|
||||||
|
f,
|
||||||
|
"failed to insert {:?}, key {:?} already exists with value {:?}",
|
||||||
|
self.value,
|
||||||
|
self.entry.key(),
|
||||||
|
self.entry.get(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
impl<'a, K, V, S> IntoIterator for &'a HashMap<K, V, S> {
|
impl<'a, K, V, S> IntoIterator for &'a HashMap<K, V, S> {
|
||||||
type Item = (&'a K, &'a V);
|
type Item = (&'a K, &'a V);
|
||||||
|
|
|
@ -470,6 +470,24 @@ impl Error for char::DecodeUtf16Error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[unstable(feature = "map_try_insert", issue = "none")]
|
||||||
|
impl<'a, K: Debug + Ord, V: Debug> Error
|
||||||
|
for crate::collections::btree_map::OccupiedError<'a, K, V>
|
||||||
|
{
|
||||||
|
#[allow(deprecated)]
|
||||||
|
fn description(&self) -> &str {
|
||||||
|
"key already exists"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[unstable(feature = "map_try_insert", issue = "none")]
|
||||||
|
impl<'a, K: Debug, V: Debug> Error for crate::collections::hash_map::OccupiedError<'a, K, V> {
|
||||||
|
#[allow(deprecated)]
|
||||||
|
fn description(&self) -> &str {
|
||||||
|
"key already exists"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[stable(feature = "box_error", since = "1.8.0")]
|
#[stable(feature = "box_error", since = "1.8.0")]
|
||||||
impl<T: Error> Error for Box<T> {
|
impl<T: Error> Error for Box<T> {
|
||||||
#[allow(deprecated, deprecated_in_future)]
|
#[allow(deprecated, deprecated_in_future)]
|
||||||
|
|
|
@ -281,6 +281,7 @@
|
||||||
#![feature(linkage)]
|
#![feature(linkage)]
|
||||||
#![feature(llvm_asm)]
|
#![feature(llvm_asm)]
|
||||||
#![feature(log_syntax)]
|
#![feature(log_syntax)]
|
||||||
|
#![feature(map_try_insert)]
|
||||||
#![feature(maybe_uninit_extra)]
|
#![feature(maybe_uninit_extra)]
|
||||||
#![feature(maybe_uninit_ref)]
|
#![feature(maybe_uninit_ref)]
|
||||||
#![feature(maybe_uninit_slice)]
|
#![feature(maybe_uninit_slice)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue