This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
The rust by example ko https://hanbum.gitbooks.io/rustbyexample/content/fn/methods.html | |
compiled on https://play.rust-lang.org/ | |
result : | |
*/ | |
#[derive(Debug)] | |
struct Point { | |
x: f64, | |
y: f64, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
The rust by example ko https://hanbum.gitbooks.io/rustbyexample/content/flow_control/while_let.html | |
compiled on https://play.rust-lang.org/ | |
result : | |
optional is Some(0) | |
optional is Some(1) | |
optional is Some(2) | |
optional is Some(3) | |
optional is Some(4) | |
optional is Some(5) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
The rust by example ko https://hanbum.gitbooks.io/rustbyexample/content/flow_control/if_let.html | |
compiled on https://play.rust-lang.org/ | |
result : | |
Matched 7! | |
Not matched : letter | |
emoticon is None! | |
*/ | |
fn main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
The rust by example ko https://hanbum.gitbooks.io/rustbyexample/content/flow_control/match/guard.html | |
compiled on https://play.rust-lang.org/ | |
result : | |
Antimatter! 2 and -2 | |
x:2 == y | |
The first ons is odd | |
No correlation... | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
The rust by example ko https://hanbum.gitbooks.io/rustbyexample/content/flow_control/match/destructuring/destructure_structures.html | |
compiled on https://play.rust-lang.org/ | |
result : | |
a = 1, b = 2, y = 3 | |
x = (1, 2), y = 3 | |
i = 3, j = (1, 2) | |
y = 3 | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
The rust by example ko https://hanbum.gitbooks.io/rustbyexample/content/flow_control/match/destructuring/destructure_pointers.html | |
compiled on https://play.rust-lang.org/ | |
result : | |
Got a value via destructuring 4 | |
Got a value via dereferencing 4 | |
Got a reference to a value 5 | |
We added 10. `mut_value`: 16 | |
mut_value after match : 16 | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
The rust by example ko httpshttps://hanbum.gitbooks.io/rustbyexample/content/flow_control/match/destructuring/destructure_enum.html | |
compiled on https://play.rust-lang.org/ | |
result : | |
This color is Red | |
This color is Blue | |
This color is Green | |
R:255 G:255 B:255 | |
C:128 M:128 Y:128 K:128 | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
The rust by example ko https://hanbum.gitbooks.io/rustbyexample/content/flow_control/match/destructuring/destructure_tuple.html | |
compiled on https://play.rust-lang.org/ | |
result : | |
Tell me about (0, -2) | |
First is 0 and y is -2 | |
Tell me about (2, 0) | |
x is 2 and last is 0 | |
Tell me about (1, 1) | |
It doesn't matter what they are |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
The rust by example ko https://hanbum.gitbooks.io/rustbyexample/content/cast/alias.html | |
compiled on https://play.rust-lang.org/ | |
result : | |
5 nanoseconds + 2 inches = 7 unit? | |
*/ | |
// NanoSecond는 u64의 새로운 이름. 반드시 CamelCase로 이름을 지어야함. | |
type NanoSecond = u64; | |
type Inch = u64; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
The rust by example ko https://hanbum.gitbooks.io/rustbyexample/content/cast/literals.html | |
compiled on https://play.rust-lang.org/ | |
result : | |
size of x in bytes: 1 | |
size of x in bytes: 4 | |
size of x in bytes: 4 | |
size of x in bytes: 4 | |
size of x in bytes: 8 | |
*/ |