Skip to content

Instantly share code, notes, and snippets.

@nikomatsakis
Created September 11, 2018 17:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nikomatsakis/f1c3f8fd14577b6d5cfb326e0851b986 to your computer and use it in GitHub Desktop.
Save nikomatsakis/f1c3f8fd14577b6d5cfb326e0851b986 to your computer and use it in GitHub Desktop.
// NB You must compile with `--crate-type lib` to see the failure!
#![feature(nll)]
pub trait Accessor: Sized {
}
impl Accessor for () { }
pub enum AccessorCow<'a, 'b, T>
where
AccessorTy<'a, T>: 'b,
T: System<'a> + ?Sized,
'a: 'b,
{
/// A reference to an accessor.
Ref(&'b AccessorTy<'a, T>),
/// An owned accessor.
Owned(AccessorTy<'a, T>),
}
type AccessorTy<'a, T> = <<T as System<'a>>::SystemData as DynamicSystemData<'a>>::Accessor;
pub trait System<'a> {
type SystemData: DynamicSystemData<'a>;
}
impl<'a> System<'a> for () {
type SystemData = ();
}
pub trait SystemData<'a> {
}
impl<'a> SystemData<'a> for () {
}
pub trait DynamicSystemData<'a> {
/// The accessor of the `SystemData`, which specifies the read and write dependencies and does
/// the fetching.
type Accessor: Accessor;
}
impl<'a> DynamicSystemData<'a> for () {
type Accessor = ();
}
fn main() {
let x : fn(_) -> _ = AccessorCow::Ref::<()>;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment