diff --git a/Doc-FAQ-Cheatsheet.md b/Doc-FAQ-Cheatsheet.md index abbda7c..aebe26e 100644 --- a/Doc-FAQ-Cheatsheet.md +++ b/Doc-FAQ-Cheatsheet.md @@ -112,14 +112,14 @@ for value in values.iter() { // value: &int [Phantom types](http://www.haskell.org/haskellwiki/Phantom_type) are types that cannot be constructed at compile time. To express these in rust, zero-variant `enum`s can be used: -~~~rust +```rust enum Open {} enum Closed {} -~~~ +``` Phantom types are useful for enforcing state at compile time. For example: -~~~rust +```rust struct Door(~str); fn close(Door(name): Door) -> Door { @@ -130,9 +130,9 @@ fn open(Door(name): Door) -> Door { Door(name) } -close(Door::(~"front")) // ok -close(Door::(~"front")) // error: mismatched types: expected `main::Door` but found `main::Door` -~~~ +close(Door::(~"front")); // ok +close(Door::(~"front")); // error: mismatched types: expected `main::Door` but found `main::Door` +``` # Contributing to this page