2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
2
Task/Collections/Rust/collections-1.rust
Normal file
2
Task/Collections/Rust/collections-1.rust
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
let a = [1u8,2,3,4,5]; // a is of type [u8; 5];
|
||||
let b = [0;256] // Equivalent to `let b = [0,0,0,0,0,0... repeat 256 times]`
|
||||
3
Task/Collections/Rust/collections-2.rust
Normal file
3
Task/Collections/Rust/collections-2.rust
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
let array = [1,2,3,4,5];
|
||||
let slice = &array[0..2]
|
||||
println!("{:?}", slice);
|
||||
6
Task/Collections/Rust/collections-3.rust
Normal file
6
Task/Collections/Rust/collections-3.rust
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
let mut v = Vec::new();
|
||||
v.push(1);
|
||||
v.push(2);
|
||||
v.push(3);
|
||||
// Or (mostly) equivalently via a convenient macro in the standard library
|
||||
let v = vec![1,2,3];
|
||||
4
Task/Collections/Rust/collections-4.rust
Normal file
4
Task/Collections/Rust/collections-4.rust
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
let x = "abc"; // x is of type &str (a borrowed string slice)
|
||||
let s = String::from(x);
|
||||
// or alternatively
|
||||
let s = x.to_owned();
|
||||
Loading…
Add table
Add a link
Reference in a new issue