Skip to content

Commit dfb251a

Browse files
committed
---
yaml --- r: 153593 b: refs/heads/try2 c: 56218f5 h: refs/heads/master i: 153591: 76eaf58 v: v3
1 parent 2523660 commit dfb251a

File tree

127 files changed

+743
-1851
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+743
-1851
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 8748a69e6cf6d6e922ddf07bd9ef69a67ebc83b6
8+
refs/heads/try2: 56218f5dfc3677be77bb52c0d298da2b12de99d3
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/mk/docs.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ DOCS := index intro tutorial guide guide-ffi guide-macros guide-lifetimes \
3030
guide-tasks guide-container guide-pointers guide-testing \
3131
guide-runtime complement-bugreport \
3232
complement-lang-faq complement-design-faq complement-project-faq rust \
33-
rustdoc guide-unsafe guide-strings
33+
rustdoc guide-unsafe
3434

3535
PDF_DOCS := tutorial rust
3636

branches/try2/src/doc/guide-strings.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
% The Strings Guide
22

3+
# Strings
4+
35
Strings are an important concept to master in any programming language. If you
46
come from a managed language background, you may be surprised at the complexity
57
of string handling in a systems programming language. Efficient access and
@@ -12,7 +14,7 @@ Additionally, strings are not null-terminated and can contain null bytes.
1214

1315
Rust has two main types of strings: `&str` and `String`.
1416

15-
# &str
17+
## &str
1618

1719
The first kind is a `&str`. This is pronounced a 'string slice.' String literals
1820
are of the type `&str`:
@@ -36,7 +38,7 @@ Like vector slices, string slices are simply a pointer plus a length. This
3638
means that they're a 'view' into an already-allocated string, such as a
3739
`&'static str` or a `String`.
3840

39-
# String
41+
## String
4042

4143
A `String` is a heap-allocated string. This string is growable, and is also
4244
guaranteed to be UTF-8.
@@ -71,9 +73,9 @@ let x: &[u8] = &[b'a', b'b'];
7173
let stack_str: &str = str::from_utf8(x).unwrap();
7274
```
7375

74-
# Best Practices
76+
## Best Practices
7577

76-
## `String` vs. `&str`
78+
### `String` vs. `&str`
7779

7880
In general, you should prefer `String` when you need ownership, and `&str` when
7981
you just need to borrow a string. This is very similar to using `Vec<T>` vs. `&[T]`,
@@ -96,7 +98,7 @@ need, and it can make your lifetimes more complex. Furthermore, you can pass
9698
either kind of string into `foo` by using `.as_slice()` on any `String` you
9799
need to pass in, so the `&str` version is more flexible.
98100

99-
## Comparisons
101+
### Comparisons
100102

101103
To compare a String to a constant string, prefer `as_slice()`...
102104

@@ -121,7 +123,7 @@ fn compare(string: String) {
121123
Converting a `String` to a `&str` is cheap, but converting the `&str` to a
122124
`String` involves an allocation.
123125

124-
# Other Documentation
126+
## Other Documentation
125127

126128
* [the `&str` API documentation](/std/str/index.html)
127129
* [the `String` API documentation](std/string/index.html)

branches/try2/src/doc/guide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ arguments we pass to functions and macros, if you're passing more than one.
583583
When you just use the double curly braces, Rust will attempt to display the
584584
value in a meaningful way by checking out its type. If you want to specify the
585585
format in a more detailed manner, there are a [wide number of options
586-
available](/std/fmt/index.html). For now, we'll just stick to the default:
586+
available](/std/fmt/index.html). Fow now, we'll just stick to the default:
587587
integers aren't very complicated to print.
588588

589589
So, we've cleared up all of the confusion around bindings, with one exception:

branches/try2/src/doc/index.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ li {list-style-type: none; }
1313

1414
# Guides
1515

16-
* [Strings](guide-strings.html)
1716
* [Pointers](guide-pointers.html)
1817
* [References and Lifetimes](guide-lifetimes.html)
1918
* [Containers and Iterators](guide-container.html)

branches/try2/src/doc/tutorial.md

Lines changed: 22 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -716,8 +716,8 @@ When an enum has simple integer discriminators, you can apply the `as` cast
716716
operator to convert a variant to its discriminator value as an `int`:
717717

718718
~~~~
719-
# enum Direction { North, East, South, West }
720-
println!( "North => {}", North as int );
719+
# #[deriving(Show)] enum Direction { North }
720+
println!( "{} => {}", North, North as int );
721721
~~~~
722722

723723
It is possible to set the discriminator values to chosen constant values:
@@ -748,23 +748,15 @@ includes an identifier of the actual form that it holds, much like the
748748

749749
This declaration defines a type `Shape` that can refer to such shapes, and two
750750
functions, `Circle` and `Rectangle`, which can be used to construct values of
751-
the type.
752-
753-
To create a new `Circle`, write:
754-
755-
~~~~
756-
# struct Point { x: f64, y: f64 }
757-
# enum Shape { Circle(Point, f64), Rectangle(Point, Point) }
758-
let circle = Circle(Point { x: 0.0, y: 0.0 }, 10.0);
759-
~~~~
751+
the type. To create a new Circle, write `Circle(Point { x: 0.0, y: 0.0 },
752+
10.0)`.
760753

761754
All of these variant constructors may be used as patterns. The only way to
762755
access the contents of an enum instance is the destructuring of a match. For
763756
example:
764757

765758
~~~~
766759
use std::f64;
767-
768760
# struct Point {x: f64, y: f64}
769761
# enum Shape { Circle(Point, f64), Rectangle(Point, Point) }
770762
fn area(sh: Shape) -> f64 {
@@ -773,9 +765,6 @@ fn area(sh: Shape) -> f64 {
773765
Rectangle(Point { x, y }, Point { x: x2, y: y2 }) => (x2 - x) * (y2 - y)
774766
}
775767
}
776-
777-
let rect = Rectangle(Point { x: 0.0, y: 0.0 }, Point { x: 2.0, y: 2.0 });
778-
println!("area: {}", area(rect));
779768
~~~~
780769

781770
Use a lone `_` to ignore an individual field. Ignore all fields of a variant
@@ -797,9 +786,8 @@ fn point_from_direction(dir: Direction) -> Point {
797786
Enum variants may also be structs. For example:
798787

799788
~~~~
800-
#![feature(struct_variant)]
789+
# #![feature(struct_variant)]
801790
use std::f64;
802-
803791
# struct Point { x: f64, y: f64 }
804792
# fn square(x: f64) -> f64 { x * x }
805793
enum Shape {
@@ -814,14 +802,7 @@ fn area(sh: Shape) -> f64 {
814802
}
815803
}
816804
}
817-
818-
fn main() {
819-
let rect = Rectangle {
820-
top_left: Point { x: 0.0, y: 0.0 },
821-
bottom_right: Point { x: 2.0, y: -2.0 }
822-
};
823-
println!("area: {}", area(rect));
824-
}
805+
# fn main() {}
825806
~~~~
826807

827808
> *Note:* This feature of the compiler is currently gated behind the
@@ -1005,10 +986,6 @@ that are `Send`, but non-`Send` types can still *contain* types with custom
1005986
destructors. Example of types which are not `Send` are [`Gc<T>`][gc] and
1006987
[`Rc<T>`][rc], the shared-ownership types.
1007988

1008-
> *Note:* See a [later chapter](#ownership-escape-hatches) for a discussion about
1009-
> [`Gc<T>`][gc] and [`Rc<T>`][rc], and the [chapter about traits](#traits) for
1010-
> a discussion about `Send`.
1011-
1012989
[gc]: http://doc.rust-lang.org/std/gc/struct.Gc.html
1013990
[rc]: http://doc.rust-lang.org/std/rc/struct.Rc.html
1014991

@@ -1668,13 +1645,6 @@ let string = "foobar";
16681645
let view: &str = string.slice(0, 3);
16691646
~~~
16701647

1671-
Square brackets denote indexing into a slice or fixed-size vector:
1672-
1673-
~~~~
1674-
let crayons: [&str, ..3] = ["BananaMania", "Beaver", "Bittersweet"];
1675-
println!("Crayon 2 is '{}'", crayons[2]);
1676-
~~~~
1677-
16781648
Mutable slices also exist, just as there are mutable references. However, there
16791649
are no mutable string slices. Strings are a multi-byte encoding (UTF-8) of
16801650
Unicode code points, so they cannot be freely mutated without the ability to
@@ -1689,6 +1659,20 @@ view[0] = 5;
16891659
let ys: &mut [int] = &mut [1i, 2i, 3i];
16901660
~~~
16911661

1662+
Square brackets denote indexing into a slice or fixed-size vector:
1663+
1664+
~~~~
1665+
# enum Crayon { Almond, AntiqueBrass, Apricot,
1666+
# Aquamarine, Asparagus, AtomicTangerine,
1667+
# BananaMania, Beaver, Bittersweet };
1668+
# fn draw_scene(c: Crayon) { }
1669+
let crayons: [Crayon, ..3] = [BananaMania, Beaver, Bittersweet];
1670+
match crayons[0] {
1671+
Bittersweet => draw_scene(crayons[0]),
1672+
_ => ()
1673+
}
1674+
~~~~
1675+
16921676
A slice or fixed-size vector can be destructured using pattern matching:
16931677

16941678
~~~~
@@ -1754,8 +1738,6 @@ via dynamic checks and can fail at runtime.
17541738
The `Rc` and `Gc` types are not sendable, so they cannot be used to share memory between tasks. Safe
17551739
immutable and mutable shared memory is provided by the `sync::arc` module.
17561740

1757-
> *Note:* See a [later chapter](#traits) for a discussion about `Send` and sendable types.
1758-
17591741
# Closures
17601742

17611743
Named functions, like those we've seen so far, may not refer to local
@@ -2627,7 +2609,7 @@ let nonsense = mycircle.radius() * mycircle.area();
26272609
26282610
## Deriving implementations for traits
26292611

2630-
A small number of traits in can have implementations
2612+
A small number of traits in `std` and `extra` can have implementations
26312613
that can be automatically derived. These instances are specified by
26322614
placing the `deriving` attribute on a data type declaration. For
26332615
example, the following will mean that `Circle` has an implementation
@@ -2636,7 +2618,6 @@ of type `ABC` can be randomly generated and converted to a string:
26362618

26372619
~~~
26382620
extern crate rand;
2639-
use std::rand::{task_rng, Rng};
26402621
26412622
#[deriving(PartialEq)]
26422623
struct Circle { radius: f64 }
@@ -2647,13 +2628,6 @@ enum ABC { A, B, C }
26472628
fn main() {
26482629
// Use the Show trait to print "A, B, C."
26492630
println!("{}, {}, {}", A, B, C);
2650-
2651-
let mut rng = task_rng();
2652-
2653-
// Use the Rand trait to generate a random variants.
2654-
for _ in range(0i, 10) {
2655-
println!("{}", rng.gen::<ABC>());
2656-
}
26572631
}
26582632
~~~
26592633

@@ -3162,8 +3136,8 @@ In Rust terminology, we need a way to refer to other crates.
31623136
For that, Rust offers you the `extern crate` declaration:
31633137

31643138
~~~
3165-
// `num` ships with Rust.
31663139
extern crate num;
3140+
// `num` ships with Rust (much like `extra`; more details further down).
31673141
31683142
fn main() {
31693143
// The rational number '1/2':

branches/try2/src/liballoc/rc.rs

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,6 @@ fn main() {
148148
149149
*/
150150

151-
#![stable]
152-
153151
use core::mem::transmute;
154152
use core::cell::Cell;
155153
use core::clone::Clone;
@@ -173,7 +171,6 @@ struct RcBox<T> {
173171

174172
/// Immutable reference counted pointer type
175173
#[unsafe_no_drop_flag]
176-
#[stable]
177174
pub struct Rc<T> {
178175
// FIXME #12808: strange names to try to avoid interfering with
179176
// field accesses of the contained type via Deref
@@ -182,7 +179,6 @@ pub struct Rc<T> {
182179
_noshare: marker::NoShare
183180
}
184181

185-
#[stable]
186182
impl<T> Rc<T> {
187183
/// Construct a new reference-counted box
188184
pub fn new(value: T) -> Rc<T> {
@@ -207,7 +203,6 @@ impl<T> Rc<T> {
207203

208204
impl<T> Rc<T> {
209205
/// Downgrade the reference-counted pointer to a weak reference
210-
#[experimental = "Weak pointers may not belong in this module."]
211206
pub fn downgrade(&self) -> Weak<T> {
212207
self.inc_weak();
213208
Weak {
@@ -243,7 +238,6 @@ impl<T: Clone> Rc<T> {
243238
}
244239
}
245240

246-
#[experimental = "Deref is experimental."]
247241
impl<T> Deref<T> for Rc<T> {
248242
/// Borrow the value contained in the reference-counted box
249243
#[inline(always)]
@@ -253,7 +247,6 @@ impl<T> Deref<T> for Rc<T> {
253247
}
254248

255249
#[unsafe_destructor]
256-
#[experimental = "Drop is experimental."]
257250
impl<T> Drop for Rc<T> {
258251
fn drop(&mut self) {
259252
unsafe {
@@ -276,7 +269,7 @@ impl<T> Drop for Rc<T> {
276269
}
277270
}
278271

279-
#[unstable = "Clone is unstable."]
272+
#[unstable]
280273
impl<T> Clone for Rc<T> {
281274
#[inline]
282275
fn clone(&self) -> Rc<T> {
@@ -285,26 +278,22 @@ impl<T> Clone for Rc<T> {
285278
}
286279
}
287280

288-
#[stable]
289281
impl<T: Default> Default for Rc<T> {
290282
#[inline]
291283
fn default() -> Rc<T> {
292284
Rc::new(Default::default())
293285
}
294286
}
295287

296-
#[unstable = "PartialEq is unstable."]
297288
impl<T: PartialEq> PartialEq for Rc<T> {
298289
#[inline(always)]
299290
fn eq(&self, other: &Rc<T>) -> bool { **self == **other }
300291
#[inline(always)]
301292
fn ne(&self, other: &Rc<T>) -> bool { **self != **other }
302293
}
303294

304-
#[unstable = "Eq is unstable."]
305295
impl<T: Eq> Eq for Rc<T> {}
306296

307-
#[unstable = "PartialOrd is unstable."]
308297
impl<T: PartialOrd> PartialOrd for Rc<T> {
309298
#[inline(always)]
310299
fn partial_cmp(&self, other: &Rc<T>) -> Option<Ordering> {
@@ -324,13 +313,11 @@ impl<T: PartialOrd> PartialOrd for Rc<T> {
324313
fn ge(&self, other: &Rc<T>) -> bool { **self >= **other }
325314
}
326315

327-
#[unstable = "Ord is unstable."]
328316
impl<T: Ord> Ord for Rc<T> {
329317
#[inline]
330318
fn cmp(&self, other: &Rc<T>) -> Ordering { (**self).cmp(&**other) }
331319
}
332320

333-
#[experimental = "Show is experimental."]
334321
impl<T: fmt::Show> fmt::Show for Rc<T> {
335322
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
336323
(**self).fmt(f)
@@ -339,7 +326,6 @@ impl<T: fmt::Show> fmt::Show for Rc<T> {
339326

340327
/// Weak reference to a reference-counted box
341328
#[unsafe_no_drop_flag]
342-
#[experimental = "Weak pointers may not belong in this module."]
343329
pub struct Weak<T> {
344330
// FIXME #12808: strange names to try to avoid interfering with
345331
// field accesses of the contained type via Deref
@@ -348,7 +334,6 @@ pub struct Weak<T> {
348334
_noshare: marker::NoShare
349335
}
350336

351-
#[experimental = "Weak pointers may not belong in this module."]
352337
impl<T> Weak<T> {
353338
/// Upgrade a weak reference to a strong reference
354339
pub fn upgrade(&self) -> Option<Rc<T>> {
@@ -362,7 +347,6 @@ impl<T> Weak<T> {
362347
}
363348

364349
#[unsafe_destructor]
365-
#[experimental = "Weak pointers may not belong in this module."]
366350
impl<T> Drop for Weak<T> {
367351
fn drop(&mut self) {
368352
unsafe {
@@ -380,7 +364,6 @@ impl<T> Drop for Weak<T> {
380364
}
381365

382366
#[unstable]
383-
#[experimental = "Weak pointers may not belong in this module."]
384367
impl<T> Clone for Weak<T> {
385368
#[inline]
386369
fn clone(&self) -> Weak<T> {

0 commit comments

Comments
 (0)