Skip to content

Commit f07c6e4

Browse files
committed
---
yaml --- r: 153006 b: refs/heads/try2 c: c90950e h: refs/heads/master v: v3
1 parent 3921f1b commit f07c6e4

File tree

7 files changed

+46
-207
lines changed

7 files changed

+46
-207
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: 380657557cb3793d39dfc0d2321fc946cb3496f5
8+
refs/heads/try2: c90950ea60f09330f3c637201afddda475aa504d
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/doc/guide.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -421,16 +421,6 @@ return
421421

422422
comments
423423

424-
## Testing
425-
426-
attributes
427-
428-
stability markers
429-
430-
## Crates and Modules
431-
432-
visibility
433-
434424
## Compound Data Types
435425

436426
Tuples
@@ -451,10 +441,21 @@ loop
451441

452442
break/continue
453443

454-
iterators
444+
## iterators
455445

456446
## Lambdas
457447

448+
## Testing
449+
450+
attributes
451+
452+
stability markers
453+
454+
## Crates and Modules
455+
456+
visibility
457+
458+
458459
## Generics
459460

460461
## Traits

branches/try2/src/doc/intro.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ fn main() {
252252
}
253253
```
254254

255-
The compiler will produce an error indicating that the value is no longer in scope:
255+
This will result an error indicating that the value is no longer in scope:
256256

257257
```text
258258
concurrency.rs:12:20: 12:27 error: use of moved value: 'numbers'

branches/try2/src/etc/licenseck.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
"libsync/mpsc_intrusive.rs", # BSD
4545
"test/bench/shootout-binarytrees.rs", # BSD
4646
"test/bench/shootout-fannkuch-redux.rs", # BSD
47-
"test/bench/shootout-mandelbrot.rs", # BSD
4847
"test/bench/shootout-meteor.rs", # BSD
4948
"test/bench/shootout-pidigits.rs", # BSD
5049
"test/bench/shootout-regex-dna.rs", # BSD

branches/try2/src/etc/vim/syntax/rust.vim

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -77,39 +77,34 @@ syn keyword rustEnumVariant Ok Err
7777
"syn keyword rustFunction drop
7878

7979
" Types and traits {{{3
80-
syn keyword rustTrait Ascii AsciiCast OwnedAsciiCast AsciiStr
81-
syn keyword rustTrait IntoBytes
80+
syn keyword rustTrait Ascii AsciiCast OwnedAsciiCast AsciiStr IntoBytes
8281
syn keyword rustTrait ToCStr
8382
syn keyword rustTrait Char
8483
syn keyword rustTrait Clone
85-
syn keyword rustTrait PartialEq PartialOrd Eq Ord Equiv
86-
syn keyword rustEnum Ordering
84+
syn keyword rustTrait Eq Ord PartialEq PartialOrd Ordering Equiv
8785
syn keyword rustEnumVariant Less Equal Greater
88-
syn keyword rustTrait Collection Mutable Map MutableMap
89-
syn keyword rustTrait Set MutableSet
90-
syn keyword rustTrait FromIterator Extendable ExactSize
91-
syn keyword rustTrait Iterator DoubleEndedIterator
92-
syn keyword rustTrait RandomAccessIterator CloneableIterator
93-
syn keyword rustTrait OrdIterator MutableDoubleEndedIterator
94-
syn keyword rustTrait Num NumCast CheckedAdd CheckedSub CheckedMul CheckedDiv
95-
syn keyword rustTrait Signed Unsigned Primitive Int Float
96-
syn keyword rustTrait FloatMath ToPrimitive FromPrimitive
86+
syn keyword rustTrait Container Mutable Map MutableMap Set MutableSet
87+
syn keyword rustTrait FromIterator Extendable
88+
syn keyword rustTrait Iterator DoubleEndedIterator RandomAccessIterator CloneableIterator
89+
syn keyword rustTrait OrdIterator MutableDoubleEndedIterator ExactSize
90+
syn keyword rustTrait Num NumCast CheckedAdd CheckedSub CheckedMul
91+
syn keyword rustTrait Signed Unsigned
92+
syn keyword rustTrait Primitive Int Float FloatMath ToPrimitive FromPrimitive
93+
"syn keyword rustTrait Expect
9794
syn keyword rustTrait Box
9895
syn keyword rustTrait GenericPath Path PosixPath WindowsPath
9996
syn keyword rustTrait RawPtr
10097
syn keyword rustTrait Buffer Writer Reader Seek
101-
syn keyword rustTrait Str StrVector StrSlice OwnedStr
102-
syn keyword rustTrait IntoMaybeOwned StrAllocating
98+
syn keyword rustTrait Str StrVector StrSlice OwnedStr IntoMaybeOwned
99+
syn keyword rustTrait StrAllocating
103100
syn keyword rustTrait ToStr IntoStr
104101
syn keyword rustTrait Tuple1 Tuple2 Tuple3 Tuple4
105102
syn keyword rustTrait Tuple5 Tuple6 Tuple7 Tuple8
106103
syn keyword rustTrait Tuple9 Tuple10 Tuple11 Tuple12
107-
syn keyword rustTrait CloneableVector ImmutableCloneableVector
108-
syn keyword rustTrait MutableCloneableVector MutableOrdVector
104+
syn keyword rustTrait CloneableVector ImmutableCloneableVector MutableCloneableVector
109105
syn keyword rustTrait ImmutableVector MutableVector
110-
syn keyword rustTrait ImmutableEqVector ImmutableOrdVector
111-
syn keyword rustTrait Vector VectorVector
112-
syn keyword rustTrait MutableVectorAllocating
106+
syn keyword rustTrait ImmutableEqVector ImmutableOrdVector MutableOrdVector
107+
syn keyword rustTrait Vector VectorVector OwnedVector MutableVectorAllocating
113108
syn keyword rustTrait String
114109
syn keyword rustTrait Vec
115110

