Skip to content

Instantly share code, notes, and snippets.

@scalexm scalexm/gat.rs
Last active Jul 31, 2018

Embed
What would you like to do?
// chalk does not handle outlive requirements for now, so we say that
// `T: 'a` iff `T: Outlives<'a>`
trait Outlives<'a> { }
struct Slice<'a, T> where T: Outlives<'a> { }
// hack for implied outlive requirements: if you have e.g. `&'a T: 'b` then you must have `T: 'b`
// (see https://play.rust-lang.org/?gist=3e5410767c6d596ed7c5b2686f9f6ba1&version=stable&mode=debug&edition=2015)
impl<'a, 'b, T> Outlives<'b> for T where Slice<'a, T>: Outlives<'b> { }
trait StreamingIterator {
// if you remove the where clause, then chalk won't accept the impl below
type Item<'a> where <Self as StreamingIterator>::Item<'a>: Outlives<'a>;
}
struct Stream<T> { }
impl<T> StreamingIterator for Stream<T> {
type Item<'a> = Slice<'a, T>;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.