Skip to content

Instantly share code, notes, and snippets.

@rust-play
Created January 17, 2019 02:42
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 rust-play/89817f8251e78f2c1512d473377222f6 to your computer and use it in GitHub Desktop.
Save rust-play/89817f8251e78f2c1512d473377222f6 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
#![stable(feature = "playground", since = "0.0.0")]
#![feature(const_fn, staged_api)]
#![allow(dead_code)]
use core::marker::PhantomData;
#[stable(feature = "iter_empty", since = "1.2.0")]
pub struct Empty<T: 'static>(PhantomData<&'static T>);
impl<T> Empty<T> {
#[stable(feature = "iter_empty", since = "1.2.0")]
pub const fn new() -> Self {
Empty(PhantomData)
}
}
fn covariant<'a>(empty: Empty<&'static u8>) -> Empty<&'a u8> {
empty
}
fn main() {
fn assert_send_and_sync<T: Send + Sync>() {}
let _ = assert_send_and_sync::<Empty<*mut u8>>;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment