Skip to content

Instantly share code, notes, and snippets.

View Shaun289's full-sized avatar

Sunjong Park Shaun289

View GitHub Profile
@Shaun289
Shaun289 / formatted_print.rs
Created October 23, 2021 06:07
Rust study : Formatted print
/*
The rust by example ko https://hanbum.gitbooks.io/rustbyexample/content/hello/print.html
compiled on https://play.rust-lang.org/
result:
31 days
Alice, this is Bob, Bob this is Alice
the quick brown fox jumps over the lazy dog
1 of 10 people know binary, the other half don't
[ 1]
[1 ]
@Shaun289
Shaun289 / formatted_print_debug
Created October 25, 2021 21:00
Rust study : Formatted print Debug
/*
The rust by example ko https://hanbum.gitbooks.io/rustbyexample/content/hello/print/print_debug.html
compiled on https://play.rust-lang.org/
result:
12 months in a year
"Christian" "Slater" is the "actor's" name.
Now Structure(3) will print!
Now Deep(Structure(3)) will print!
*/
@Shaun289
Shaun289 / structure.rs
Created October 25, 2021 21:33
Rust study : structure
/*
The rust by example ko https://hanbum.gitbooks.io/rustbyexample/content/custom_types/structs.html
compiled on https://play.rust-lang.org/
result:
point coordinates: (0.3, 0.4)
Rectangle { p1: Point { x: 0.4, y: 0.3 }, p2: Point { x: 0.3, y: 0.4 } }
pair 1 and 0.1
pair contains 1 and 0.1
Area of rect:4.0
New rectangle:Rectangle { p1: Point { x: 1.0, y: 1.0 }, p2: Point { x: 5.0, y: 5.0 } }
@Shaun289
Shaun289 / enum.rs
Created October 27, 2021 00:26
Rust study : enum
/*
The rust by example ko httpshttps://hanbum.gitbooks.io/rustbyexample/content/custom_types/enum.html
compiled on https://play.rust-lang.org/
result:
Has a height of 18
Has a weight of 10
Dave is 72 tall!
Is a scientist!
Is an engineer!
*/
@Shaun289
Shaun289 / use.rs
Created October 27, 2021 03:13
Ruse study : use
/*
The rust by example ko https://hanbum.gitbooks.io/rustbyexample/content/custom_types/enum/enum_use.html
compiled on https://play.rust-lang.org/
result:
The poor have no money..
Civilians work!
*/
// 사용하지 않는 코드 때문에 생성되는 경고를 숨기는 속성
#![allow(dead_code)]
@Shaun289
Shaun289 / c_like_enum.rs
Last active October 28, 2021 00:56
Rust study : c like enum
/*
The rust by example ko https://hanbum.gitbooks.io/rustbyexample/content/custom_types/enum/c_like.html
compiled on https://play.rust-lang.org/
result:
running 1 test
test tests::number ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
@Shaun289
Shaun289 / enum_linked_list.rs
Created October 29, 2021 01:33
Rust study : enum Linked List
/*
The rust by example ko https://hanbum.gitbooks.io/rustbyexample/content/custom_types/enum/testcase_linked_list.html
compiled on https://play.rust-lang.org/
result:
running 1 test
test tests::test_list ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
@Shaun289
Shaun289 / const.rs
Created October 29, 2021 09:12
Rust study : constants and static
/*
The rust by example ko https://hanbum.gitbooks.io/rustbyexample/content/custom_types/constants.html
compiled on https://play.rust-lang.org/
result:
running 1 test
test tests::const_test ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
*/
@Shaun289
Shaun289 / string.rs
Created October 30, 2021 08:38
Rust study : string
/*
The rust by example ko https://hanbum.gitbooks.io/rustbyexample/content/std/str.html
compiled on https://play.rust-lang.org/
I need more pracetice in rust string
result:
Pangram: the quick brown fox jumps over the lazy dog
Words in reverse
->dog
@Shaun289
Shaun289 / array_slice.rs
Last active November 2, 2021 04:17
Rust study : array and slices.
/*
The rust by example ko https://hanbum.gitbooks.io/rustbyexample/content/primitives/array.html
compiled on https://play.rust-lang.org/
result:
Standard Error
Compiling playground v0.0.1 (/playground)
Finished dev [unoptimized + debuginfo] target(s) in 1.09s
Running `target/debug/playground`
thread 'main' panicked at 'index out of bounds: the len is 4 but the index is 5', src/main.rs:17:34