Skip to content
Snippets Groups Projects
Commit b4f7bf9f authored by Per Lindgren's avatar Per Lindgren
Browse files

trait example

parent f92f35e6
No related branches found
No related tags found
No related merge requests found
...@@ -5,7 +5,8 @@ use std::marker::Sized; ...@@ -5,7 +5,8 @@ use std::marker::Sized;
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone)]
#[repr(C)] #[repr(C)]
struct Point {
struct Plain {
x: u32, x: u32,
y: u32, y: u32,
} }
...@@ -30,7 +31,7 @@ where ...@@ -30,7 +31,7 @@ where
trait OkInState {} trait OkInState {}
impl OkInState for .. {} impl OkInState for .. {}
impl !OkInState for Point {} impl !OkInState for Plain {}
// You cannot implement it yourself // You cannot implement it yourself
//impl OkInState for Point {} //impl OkInState for Point {}
...@@ -47,7 +48,7 @@ where ...@@ -47,7 +48,7 @@ where
struct X {} struct X {}
fn main() { fn main() {
let mut p = Point { x: 0, y: 1 }; let mut p = Plain { x: 0, y: 1 };
let _c = Cont { data: X {} }; let _c = Cont { data: X {} };
let _c = Cont { data: p }; let _c = Cont { data: p };
println!(" p {:?}", p); println!(" p {:?}", p);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment