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:
parent
541a302224
commit
42d6e4fb05
@ -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()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user