-
-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1978 from hannobraun/insert
Make `IsInserted` more useful
- Loading branch information
Showing
4 changed files
with
48 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use std::borrow::Borrow; | ||
|
||
use crate::storage::Handle; | ||
|
||
/// Indicate whether an object has been inserted | ||
/// | ||
/// Intended to be used as a type parameter bound for structs that need to track | ||
/// whether their contents have been inserted or not. | ||
pub trait IsInserted { | ||
/// The type of the object for which the insertion status is tracked | ||
type T<T>: Borrow<T>; | ||
} | ||
|
||
/// Indicate that an object has been inserted | ||
/// | ||
/// See [`IsInserted`]. | ||
pub struct IsInsertedYes; | ||
|
||
impl IsInserted for IsInsertedYes { | ||
type T<T> = Handle<T>; | ||
} | ||
|
||
/// Indicate that an object has not been inserted | ||
/// | ||
/// See [`IsInserted`]. | ||
pub struct IsInsertedNo; | ||
|
||
impl IsInserted for IsInsertedNo { | ||
type T<T> = T; | ||
} |
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,7 @@ | ||
mod insert_trait; | ||
mod is_inserted; | ||
|
||
pub use self::{ | ||
insert_trait::Insert, | ||
is_inserted::{IsInserted, IsInsertedNo, IsInsertedYes}, | ||
}; |
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