tools: borrow: implement Deref for Tied

Eg. if you have an x: Tied<Dir, Iterator> now you can simply
call x.next() as it'll dereference to the Iterator.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2019-02-12 11:46:16 +01:00
parent 541a302224
commit 42d6e4fb05
1 changed files with 14 additions and 0 deletions

View File

@ -43,3 +43,17 @@ impl<T, U: ?Sized> AsMut<U> for Tied<T, U> {
self.1.as_mut().unwrap()
}
}
impl<T, U: ?Sized> std::ops::Deref for Tied<T, U> {
type Target = U;
fn deref(&self) -> &U {
self.as_ref()
}
}
impl<T, U: ?Sized> std::ops::DerefMut for Tied<T, U> {
fn deref_mut(&mut self) -> &mut U {
self.as_mut()
}
}