Add as_ref and as_mut functions to Toggle (#1684)

This commit is contained in:
Ashley 2020-08-10 10:11:58 +02:00 committed by GitHub
parent 32df8ea192
commit b6ec95eb77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -51,6 +51,16 @@ impl<TBehaviour> Toggle<TBehaviour> {
pub fn is_enabled(&self) -> bool {
self.inner.is_some()
}
/// Returns a reference to the inner `NetworkBehaviour`.
pub fn as_ref(&self) -> Option<&TBehaviour> {
self.inner.as_ref()
}
/// Returns a mutable reference to the inner `NetworkBehaviour`.
pub fn as_mut(&mut self) -> Option<&mut TBehaviour> {
self.inner.as_mut()
}
}
impl<TBehaviour> From<Option<TBehaviour>> for Toggle<TBehaviour> {