From 42d6e4fb05b64e3d7e65399fb4a5e9f6d06590c2 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Tue, 12 Feb 2019 11:46:16 +0100 Subject: [PATCH] tools: borrow: implement Deref for Tied Eg. if you have an x: Tied now you can simply call x.next() as it'll dereference to the Iterator. Signed-off-by: Wolfgang Bumiller --- src/tools/borrow.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/tools/borrow.rs b/src/tools/borrow.rs index 5970828d..66b68ada 100644 --- a/src/tools/borrow.rs +++ b/src/tools/borrow.rs @@ -43,3 +43,17 @@ impl AsMut for Tied { self.1.as_mut().unwrap() } } + +impl std::ops::Deref for Tied { + type Target = U; + + fn deref(&self) -> &U { + self.as_ref() + } +} + +impl std::ops::DerefMut for Tied { + fn deref_mut(&mut self) -> &mut U { + self.as_mut() + } +}