From 43a179eba7889ddd71b63ff0bccf33161eda4c5a Mon Sep 17 00:00:00 2001 From: Jonas Hietala Date: Wed, 16 Jul 2014 09:41:56 +0200 Subject: [PATCH 1/5] Rename Option to MyOption in tutorial to workaround iteration bug. #15409 --- src/doc/tutorial.md | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/doc/tutorial.md b/src/doc/tutorial.md index 10f67876e508f..532b2eec9ea9a 100644 --- a/src/doc/tutorial.md +++ b/src/doc/tutorial.md @@ -2079,21 +2079,23 @@ struct Stack { elements: Vec } -enum Option { - Some(T), - None +enum MyOption { + MySome(T), + MyNone } # fn main() {} ~~~~ These declarations can be instantiated to valid types like `Set`, -`Stack`, and `Option`. - -The last type in that example, `Option`, appears frequently in Rust code. -Because Rust does not have null pointers (except in unsafe code), we need -another way to write a function whose result isn't defined on every possible -combination of arguments of the appropriate types. The usual way is to write -a function that returns `Option` instead of `T`. +`Stack`, and `MyOption`. + +The last type in that example, `MyOption`, is already defined in Rust as +the type `Option` with the constants `Some(T)` and `None`. +`Option` appears frequently in Rust code. +Because Rust does not have null pointers (except in unsafe code), +we need another way to write a function whose result isn't defined on every +possible combination of arguments of the appropriate types. The usual way is to +write a function that returns `Option` instead of `T`.` ~~~~ # struct Point { x: f64, y: f64 } From 84a7f60df8e458d79574720bd57120159a0155f0 Mon Sep 17 00:00:00 2001 From: Jonas Hietala Date: Wed, 16 Jul 2014 09:49:44 +0200 Subject: [PATCH 2/5] Remove extra ` --- src/doc/tutorial.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/doc/tutorial.md b/src/doc/tutorial.md index 532b2eec9ea9a..fde4194701ecb 100644 --- a/src/doc/tutorial.md +++ b/src/doc/tutorial.md @@ -979,7 +979,7 @@ let mut b = Foo { x: 5, y: box 10 }; b.x = 10; ~~~~ -If an object doesn't contain any non-`Send` types, it consists of a single +If an object doesn't contain any non-Send types, it consists of a single ownership tree and is itself given the `Send` trait which allows it to be sent between tasks. Custom destructors can only be implemented directly on types that are `Send`, but non-`Send` types can still *contain* types with custom @@ -2095,7 +2095,7 @@ the type `Option` with the constants `Some(T)` and `None`. Because Rust does not have null pointers (except in unsafe code), we need another way to write a function whose result isn't defined on every possible combination of arguments of the appropriate types. The usual way is to -write a function that returns `Option` instead of `T`.` +write a function that returns `Option` instead of `T`. ~~~~ # struct Point { x: f64, y: f64 } From c0689d6a65b31259282e19c7692a1d420f806add Mon Sep 17 00:00:00 2001 From: Jonas Hietala Date: Wed, 16 Jul 2014 09:50:52 +0200 Subject: [PATCH 3/5] Revert non-Send to non-`Send`. --- src/doc/tutorial.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/tutorial.md b/src/doc/tutorial.md index fde4194701ecb..80c2369b2e03e 100644 --- a/src/doc/tutorial.md +++ b/src/doc/tutorial.md @@ -979,7 +979,7 @@ let mut b = Foo { x: 5, y: box 10 }; b.x = 10; ~~~~ -If an object doesn't contain any non-Send types, it consists of a single +If an object doesn't contain any non-`Send` types, it consists of a single ownership tree and is itself given the `Send` trait which allows it to be sent between tasks. Custom destructors can only be implemented directly on types that are `Send`, but non-`Send` types can still *contain* types with custom From 899f39b62b24cd5f78d9476ba6bd142eff73484c Mon Sep 17 00:00:00 2001 From: Jonas Hietala Date: Wed, 16 Jul 2014 17:04:12 +0200 Subject: [PATCH 4/5] Tutorial, use Maybe instead of MyOption. --- src/doc/tutorial.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/doc/tutorial.md b/src/doc/tutorial.md index 80c2369b2e03e..892f6167027b9 100644 --- a/src/doc/tutorial.md +++ b/src/doc/tutorial.md @@ -2079,17 +2079,17 @@ struct Stack { elements: Vec } -enum MyOption { - MySome(T), - MyNone +enum Maybe { + Just(T), + Nothing } # fn main() {} ~~~~ These declarations can be instantiated to valid types like `Set`, -`Stack`, and `MyOption`. +`Stack`, and `Maybe`. -The last type in that example, `MyOption`, is already defined in Rust as +The last type in that example, `Maybe`, is already defined in Rust as the type `Option` with the constants `Some(T)` and `None`. `Option` appears frequently in Rust code. Because Rust does not have null pointers (except in unsafe code), From 339e47c73c4489cfa32082b595fb6f14b26449c7 Mon Sep 17 00:00:00 2001 From: Jonas Hietala Date: Wed, 16 Jul 2014 17:33:58 +0200 Subject: [PATCH 5/5] Rename constants to variants. --- src/doc/tutorial.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/tutorial.md b/src/doc/tutorial.md index 892f6167027b9..325eb9f0a2a5b 100644 --- a/src/doc/tutorial.md +++ b/src/doc/tutorial.md @@ -2090,7 +2090,7 @@ These declarations can be instantiated to valid types like `Set`, `Stack`, and `Maybe`. The last type in that example, `Maybe`, is already defined in Rust as -the type `Option` with the constants `Some(T)` and `None`. +the type `Option` with the variants `Some(T)` and `None`. `Option` appears frequently in Rust code. Because Rust does not have null pointers (except in unsafe code), we need another way to write a function whose result isn't defined on every