-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix BTreeSet's range API panic message, document
- Loading branch information
Showing
7 changed files
with
117 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ mod node; | |
mod remove; | ||
mod search; | ||
pub mod set; | ||
mod set_val; | ||
mod split; | ||
|
||
#[doc(hidden)] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/// Zero-Sized Type (ZST) for internal `BTreeSet` values. | ||
/// Used instead of `()` to differentiate between: | ||
/// * `BTreeMap<T, ()>` (possible user-defined map) | ||
/// * `BTreeMap<T, SetValZST>` (internal set representation) | ||
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Default)] | ||
pub struct SetValZST; | ||
|
||
/// A trait to differentiate between `BTreeMap` and `BTreeSet` values. | ||
/// Returns `true` only for type `SetValZST`, `false` for all other types (blanket implementation). | ||
/// `TypeId` requires a `'static` lifetime, use of this trait avoids that restriction. | ||
/// | ||
/// [`TypeId`]: std::any::TypeId | ||
pub trait IsSetVal { | ||
fn is_set_val() -> bool; | ||
} | ||
|
||
// Blanket implementation | ||
impl<V> IsSetVal for V { | ||
default fn is_set_val() -> bool { | ||
false | ||
} | ||
} | ||
|
||
// Specialization | ||
impl IsSetVal for SetValZST { | ||
fn is_set_val() -> bool { | ||
true | ||
} | ||
} |