Share `UnorderedKeyError` with `BTReeMap` for set API · patricklam/verify-rust-std@07f64a8
@@ -2,7 +2,6 @@ use crate::vec::Vec;
22use core::borrow::Borrow;
33use core::cmp::Ordering::{self, Equal, Greater, Less};
44use core::cmp::{max, min};
5-use core::error::Error;
65use core::fmt::{self, Debug};
76use core::hash::{Hash, Hasher};
87use core::iter::{FusedIterator, Peekable};
@@ -2177,11 +2176,11 @@ impl<'a, T: Ord, A: Allocator + Clone> CursorMut<'a, T, A> {
21772176 ///
21782177 /// If the inserted element is not greater than the element before the
21792178 /// cursor (if any), or if it not less than the element after the cursor (if
2180- /// any), then an [`UnorderedError`] is returned since this would
2179+ /// any), then an [`UnorderedKeyError`] is returned since this would
21812180 /// invalidate the [`Ord`] invariant between the elements of the set.
21822181 #[unstable(feature = "btree_cursors", issue = "107540")]
2183-pub fn insert_after(&mut self, value: T) -> Result<(), UnorderedError> {
2184-self.inner.insert_after(value, SetValZST).map_err(UnorderedError::from_map_error)
2182+pub fn insert_after(&mut self, value: T) -> Result<(), UnorderedKeyError> {
2183+self.inner.insert_after(value, SetValZST)
21852184}
2186218521872186/// Inserts a new element into the set in the gap that the
@@ -2192,11 +2191,11 @@ impl<'a, T: Ord, A: Allocator + Clone> CursorMut<'a, T, A> {
21922191 ///
21932192 /// If the inserted element is not greater than the element before the
21942193 /// cursor (if any), or if it not less than the element after the cursor (if
2195- /// any), then an [`UnorderedError`] is returned since this would
2194+ /// any), then an [`UnorderedKeyError`] is returned since this would
21962195 /// invalidate the [`Ord`] invariant between the elements of the set.
21972196 #[unstable(feature = "btree_cursors", issue = "107540")]
2198-pub fn insert_before(&mut self, value: T) -> Result<(), UnorderedError> {
2199-self.inner.insert_before(value, SetValZST).map_err(UnorderedError::from_map_error)
2197+pub fn insert_before(&mut self, value: T) -> Result<(), UnorderedKeyError> {
2198+self.inner.insert_before(value, SetValZST)
22002199}
2201220022022201/// Removes the next element from the `BTreeSet`.
@@ -2218,29 +2217,8 @@ impl<'a, T: Ord, A: Allocator + Clone> CursorMut<'a, T, A> {
22182217}
22192218}
222022192221-/// Error type returned by [`CursorMut::insert_before`] and
2222-/// [`CursorMut::insert_after`] if the element being inserted is not properly
2223-/// ordered with regards to adjacent elements.
2224-#[derive(Clone, PartialEq, Eq, Debug)]
22252220#[unstable(feature = "btree_cursors", issue = "107540")]
2226-pub struct UnorderedError {}
2227-2228-impl UnorderedError {
2229-fn from_map_error(error: super::map::UnorderedKeyError) -> Self {
2230-let super::map::UnorderedKeyError {} = error;
2231-Self {}
2232-}
2233-}
2234-2235-#[unstable(feature = "btree_cursors", issue = "107540")]
2236-impl fmt::Display for UnorderedError {
2237-fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2238-write!(f, "value is not properly ordered relative to neighbors")
2239-}
2240-}
2241-2242-#[unstable(feature = "btree_cursors", issue = "107540")]
2243-impl Error for UnorderedError {}
2221+pub use super::map::UnorderedKeyError;
2244222222452223#[cfg(test)]
22462224mod tests;