fix: get MatchBorrow type check working for references 3 deep

This commit is contained in:
Ryan Leckey
2020-07-26 23:07:12 -07:00
parent fe04a1b612
commit d06de149a0
3 changed files with 54 additions and 20 deletions

View File

@@ -81,10 +81,38 @@ impl<'a> MatchBorrowExt for MatchBorrow<&'a [u8], Vec<u8>> {
type Matched = &'a [u8];
}
impl<'a, T> MatchBorrowExt for MatchBorrow<&'a T, T> {
impl<T> MatchBorrowExt for MatchBorrow<&'_ T, T> {
type Matched = T;
}
impl<T> MatchBorrowExt for MatchBorrow<&'_ &'_ T, T> {
type Matched = T;
}
impl<T> MatchBorrowExt for MatchBorrow<T, &'_ T> {
type Matched = T;
}
impl<T> MatchBorrowExt for MatchBorrow<T, &'_ &'_ T> {
type Matched = T;
}
impl<T> MatchBorrowExt for MatchBorrow<Option<&'_ T>, Option<T>> {
type Matched = Option<T>;
}
impl<T> MatchBorrowExt for MatchBorrow<Option<&'_ &'_ T>, Option<T>> {
type Matched = Option<T>;
}
impl<T> MatchBorrowExt for MatchBorrow<Option<T>, Option<&'_ T>> {
type Matched = Option<T>;
}
impl<T> MatchBorrowExt for MatchBorrow<Option<T>, Option<&'_ &'_ T>> {
type Matched = Option<T>;
}
impl<T, U> MatchBorrowExt for &'_ MatchBorrow<T, U> {
type Matched = U;
}
@@ -125,5 +153,11 @@ fn test_match_borrow() {
let (_, match_borrow) = MatchBorrow::new(&&0i64, &0i64);
let _: i64 = match_borrow.match_borrow();
let (_, match_borrow) = MatchBorrow::new(&0i64, &0i64);
let _: i64 = match_borrow.match_borrow();
let (_, match_borrow) = MatchBorrow::new(0i64, &0i64);
let _: i64 = match_borrow.match_borrow();
}
}