Created
September 11, 2018 17:23
-
-
Save nikomatsakis/f1c3f8fd14577b6d5cfb326e0851b986 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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