Skip to content

Commit 37a3131

Browse files
committed
doc: Update with changes in field privacy
1 parent 8093427 commit 37a3131

File tree

3 files changed

+11
-14
lines changed

3 files changed

+11
-14
lines changed

src/doc/guide-unsafe.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ use std::ptr;
200200
// Unique<T> has the same semantics as ~T
201201
pub struct Unique<T> {
202202
// It contains a single raw, mutable pointer to the object in question.
203-
priv ptr: *mut T
203+
ptr: *mut T
204204
}
205205
206206
// Implement methods for creating and using the values in the box.

src/doc/rust.md

+6-9
Original file line numberDiff line numberDiff line change
@@ -1527,12 +1527,9 @@ of an item to see whether it should be allowed or not. This is where privacy
15271527
warnings are generated, or otherwise "you used a private item of another module
15281528
and weren't allowed to."
15291529

1530-
By default, everything in rust is *private*, with two exceptions. The first
1531-
exception is that struct fields are public by default (but the struct itself is
1532-
still private by default), and the remaining exception is that enum variants in
1533-
a `pub` enum are the default visibility of the enum container itself.. You are
1534-
allowed to alter this default visibility with the `pub` keyword (or `priv`
1535-
keyword for struct fields and enum variants). When an item is declared as `pub`,
1530+
By default, everything in rust is *private*, with one exception. Enum variants
1531+
in a `pub` enum are also public by default. You are allowed to alter this
1532+
default visibility with the `priv` keyword. When an item is declared as `pub`,
15361533
it can be thought of as being accessible to the outside world. For example:
15371534

15381535
~~~~
@@ -1542,7 +1539,7 @@ struct Foo;
15421539
15431540
// Declare a public struct with a private field
15441541
pub struct Bar {
1545-
priv field: int
1542+
field: int
15461543
}
15471544
15481545
// Declare a public enum with public and private variants
@@ -2354,7 +2351,7 @@ The following are examples of structure expressions:
23542351
~~~~
23552352
# struct Point { x: f64, y: f64 }
23562353
# struct TuplePoint(f64, f64);
2357-
# mod game { pub struct User<'a> { name: &'a str, age: uint, score: uint } }
2354+
# mod game { pub struct User<'a> { pub name: &'a str, pub age: uint, pub score: uint } }
23582355
# struct Cookie; fn some_fn<T>(t: T) {}
23592356
Point {x: 10.0, y: 20.0};
23602357
TuplePoint(10.0, 20.0);
@@ -3140,7 +3137,7 @@ The types `char` and `str` hold textual data.
31403137
A value of type `char` is a [Unicode scalar value](
31413138
http://www.unicode.org/glossary/#unicode_scalar_value)
31423139
(ie. a code point that is not a surrogate),
3143-
represented as a 32-bit unsigned word in the 0x0000 to 0xD7FF
3140+
represented as a 32-bit unsigned word in the 0x0000 to 0xD7FF
31443141
or 0xE000 to 0x10FFFF range.
31453142
A `[char]` vector is effectively an UCS-4 / UTF-32 string.
31463143

src/doc/tutorial.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -2657,8 +2657,8 @@ Rust doesn't support encapsulation: both struct fields and methods can
26572657
be private. But this encapsulation is at the module level, not the
26582658
struct level.
26592659

2660-
For convenience, fields are _public_ by default, and can be made _private_ with
2661-
the `priv` keyword:
2660+
Fields are _private_ by default, and can be made _public_ with
2661+
the `pub` keyword:
26622662

26632663
~~~
26642664
mod farm {
@@ -2667,8 +2667,8 @@ mod farm {
26672667
# impl Human { pub fn rest(&self) { } }
26682668
# pub fn make_me_a_farm() -> Farm { Farm { chickens: ~[], farmer: Human(0) } }
26692669
pub struct Farm {
2670-
priv chickens: ~[Chicken],
2671-
farmer: Human
2670+
chickens: ~[Chicken],
2671+
pub farmer: Human
26722672
}
26732673
26742674
impl Farm {

0 commit comments

Comments
 (0)