branches/try2/src/liballoc/rc.rs

Lines changed: 9 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -10,141 +10,16 @@
1010

1111
/*! Task-local reference-counted boxes (`Rc` type)
1212
13-
The `Rc` type provides shared ownership of an immutable value. Destruction is
14-
deterministic, and will occur as soon as the last owner is gone. It is marked
15-
as non-sendable because it avoids the overhead of atomic reference counting.
13+
The `Rc` type provides shared ownership of an immutable value. Destruction is deterministic, and
14+
will occur as soon as the last owner is gone. It is marked as non-sendable because it avoids the
15+
overhead of atomic reference counting.
1616
17-
The `downgrade` method can be used to create a non-owning `Weak` pointer to the
18-
box. A `Weak` pointer can be upgraded to an `Rc` pointer, but will return
19-
`None` if the value has already been freed.
17+
The `downgrade` method can be used to create a non-owning `Weak` pointer to the box. A `Weak`
18+
pointer can be upgraded to an `Rc` pointer, but will return `None` if the value has already been
19+
freed.
2020
21-
For example, a tree with parent pointers can be represented by putting the
22-
nodes behind strong `Rc` pointers, and then storing the parent pointers as
23-
`Weak` pointers.
24-
25-
26-
## Examples
27-
28-
Consider a scenario where a set of Gadgets are owned by a given Owner. We want
29-
to have our Gadgets point to their Owner. We can't do this with unique
30-
ownership, because more than one gadget may belong to the same Owner. Rc
31-
allows us to share an Owner between multiple Gadgets, and have the Owner kept
32-
alive as long as any Gadget points at it.
33-
34-
```rust
35-
use std::rc::Rc;
36-
37-
struct Owner {
38-
name: String
39-
// ...other fields
40-
}
41-
42-
struct Gadget {
43-
id: int,
44-
owner: Rc<Owner>
45-
// ...other fields
46-
}
47-
48-
fn main() {
49-
// Create a reference counted Owner.
50-
let gadget_owner : Rc<Owner> = Rc::new(
51-
Owner { name: String::from_str("Gadget Man") }
52-
);
53-
54-
// Create Gadgets belonging to gadget_owner. To increment the reference
55-
// count we clone the Rc object.
56-
let gadget1 = Gadget { id: 1, owner: gadget_owner.clone() };
57-
let gadget2 = Gadget { id: 2, owner: gadget_owner.clone() };
58-
59-
drop(gadget_owner);
60-
61-
// Despite dropping gadget_owner, we're still able to print out the name of
62-
// the Owner of the Gadgets. This is because we've only dropped the
63-
// reference count object, not the Owner it wraps. As long as there are
64-
// other Rc objects pointing at the same Owner, it will stay alive. Notice
65-
// that the Rc wrapper around Gadget.owner gets automatically dereferenced
66-
// for us.
67-
println!("Gadget {} owned by {}", gadget1.id, gadget1.owner.name);
68-
println!("Gadget {} owned by {}", gadget2.id, gadget2.owner.name);
69-
70-
// At the end of the method, gadget1 and gadget2 get destroyed, and with
71-
// them the last counted references to our Owner. Gadget Man now gets
72-
// destroyed as well.
73-
}
74-
```
75-
76-
If our requirements change, and we also need to be able to traverse from
77-
Owner->Gadget, we will run into problems: an Rc pointer from Owner->Gadget
78-
introduces a cycle between the objects. This means that their reference counts
79-
can never reach 0, and the objects will stay alive: a memory leak. In order to
80-
get around this, we can use `Weak` pointers. These are reference counted
81-
pointers that don't keep an object alive if there are no normal `Rc` (or
82-
*strong*) pointers left.
83-
84-
Rust actually makes it somewhat difficult to produce this loop in the first
85-
place: in order to end up with two objects that point at each other, one of
86-
them needs to be mutable. This is problematic because Rc enforces memory
87-
safety by only giving out shared references to the object it wraps, and these
88-
don't allow direct mutation. We need to wrap the part of the object we wish to
89-
mutate in a `RefCell`, which provides *interior mutability*: a method to
90-
achieve mutability through a shared reference. `RefCell` enforces Rust's
91-
borrowing rules at runtime. Read the `Cell` documentation for more details on
92-
interior mutability.
93-
94-
```rust
95-
use std::rc::Rc;
96-
use std::rc::Weak;
97-
use std::cell::RefCell;
98-
99-
struct Owner {
100-
name: String,
101-
gadgets: RefCell<Vec<Weak<Gadget>>>
102-
// ...other fields
103-
}
104-
105-
struct Gadget {
106-
id: int,
107-
owner: Rc<Owner>
108-
// ...other fields
109-
}
110-
111-
fn main() {
112-
// Create a reference counted Owner. Note the fact that we've put the
113-
// Owner's vector of Gadgets inside a RefCell so that we can mutate it
114-
// through a shared reference.
115-
let gadget_owner : Rc<Owner> = Rc::new(
116-
Owner {
117-
name: "Gadget Man".to_string(),
118-
gadgets: RefCell::new(Vec::new())
119-
}
120-
);
121-
122-
// Create Gadgets belonging to gadget_owner as before.
123-
let gadget1 = Rc::new(Gadget{id: 1, owner: gadget_owner.clone()});
124-
let gadget2 = Rc::new(Gadget{id: 2, owner: gadget_owner.clone()});
125-
126-
// Add the Gadgets to their Owner. To do this we mutably borrow from
127-
// the RefCell holding the Owner's Gadgets.
128-
gadget_owner.gadgets.borrow_mut().push(gadget1.clone().downgrade());
129-
gadget_owner.gadgets.borrow_mut().push(gadget2.clone().downgrade());
130-
131-
// Iterate over our Gadgets, printing their details out
132-
for gadget_opt in gadget_owner.gadgets.borrow().iter() {
133-
134-
// gadget_opt is a Weak<Gadget>. Since weak pointers can't guarantee
135-
// that their object is still alive, we need to call upgrade() on them
136-
// to turn them into a strong reference. This returns an Option, which
137-
// contains a reference to our object if it still exists.
138-
let gadget = gadget_opt.upgrade().unwrap();
139-
println!("Gadget {} owned by {}", gadget.id, gadget.owner.name);
140-
}
141-
142-
// At the end of the method, gadget_owner, gadget1 and gadget2 get
143-
// destroyed. There are now no strong (Rc) references to the gadgets.
144-
// Once they get destroyed, the Gadgets get destroyed. This zeroes the
145-
// reference count on Gadget Man, so he gets destroyed as well.
146-
}
147-
```
21+
For example, a tree with parent pointers can be represented by putting the nodes behind `Strong`
22+
pointers, and then storing the parent pointers as `Weak` pointers.
14823
14924
*/
15025

