Skip to content

Instantly share code, notes, and snippets.

@mnemnion
Created November 23, 2014 17:24
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 mnemnion/a9a6840201463ca1f82c to your computer and use it in GitHub Desktop.
Save mnemnion/a9a6840201463ca1f82c to your computer and use it in GitHub Desktop.
This should be at least warned against
type Cell = u32 ;
type Kilo = u32 ;
fn main() {
let x: Cell = 5 ;
let y: Kilo = 10 ;
let z = x + y ;
println!("Cell is {}, Kilo is {}, Nonsense is {}", x, y, z);
}
@mnemnion
Copy link
Author

The alternative is basically

type CellUInt = u32 ;

struct Cell(CellUInt) ;

let x: CellUInt = Cell(a_cell) ; //etc

and that's probably better. Day 4 humans and robots, day 4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment