Skip to content

Commit 834432b

Browse files
committed
---
yaml --- r: 81075 b: refs/heads/snap-stage3 c: 5e6a8ea h: refs/heads/master i: 81073: d83441b 81071: 905e9c5 v: v3
1 parent 92114c6 commit 834432b

File tree

199 files changed

+3382
-3695
lines changed

Some content is hidden

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

199 files changed

+3382
-3695
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 4c6bf4872012c010f84dc7fa2cdfe87522533f89
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 10a583ce1ac28a8cbf34b0f4274285f33bdfce29
4+
refs/heads/snap-stage3: 5e6a8eabc5dcd5ab2f91e62f6c67b1a1e938d444
55
refs/heads/try: 70152ff55722878cde684ee6462c14c65f2c4729
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/RELEASES.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ Version 0.8 (October 2013)
3131
* `ref` bindings in irrefutable patterns work correctly now.
3232
* `char` is now prevented from containing invalid code points.
3333
* Casting to `bool` is no longer allowed.
34-
* `\0` is now accepted as an escape in chars and strings.
3534
* `yield` is a reserved keyword.
3635
* `typeof` is a reserved keyword.
3736
* Crates may be imported by URL with `extern mod foo = "url";`.
@@ -112,9 +111,6 @@ Version 0.8 (October 2013)
112111
the `MutableSet` and `MutableMap` traits. `Container::is_empty`,
113112
`Map::contains_key`, `MutableMap::insert`, and `MutableMap::remove` have
114113
default implementations.
115-
* std: Various `from_str` functions were removed in favor of a generic
116-
`from_str` which is available in the prelude.
117-
* std: `util::unreachable` removed in favor of the `unreachable!` macro.
118114
* extra: `dlist`, the doubly-linked list was modernized.
119115
* extra: Added a `hex` module with `ToHex` and `FromHex` traits.
120116
* extra: Added `glob` module, replacing `std::os::glob`.
@@ -129,9 +125,6 @@ Version 0.8 (October 2013)
129125
* extra: `semver` updated to SemVer 2.0.0.
130126
* extra: `term` handles more terminals correctly.
131127
* extra: `dbg` module removed.
132-
* extra: `par` module removed.
133-
* extra: `future` was cleaned up, with some method renames.
134-
* extra: Most free functions in `getopts` were converted to methods.
135128

136129
* Other
137130
* rustc's debug info generation (`-Z debug-info`) is greatly improved.
@@ -212,7 +205,6 @@ Version 0.7 (July 2013)
212205
* std: Many old internal vector and string iterators,
213206
incl. `any`, `all`. removed.
214207
* std: The `finalize` method of `Drop` renamed to `drop`.
215-
* std: The `drop` method now takes `&mut self` instead of `&self`.
216208
* std: The prelude no longer reexports any modules, only types and traits.
217209
* std: Prelude additions: `print`, `println`, `FromStr`, `ApproxEq`, `Equiv`,
218210
`Iterator`, `IteratorUtil`, many numeric traits, many tuple traits.

branches/snap-stage3/doc/tutorial-rustpkg.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ package up your Rust code and share it with other people. This tutorial will
77
get you started on all of the concepts and commands you need to give the gift
88
of Rust code to someone else.
99

10-
# Installing External Packages
10+
## Installing External Packages
1111

1212
First, let's try to use an external package somehow. I've made a sample package
1313
called `hello` to demonstrate how to do so. Here's how `hello` is used:
@@ -68,7 +68,7 @@ Hello, world.
6868

6969
Simple! That's all it takes.
7070

71-
# Workspaces
71+
## Workspaces
7272

7373
Before we can talk about how to make packages of your own, you have to
7474
understand the big concept with `rustpkg`: workspaces. A 'workspace' is simply
@@ -88,14 +88,14 @@ There are also default file names you'll want to follow as well:
8888
* `main.rs`: A file that's going to become an executable.
8989
* `lib.rs`: A file that's going to become a library.
9090

91-
# Building your own Package
91+
## Building your own Package
9292

9393
Now that you've got workspaces down, let's build your own copy of `hello`. Go
9494
to wherever you keep your personal projects, and let's make all of the
9595
directories we'll need. I'll refer to this personal project directory as
9696
`~/src` for the rest of this tutorial.
9797

98-
## Creating our workspace
98+
### Creating our workspace
9999

