Skip to content

Commit 1a1cee0

Browse files
committed
Update README.md
1 parent 6e018e9 commit 1a1cee0

File tree

4 files changed

+49
-25
lines changed

4 files changed

+49
-25
lines changed

README.md

+21-24
Original file line numberDiff line numberDiff line change
@@ -13,35 +13,36 @@ Examples are tested with version 1.3.0.
1313

1414
* [Homepage](http://www.rust-lang.org/)
1515
* `what_it_looks_like.rs`, `what_it_looks_like2.rs`
16-
* [Tutorial]
17-
* [2.1](http://doc.rust-lang.org/tutorial.html#compiling-your-first-program) Compiling your first program: `tutorial-02_1-hello.rs`
18-
* [3](http://doc.rust-lang.org/tutorial.html#syntax-basics) Syntax basics: `tutorial-03-syntax_basics.rs`
19-
* [4.2](http://doc.rust-lang.org/tutorial.html#pattern-matching) Pattern matching: `tutorial-04_2-pattern-matching.rs`
20-
* [4.3](http://doc.rust-lang.org/tutorial.html#loops) Loops (`for`, `while`, `loop`): `tutorial-04_3-loops.rs`
21-
* [5.1](http://doc.rust-lang.org/tutorial.html#structs) Structs: `tutorial-05_1-structs.rs`
22-
* [5.2](http://doc.rust-lang.org/tutorial.html#enums) Enums: `tutorial-05_2-enum.rs`
23-
* [5.3](http://doc.rust-lang.org/tutorial.html#tuples) Tuples: `tutorial-05_3-tuples.rs`
24-
* [15](http://doc.rust-lang.org/tutorial.html#closures) Closures: `tutorial-15-closure.rs`
25-
* [16](http://doc.rust-lang.org/tutorial.html#methods) Methods, with *constructor*: `tutorial-16-methods.rs`
26-
* [17](http://doc.rust-lang.org/tutorial.html#generics) Generics: `tutorial-17-generics.rs`
16+
* Old Tutorial, deprecated in favor of the [Book]
17+
* 2.1 Compiling your first program: `tutorial-02_1-hello.rs`
18+
* 3 Syntax basics: `tutorial-03-syntax_basics.rs`
19+
* 4.2 Pattern matching: `tutorial-04_2-pattern-matching.rs`
20+
* 4.3 Loops (`for`, `while`, `loop`): `tutorial-04_3-loops.rs`
21+
* 5.1 Structs: `tutorial-05_1-structs.rs`
22+
* 5.2 Enums: `tutorial-05_2-enum.rs`
23+
* 5.3 Tuples: `tutorial-05_3-tuples.rs`
24+
* 15 Closures: `tutorial-15-closure.rs`
25+
* 16 Methods, with *constructor*: `tutorial-16-methods.rs`
26+
* 17 Generics: `tutorial-17-generics.rs`
27+
* Old Rust Threads and Communication Guide, moved into the [Rust Programming Language book](http://doc.rust-lang.org/book/concurrency.html)
28+
* 2.1 Communication: `tutorial-tasks-02_1-communication.rs`
29+
* 2.3 Sharing immutable data without copy: Arc: `tutorial-tasks-02_3-arc.rs`
2730
* [Book]
28-
* [4.6](http://doc.rust-lang.org/book/concurrency.html#threads) Concurrency, threads: `book-4-6-threads.rs`
29-
* [2.1](http://doc.rust-lang.org/guide-tasks.html#communication) Communication: `tutorial-tasks-02_1-communication.rs`
30-
* [2.3](http://doc.rust-lang.org/guide-tasks.html#sharing-immutable-data-without-copy:-arc) Sharing immutable data without copy: Arc: `tutorial-tasks-02_3-arc.rs`
31-
* [Doc unit testing]
31+
* [5.6](http://doc.rust-lang.org/book/concurrency.html#threads) Concurrency, threads: `book-5-6-threads.rs`
32+
* Doc unit testing, moved into the [Rust Programming Language book](http://doc.rust-lang.org/book/testing.html).
3233
* Unit testing in Rust: `unittests.rs`
33-
* [Rust Cheatsheet]
34+
* Old Rust Cheatsheet
3435
* Use Struct to express phantom types: `phantom_type.rs`
3536
* API
3637
* Program to an 'interface', not an 'implementation', by [Josh Davis](http://joshldavis.com/2013/07/01/program-to-an-interface-fool/): `lang-interface.rs`
3738
* Lambda expressions: `lang-lambda.rs`
3839
* Generics, Polymorphism, by [Felix S. Klock II](https://github.com/Rust-Meetup-Paris/Talks/tree/master/introduction_to_rust): `lang-generics.rs`
3940
* Overloading by [Rust By Example](http://rustbyexample.com/ops.html): `lang-overloading.rs`
4041
* Pointer snippets from Dave Herman's talk: `lang-pointers.rs`
41-
* [collections:hashmap::HashMap](http://doc.rust-lang.org/collections/hashmap/struct.HashMap.html): `api-collections-hashmap.rs`
42-
* [getopts](http://doc.rust-lang.org/getopts/index.html): `api-getopts.rs`
43-
* [std::from_str::FromStr](http://doc.rust-lang.org/std/from_str/trait.FromStr.html): `api-std-from_str.rs`
44-
* [std::fs::File](http://doc.rust-lang.org/std/fs/index.html): `api-std-fs-file.rs`
42+
* [std::collections:HashMap](https://doc.rust-lang.org/std/collections/struct.HashMap.html): `api-collections-hashmap.rs`
43+
* [getopts](http://doc.rust-lang.org/getopts/getopts/index.html): `api-getopts.rs`
44+
* [std::FromStr](https://doc.rust-lang.org/core/str/trait.FromStr.htmll): `api-std-from_str.rs`
45+
* [std::fs::File](http://doc.rust-lang.org/std/fs/struct.File.html): `api-std-fs-file.rs`
4546
* [std::vec](http://doc.rust-lang.org/std/vec/index.html): OwnedVector, 2D-arrays, ...: `api-std-vec.rs`
4647
* Some new files:
4748
* `Makefile` to compile, run tests and run benchmarks
@@ -58,12 +59,8 @@ Examples are tested with version 1.3.0.
5859
* Design pattern Template method: `design_pattern-templatemethod.rs`
5960
* Design pattern Chain of Command: `design_pattern-chain_of_command.rs`
6061

61-
[Tutorial]: http://doc.rust-lang.org/tutorial.html
6262
[The Rust Reference Manual]: http://doc.rust-lang.org/rust.html
6363
[Book]: http://doc.rust-lang.org/book/
64-
[Doc unit testing]: http://doc.rust-lang.org/guide-testing.html
65-
[Rust Cheatsheet]: http://doc.rust-lang.org/complement-cheatsheet.html#how-do-i-express-phantom-types?
66-
6764

6865
# Compile and running it
6966

File renamed without changes.

lang-pointers.rs

+27
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@ fn print_point(p: &Point) {
4747
}
4848
}
4949

50+
// http://oct.zoy.org/presentations/rust-devox/#/3/11
51+
fn add_one(mut num: Box<i32>) -> Box<i32> {
52+
*num += 1;
53+
num
54+
}
55+
fn add_one_ref(ref_to_int: &mut i32) {
56+
*ref_to_int += 1;
57+
}
58+
5059
fn main() {
5160
/*
5261
* Snippets from the Dave Herman's presentation (2013-01-06)
@@ -112,4 +121,22 @@ fn main() {
112121
let rc2 = rc1.clone();
113122
//println!("{}", *(rc1.deref()) + *(rc2.deref()));
114123
println!("{}", *rc1 + *rc2);
124+
125+
/*
126+
* http://oct.zoy.org/presentations/rust-devox/#/3/11
127+
* Safety features - Transferring ownership
128+
* Rust allow the owner of a handle to lend out:
129+
* - exactly one mutable reference
130+
* - one or more immutable references
131+
*/
132+
let x = Box::new(5);
133+
println!("before add_one(): {}", x);
134+
let y = add_one(x);
135+
// x is moved by add_one()
136+
println!("after add_one(): {}", y);
137+
138+
let x = &mut 5;
139+
println!("before add_one_ref(): {}", x);
140+
add_one_ref(x);
141+
println!("after add_one_ref(): {}", x);
115142
}

what_it_looks_like2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ fn main() {
77
// `*` or `/` means mul/div by 2
88

99
let program = "+ + * - /";
10-
let mut accumulator = 0i32;
10+
let mut accumulator = 0;
1111

1212
for token in program.chars() {
1313
match token {

0 commit comments

Comments
 (0)