branches/try2/src/test/bench/shootout-mandelbrot.rs

Lines changed: 8 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,12 @@
1-
// The Computer Language Benchmarks Game
2-
// http://benchmarksgame.alioth.debian.org/
1+
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
34
//
4-
// contributed by the Rust Project Developers
5-
6-
// Copyright (c) 2012-2014 The Rust Project Developers
7-
//
8-
// All rights reserved.
9-
//
10-
// Redistribution and use in source and binary forms, with or without
11-
// modification, are permitted provided that the following conditions
12-
// are met:
13-
//
14-
// - Redistributions of source code must retain the above copyright
15-
// notice, this list of conditions and the following disclaimer.
16-
//
17-
// - Redistributions in binary form must reproduce the above copyright
18-
// notice, this list of conditions and the following disclaimer in
19-
// the documentation and/or other materials provided with the
20-
// distribution.
21-
//
22-
// - Neither the name of "The Computer Language Benchmarks Game" nor
23-
// the name of "The Computer Language Shootout Benchmarks" nor the
24-
// names of its contributors may be used to endorse or promote
25-
// products derived from this software without specific prior
26-
// written permission.
27-
//
28-
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29-
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30-
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
31-
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
32-
// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
33-
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
34-
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
35-
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36-
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
37-
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
38-
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
39-
// OF THE POSSIBILITY OF SUCH DAMAGE.
40-
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
4110
#![feature(macro_rules)]
4211
#![feature(simd)]
4312
#![allow(experimental)]

0 commit comments

Comments
 (0)