Skip to content

Instantly share code, notes, and snippets.

@rust-play
Created November 23, 2022 16:51
Show Gist options
  • Save rust-play/77f765c79c13afb3899c376d51e2eb77 to your computer and use it in GitHub Desktop.
Save rust-play/77f765c79c13afb3899c376d51e2eb77 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
use std::marker::PhantomData;
use serde::Serialize;
#[derive(Serialize)]
struct A<T>(PhantomData<T>);
#[derive(Serialize)]
struct B<T>(A<T>);
type GhostlyData<T> = PhantomData<T>;
#[derive(Serialize)]
struct C<T>(GhostlyData<T>);
struct NotSerialize;
fn assert_serialize<T: Serialize>() {}
fn main() {
assert_serialize::<A<NotSerialize>>();
// assert_serialize::<B<NotSerialize>>();
// assert_serialize::<C<NotSerialize>>();
println!("Hello, world!");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment