Skip to content

Commit

Permalink
Add as_ref and as_mut functions to Toggle (#1684)
Browse files Browse the repository at this point in the history
  • Loading branch information
expenses committed Aug 10, 2020
1 parent 32df8ea commit b6ec95e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions swarm/src/toggle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down

0 comments on commit b6ec95e

Please sign in to comment.