Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
9d9b55c
make invalid_type_param_default lint show up in cargo future-compat r…
RalfJung Jul 15, 2024
468f935
std::thread: available_parallelism implementation for vxWorks proposal.
devnexen Jul 21, 2024
9b165a1
Implement cursors for `BTreeSet`
kmicklas Jul 28, 2024
bbeff8c
set `force_recompile: true` if library is modified
onur-ozkan Jul 30, 2024
6fcc630
update download-rustc documentation
onur-ozkan Jul 30, 2024
0204762
Share `UnorderedKeyError` with `BTReeMap` for set API
kmicklas Aug 1, 2024
4560770
Fix some uses of "map" instead of "set" in `BTreeSet` cursor API docs
kmicklas Aug 1, 2024
cbdc377
Introduce `Cursor`/`CursorMut`/`CursorMutKey` thrichotomy for `BTreeS…
kmicklas Aug 1, 2024
0bc501e
Fix mutability in doc tests for `BTreeSet` cursors
kmicklas Aug 1, 2024
8497800
Add test for updating enum discriminant through pointer
clubby789 Aug 1, 2024
249afea
docs(resolve): more explain about `target`
bvanjoi Aug 4, 2024
2ac0969
handle crates when they are not specified for std docs
onur-ozkan Aug 4, 2024
d8c2b76
run-make: enable msvc for link-dedup
ChrisDenton Aug 4, 2024
491edbf
assert expected json files in `rust-docs-json` component
onur-ozkan Aug 4, 2024
e83a974
Rollup merge of #127655 - RalfJung:invalid_type_param_default, r=comp…
matthiaskrgr Aug 4, 2024
69b7ac8
Rollup merge of #127974 - onur-ozkan:force-std-builds, r=Mark-Simulacrum
matthiaskrgr Aug 4, 2024
d211dad
Rollup merge of #128026 - devnexen:available_parallelism_vxworks, r=M…
matthiaskrgr Aug 4, 2024
86e12f7
Rollup merge of #128309 - kmicklas:btreeset-cursor, r=Amanieu
matthiaskrgr Aug 4, 2024
de80993
Rollup merge of #128500 - clubby789:122600-test, r=Mark-Simulacrum
matthiaskrgr Aug 4, 2024
b8b1b22
Rollup merge of #128630 - bvanjoi:resolve-comment, r=petrochenkov
matthiaskrgr Aug 4, 2024
9710488
Rollup merge of #128631 - onur-ozkan:hotfix, r=Mark-Simulacrum
matthiaskrgr Aug 4, 2024
3300a53
Rollup merge of #128638 - ChrisDenton:link-dedup, r=jieyouxu
matthiaskrgr Aug 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Share UnorderedKeyError with BTReeMap for set API
  • Loading branch information
kmicklas committed Aug 1, 2024
commit 020476296b1aa60f79c2f671c48542afe99cc428
36 changes: 7 additions & 29 deletions library/alloc/src/collections/btree/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::vec::Vec;
use core::borrow::Borrow;
use core::cmp::Ordering::{self, Equal, Greater, Less};
use core::cmp::{max, min};
use core::error::Error;
use core::fmt::{self, Debug};
use core::hash::{Hash, Hasher};
use core::iter::{FusedIterator, Peekable};
Expand Down Expand Up @@ -2177,11 +2176,11 @@ impl<'a, T: Ord, A: Allocator + Clone> CursorMut<'a, T, A> {
///
/// If the inserted element is not greater than the element before the
/// cursor (if any), or if it not less than the element after the cursor (if
/// any), then an [`UnorderedError`] is returned since this would
/// any), then an [`UnorderedKeyError`] is returned since this would
/// invalidate the [`Ord`] invariant between the elements of the set.
#[unstable(feature = "btree_cursors", issue = "107540")]
pub fn insert_after(&mut self, value: T) -> Result<(), UnorderedError> {
self.inner.insert_after(value, SetValZST).map_err(UnorderedError::from_map_error)
pub fn insert_after(&mut self, value: T) -> Result<(), UnorderedKeyError> {
self.inner.insert_after(value, SetValZST)
}

/// Inserts a new element into the set in the gap that the
Expand All @@ -2192,11 +2191,11 @@ impl<'a, T: Ord, A: Allocator + Clone> CursorMut<'a, T, A> {
///
/// If the inserted element is not greater than the element before the
/// cursor (if any), or if it not less than the element after the cursor (if
/// any), then an [`UnorderedError`] is returned since this would
/// any), then an [`UnorderedKeyError`] is returned since this would
/// invalidate the [`Ord`] invariant between the elements of the set.
#[unstable(feature = "btree_cursors", issue = "107540")]
pub fn insert_before(&mut self, value: T) -> Result<(), UnorderedError> {
self.inner.insert_before(value, SetValZST).map_err(UnorderedError::from_map_error)
pub fn insert_before(&mut self, value: T) -> Result<(), UnorderedKeyError> {
self.inner.insert_before(value, SetValZST)
}

/// Removes the next element from the `BTreeSet`.
Expand All @@ -2218,29 +2217,8 @@ impl<'a, T: Ord, A: Allocator + Clone> CursorMut<'a, T, A> {
}
}

/// Error type returned by [`CursorMut::insert_before`] and
/// [`CursorMut::insert_after`] if the element being inserted is not properly
/// ordered with regards to adjacent elements.
#[derive(Clone, PartialEq, Eq, Debug)]
#[unstable(feature = "btree_cursors", issue = "107540")]
pub struct UnorderedError {}

impl UnorderedError {
fn from_map_error(error: super::map::UnorderedKeyError) -> Self {
let super::map::UnorderedKeyError {} = error;
Self {}
}
}

#[unstable(feature = "btree_cursors", issue = "107540")]
impl fmt::Display for UnorderedError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "value is not properly ordered relative to neighbors")
}
}

#[unstable(feature = "btree_cursors", issue = "107540")]
impl Error for UnorderedError {}
pub use super::map::UnorderedKeyError;

#[cfg(test)]
mod tests;