pub trait TokenCellTrait<T: ?Sized, Token: TokenTrait<ComparisonMaySpuriouslyEq = False>> {
// Required methods
fn try_guard<'l>(
&'l self,
token: &'l Token,
) -> Result<TokenGuard<'l, T, Token>, Token::ComparisonError>;
fn try_borrow<'l>(
&'l self,
token: &'l Token,
) -> Result<&'l T, Token::ComparisonError>;
fn try_guard_mut<'l>(
&'l self,
token: &'l mut Token,
) -> Result<TokenGuardMut<'l, T, Token>, Token::ComparisonError>;
fn try_borrow_mut<'l>(
&'l self,
token: &'l mut Token,
) -> Result<&'l mut T, Token::ComparisonError>;
// Provided methods
fn borrow<'l>(&'l self, token: &'l Token) -> &'l T
where Token::ComparisonError: Debug { ... }
fn borrow_mut<'l>(&'l self, token: &'l mut Token) -> &'l mut T
where Token::ComparisonError: Debug { ... }
fn map<'a, U, F: FnOnce(TokenGuard<'a, T, Token>) -> U>(
&'a self,
f: F,
) -> TokenMap<'a, T, U, F, Self, Token, False> { ... }
fn map_mut<'a, U, F: FnOnce(TokenGuardMut<'a, T, Token>) -> U>(
&'a self,
f: F,
) -> TokenMapMut<'a, T, U, F, Self, Token, False> { ... }
}Expand description
Common ways to interract with a TokenCell.
Note that while many functions document fallihle behaviours, this behaviour is only reachable for tokens that perform runtime check. These are identifiable by their TokenTrait::ComparisonError type not being core::convert::Infallible.
Required Methods§
Sourcefn try_guard<'l>(
&'l self,
token: &'l Token,
) -> Result<TokenGuard<'l, T, Token>, Token::ComparisonError>
fn try_guard<'l>( &'l self, token: &'l Token, ) -> Result<TokenGuard<'l, T, Token>, Token::ComparisonError>
Sourcefn try_borrow<'l>(
&'l self,
token: &'l Token,
) -> Result<&'l T, Token::ComparisonError>
fn try_borrow<'l>( &'l self, token: &'l Token, ) -> Result<&'l T, Token::ComparisonError>
Attempts to borrow the inner data.
§Errors
If the token provides runtime checking and detects that self was constructed with another token.
Sourcefn try_guard_mut<'l>(
&'l self,
token: &'l mut Token,
) -> Result<TokenGuardMut<'l, T, Token>, Token::ComparisonError>
fn try_guard_mut<'l>( &'l self, token: &'l mut Token, ) -> Result<TokenGuardMut<'l, T, Token>, Token::ComparisonError>
Sourcefn try_borrow_mut<'l>(
&'l self,
token: &'l mut Token,
) -> Result<&'l mut T, Token::ComparisonError>
fn try_borrow_mut<'l>( &'l self, token: &'l mut Token, ) -> Result<&'l mut T, Token::ComparisonError>
Attempts to borrow the inner data mutably.
§Errors
If the token provides runtime checking and detects that self was constructed with another token.
Provided Methods§
Sourcefn borrow<'l>(&'l self, token: &'l Token) -> &'l Twhere
Token::ComparisonError: Debug,
fn borrow<'l>(&'l self, token: &'l Token) -> &'l Twhere
Token::ComparisonError: Debug,
Borrows the inner data, panicking if the wrong token was used as key.
Sourcefn borrow_mut<'l>(&'l self, token: &'l mut Token) -> &'l mut Twhere
Token::ComparisonError: Debug,
fn borrow_mut<'l>(&'l self, token: &'l mut Token) -> &'l mut Twhere
Token::ComparisonError: Debug,
Borrows the inner data mutably, panicking if the wrong token was used as key.
Sourcefn map<'a, U, F: FnOnce(TokenGuard<'a, T, Token>) -> U>(
&'a self,
f: F,
) -> TokenMap<'a, T, U, F, Self, Token, False>
fn map<'a, U, F: FnOnce(TokenGuard<'a, T, Token>) -> U>( &'a self, f: F, ) -> TokenMap<'a, T, U, F, Self, Token, False>
Constructs a lazy computation that can then be applied using the token.
Sourcefn map_mut<'a, U, F: FnOnce(TokenGuardMut<'a, T, Token>) -> U>(
&'a self,
f: F,
) -> TokenMapMut<'a, T, U, F, Self, Token, False>
fn map_mut<'a, U, F: FnOnce(TokenGuardMut<'a, T, Token>) -> U>( &'a self, f: F, ) -> TokenMapMut<'a, T, U, F, Self, Token, False>
Constructs a lazy computation that can then be applied using the token.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".