From c9400f06e8d2443dbf9073e53f04bce46133926c Mon Sep 17 00:00:00 2001 From: Jag Talon Date: Tue, 25 Feb 2014 01:17:31 -0500 Subject: [PATCH 1/3] tutorial: clearer explanation of freezing. - "Lending an immutable pointer" might be confusing. It was not discussed why borrowed pointers are immutable in the first place. - Make it clear that the borrowed pointers are immutable even if the variable was declared with `mut`. - Make it clear that we cannot even assign anything to the variable while its value is being borrowed. --- 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 c2469e0c171f8..bac9097c182f7 100644 --- a/src/doc/tutorial.md +++ b/src/doc/tutorial.md @@ -1468,14 +1468,14 @@ For a more in-depth explanation of references and lifetimes, read the ## Freezing -Lending an immutable pointer to an object freezes it and prevents mutation. +Lending an &-pointer to an object freezes it and prevents mutation--even if the object was declared as `mut`. `Freeze` objects have freezing enforced statically at compile-time. An example of a non-`Freeze` type is [`RefCell`][refcell]. ~~~~ let mut x = 5; { - let y = &x; // `x` is now frozen, it cannot be modified + let y = &x; // `x` is now frozen. It cannot be modified or re-assigned. } // `x` is now unfrozen again # x = 3; From 87af15606618eb62718ea40b1f00790a15879418 Mon Sep 17 00:00:00 2001 From: Jag Talon Date: Tue, 25 Feb 2014 10:17:42 -0500 Subject: [PATCH 2/3] tutorial: change "--" to an em-dash. --- 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 bac9097c182f7..36d4c4520f508 100644 --- a/src/doc/tutorial.md +++ b/src/doc/tutorial.md @@ -1468,7 +1468,7 @@ For a more in-depth explanation of references and lifetimes, read the ## Freezing -Lending an &-pointer to an object freezes it and prevents mutation--even if the object was declared as `mut`. +Lending an &-pointer to an object freezes it and prevents mutation—even if the object was declared as `mut`. `Freeze` objects have freezing enforced statically at compile-time. An example of a non-`Freeze` type is [`RefCell`][refcell]. From 187ba04203f635dca4912298d69331cd3c21672a Mon Sep 17 00:00:00 2001 From: Jag Talon Date: Tue, 25 Feb 2014 10:20:19 -0500 Subject: [PATCH 3/3] tutorial: change instances of "--" to em-dash. --- 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 36d4c4520f508..3363f78ad0a09 100644 --- a/src/doc/tutorial.md +++ b/src/doc/tutorial.md @@ -2021,8 +2021,8 @@ C++ templates. ## Traits -Within a generic function -- that is, a function parameterized by a -type parameter, say, `T` -- the operations we can do on arguments of +Within a generic function—that is, a function parameterized by a +type parameter, say, `T`—the operations we can do on arguments of type `T` are quite limited. After all, since we don't know what type `T` will be instantiated with, we can't safely modify or query values of type `T`. This is where _traits_ come into play. Traits are Rust's