100100
~~~ {.notrust}
101101
$ cd ~/src
@@ -150,15 +150,15 @@ pub fn world() {
150150

151151
Put this into `src/hello/lib.rs`. Let's talk about each of these attributes:
152152

153-
## Crate attributes for packages
153+
### Crate attributes for packages
154154

155155
`license` is equally simple: the license we want this code to have. I chose MIT
156156
here, but you should pick whatever license makes the most sense for you.
157157

158158
`desc` is a description of the package and what it does. This should just be a
159159
sentence or two.
160160

161-
## Building your package
161+
### Building your package
162162

163163
Building your package is simple:
164164

@@ -206,7 +206,7 @@ note: Installed package github.com/YOUR_USERNAME/hello-0.1 to /home/yourusername
206206

207207
That's it!
208208

209-
# More resources
209+
## More resources
210210

211211
There's a lot more going on with `rustpkg`, this is just to get you started.
212212
Check out [the rustpkg manual](rustpkg.html) for the full details on how to

branches/snap-stage3/doc/tutorial-tasks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ do_some_work();
423423
While it isn't possible for a task to recover from failure, tasks may notify
424424
each other of failure. The simplest way of handling task failure is with the
425425
`try` function, which is similar to `spawn`, but immediately blocks waiting
426-
for the child task to finish. `try` returns a value of type `Result<T,
426+
for the child task to finish. `try` returns a value of type `Result<int,
427427
()>`. `Result` is an `enum` type with two variants: `Ok` and `Err`. In this
428428
case, because the type arguments to `Result` are `int` and `()`, callers can
429429
pattern-match on a result to check whether it's an `Ok` result with an `int`

branches/snap-stage3/doc/tutorial.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1469,6 +1469,34 @@ cannot be stored in data structures or returned from
14691469
functions. Despite these limitations, stack closures are used
14701470
pervasively in Rust code.
14711471

1472+
## Managed closures
1473+
1474+
When you need to store a closure in a data structure, a stack closure
1475+
will not do, since the compiler will refuse to let you store it. For
1476+
this purpose, Rust provides a type of closure that has an arbitrary
1477+
lifetime, written `@fn` (boxed closure, analogous to the `@` pointer
1478+
type described earlier). This type of closure *is* first-class.
1479+
1480+
A managed closure does not directly access its environment, but merely
1481+
copies out the values that it closes over into a private data
1482+
structure. This means that it can not assign to these variables, and
1483+
cannot observe updates to them.
1484+
1485+
This code creates a closure that adds a given string to its argument,
1486+
returns it from a function, and then calls it:
1487+
1488+
~~~~
1489+
fn mk_appender(suffix: ~str) -> @fn(~str) -> ~str {
1490+
// The compiler knows that we intend this closure to be of type @fn
1491+
return |s| s + suffix;
1492+
}
1493+
1494+
fn main() {
1495+
let shout = mk_appender(~"!");
1496+
println(shout(~"hey ho, let's go"));
1497+
}
1498+
~~~~
1499+
14721500
## Owned closures
14731501

14741502
Owned closures, written `~fn` in analogy to the `~` pointer type,
@@ -2995,7 +3023,7 @@ There is further documentation on the [wiki], however those tend to be even more
29953023
[tasks]: tutorial-tasks.html
29963024
[macros]: tutorial-macros.html
29973025
[ffi]: tutorial-ffi.html
2998-
[rustpkg]: tutorial-rustpkg.html
3026+
[rustpkg]: rustpkg.html
29993027

30003028
[wiki]: https://github.com/mozilla/rust/wiki/Docs
30013029

branches/snap-stage3/mk/docs.mk

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -160,16 +160,6 @@ doc/tutorial-conditions.html: tutorial-conditions.md doc/version_info.html doc/r
160160
--include-before-body=doc/version_info.html \
161161
--output=$@
162162

163-
DOCS += doc/tutorial-rustpkg.html
164-
doc/tutorial-rustpkg.html: tutorial-rustpkg.md doc/version_info.html doc/rust.css
165-
@$(call E, pandoc: $@)
166-
$(Q)$(CFG_NODE) $(S)doc/prep.js --highlight $< | \
167-
$(CFG_PANDOC) --standalone --toc \
168-
--section-divs --number-sections \
169-
--from=markdown --to=html --css=rust.css \
170-
--include-before-body=doc/version_info.html \
171-
--output=$@
172-
173163
ifeq ($(CFG_PDFLATEX),)
174164
$(info cfg: no pdflatex found, omitting doc/rust.pdf)
175165
else

branches/snap-stage3/src/libextra/arc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ struct MutexArcInner<T> { priv lock: Mutex, priv failed: bool, priv data: T }
162162

163163
/// An Arc with mutable data protected by a blocking mutex.
164164
#[no_freeze]
165-
pub struct MutexArc<T> { priv x: UnsafeArc<MutexArcInner<T>> }
165+
struct MutexArc<T> { priv x: UnsafeArc<MutexArcInner<T>> }
166166

167167

168168
impl<T:Send> Clone for MutexArc<T> {
@@ -343,7 +343,7 @@ struct RWArcInner<T> { priv lock: RWLock, priv failed: bool, priv data: T }
343343
* Unlike mutex_arcs, rw_arcs are safe, because they cannot be nested.
344344
*/
345345
#[no_freeze]
346-
pub struct RWArc<T> {
346+
struct RWArc<T> {
347347
priv x: UnsafeArc<RWArcInner<T>>,
348348
}
349349

branches/snap-stage3/src/libextra/c_vec.rs

Lines changed: 22 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -36,39 +36,37 @@
3636
* still held if needed.
3737
*/
3838

39+
40+
use std::option;
3941
use std::ptr;
40-
use std::routine::Runnable;
41-
use std::util;
4242

4343
/**
4444
* The type representing a foreign chunk of memory
45+
*
4546
*/
4647
pub struct CVec<T> {
4748
priv base: *mut T,
4849
priv len: uint,
49-
priv rsrc: @DtorRes,
50+
priv rsrc: @DtorRes
5051
}
5152

5253
struct DtorRes {
53-
dtor: Option<~Runnable>,
54+
dtor: Option<@fn()>,
5455
}
5556

5657
#[unsafe_destructor]
5758
impl Drop for DtorRes {
5859
fn drop(&mut self) {
59-
let dtor = util::replace(&mut self.dtor, None);
60-
match dtor {
61-
None => (),
62-
Some(f) => f.run()
60+
match self.dtor {
61+
option::None => (),
62+
option::Some(f) => f()
6363
}
6464
}
6565
}
6666

67-
impl DtorRes {
68-
fn new(dtor: Option<~Runnable>) -> DtorRes {
69-
DtorRes {
70-
dtor: dtor,
71-
}
67+
fn DtorRes(dtor: Option<@fn()>) -> DtorRes {
68+
DtorRes {
69+
dtor: dtor
7270
}
7371
}
7472

@@ -85,10 +83,10 @@ impl DtorRes {
8583
* * len - The number of elements in the buffer
8684
*/
8785
pub unsafe fn CVec<T>(base: *mut T, len: uint) -> CVec<T> {
88-
return CVec {
86+
return CVec{
8987
base: base,
9088
len: len,
91-
rsrc: @DtorRes::new(None)
89+
rsrc: @DtorRes(option::None)
9290
};
9391
}
9492

@@ -103,12 +101,12 @@ pub unsafe fn CVec<T>(base: *mut T, len: uint) -> CVec<T> {
103101
* * dtor - A function to run when the value is destructed, useful
104102
* for freeing the buffer, etc.
105103
*/
106-
pub unsafe fn c_vec_with_dtor<T>(base: *mut T, len: uint, dtor: ~Runnable)
107-
-> CVec<T> {
104+
pub unsafe fn c_vec_with_dtor<T>(base: *mut T, len: uint, dtor: @fn())
105+
-> CVec<T> {
108106
return CVec{
109107
base: base,
110108
len: len,
111-
rsrc: @DtorRes::new(Some(dtor))
109+
rsrc: @DtorRes(option::Some(dtor))
112110
};
113111
}
114112

@@ -155,20 +153,6 @@ mod tests {
155153

156154
use std::libc::*;
157155
use std::libc;
158-
use std::routine::Runnable;
159-
160-
struct LibcFree {
161-
mem: *c_void,
162-
}
163-
164-
impl Runnable for LibcFree {
165-
#[fixed_stack_segment]
166-
fn run(~self) {
167-
unsafe {
168-
libc::free(self.mem)
169-
}
170-
}
171-
}
172156

173157
fn malloc(n: size_t) -> CVec<u8> {
174158
#[fixed_stack_segment];
@@ -179,11 +163,12 @@ mod tests {
179163

180164
assert!(mem as int != 0);
181165

182-
return c_vec_with_dtor(mem as *mut u8,
183-
n as uint,
184-
~LibcFree {
185-
mem: mem,
186-
} as ~Runnable);
166+
return c_vec_with_dtor(mem as *mut u8, n as uint, || f(mem));
167+
}
168+
169+
fn f(mem: *c_void) {
170+
#[fixed_stack_segment]; #[inline(never)];
171+
unsafe { libc::free(mem) }
187172
}
188173
}
189174

0 commit comments

Comments
 (0)