Skip to content

Commit 67d6e9d

Browse files
committed
---
yaml --- r: 212798 b: refs/heads/tmp c: 95407cc h: refs/heads/master v: v3
1 parent cf7dbe0 commit 67d6e9d

Some content is hidden

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

47 files changed

+458
-136
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
3232
refs/heads/beta: 4efc4ec178f6ddf3c8cd268b011f3a04056f9d16
3333
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928
3434
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
35-
refs/heads/tmp: 7d298d1acecbd866be7b9e2c60ef86032bb2a502
35+
refs/heads/tmp: 95407cc627bfd2c0cda7c41a1d8dba301b215bca
3636
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3737
refs/tags/homu-tmp: bea1c4a78e5233ea6f85a2028a26e08c26635fca
3838
refs/heads/gate: 97c84447b65164731087ea82685580cc81424412

branches/tmp/src/doc/complement-lang-faq.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,13 @@ You may also be interested in browsing [trending Rust repositories][github-rust]
3030

3131
## Is anyone using Rust in production?
3232

33-
Currently, Rust is still pre-1.0, and so we don't recommend that you use Rust
34-
in production unless you know exactly what you're getting into.
35-
36-
That said, there are two production deployments of Rust that we're aware of:
33+
Yes. For example (incomplete):
3734

3835
* [OpenDNS](http://labs.opendns.com/2013/10/04/zeromq-helping-us-block-malicious-domains/)
3936
* [Skylight](http://skylight.io)
40-
41-
Let the fact that this is an easily countable number be a warning.
37+
* [wit.ai](https://github.com/wit-ai/witd)
38+
* [Codius](https://codius.org/blog/codius-rust/)
39+
* [MaidSafe](http://maidsafe.net/)
4240

4341
## Does it run on Windows?
4442

branches/tmp/src/doc/trpl/enums.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,45 @@ equality yet, but we’ll find out in the [`traits`][traits] section.
6464
[match]: match.html
6565
[if-let]: if-let.html
6666
[traits]: traits.html
67+
68+
# Constructors as functions
69+
70+
An enum’s constructors can also be used like functions. For example:
71+
72+
```rust
73+
# enum Message {
74+
# Write(String),
75+
# }
76+
let m = Message::Write("Hello, world".to_string());
77+
```
78+
79+
Is the same as
80+
81+
```rust
82+
# enum Message {
83+
# Write(String),
84+
# }
85+
fn foo(x: String) -> Message {
86+
Message::Write(x)
87+
}
88+
89+
let x = foo("Hello, world".to_string());
90+
```
91+
92+
This is not immediately useful to us, but when we get to
93+
[`closures`][closures], we’ll talk about passing functions as arguments to
94+
other functions. For example, with [`iterators`][iterators], we can do this
95+
to convert a vector of `String`s into a vector of `Message::Write`s:
96+
97+
```rust
98+
# enum Message {
99+
# Write(String),
100+
# }
101+
102+
let v = vec!["Hello".to_string(), "World".to_string()];
103+
104+
let v1: Vec<Message> = v.into_iter().map(Message::Write).collect();
105+
```
106+
107+
[closures]: closures.html
108+
[iterators]: iterators.html

branches/tmp/src/doc/trpl/ffi.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ However it is often desired that the callback is targeted to a special
238238
Rust object. This could be the object that represents the wrapper for the
239239
respective C object.
240240
241-
This can be achieved by passing an unsafe pointer to the object down to the
241+
This can be achieved by passing an raw pointer to the object down to the
242242
C library. The C library can then include the pointer to the Rust object in
243243
the notification. This will allow the callback to unsafely access the
244244
referenced Rust object.
@@ -370,7 +370,7 @@ On OSX, frameworks behave with the same semantics as a dynamic library.
370370
371371
# Unsafe blocks
372372
373-
Some operations, like dereferencing unsafe pointers or calling functions that have been marked
373+
Some operations, like dereferencing raw pointers or calling functions that have been marked
374374
unsafe are only allowed inside unsafe blocks. Unsafe blocks isolate unsafety and are a promise to
375375
the compiler that the unsafety does not leak out of the block.
376376

branches/tmp/src/doc/trpl/functions.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,9 @@ an expression, and a `let` can only begin a statement, not an expression.
144144
Note that assigning to an already-bound variable (e.g. `y = 5`) is still an
145145
expression, although its value is not particularly useful. Unlike other
146146
languages where an assignment evaluates to the assigned value (e.g. `5` in the
147-
previous example), in Rust the value of an assignment is an empty tuple `()`:
147+
previous example), in Rust the value of an assignment is an empty tuple `()`
148+
because the assigned value can have [just one owner](ownership.html), and any
149+
other returned value would be too surprising:
148150

149151
```rust
150152
let mut y = 5;

branches/tmp/src/doc/trpl/raw-pointers.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ println!("raw points at {}", *raw);
5252
It gives this error:
5353

5454
```text
55-
error: dereference of unsafe pointer requires unsafe function or block [E0133]
56-
println!("raw points at{}", *raw);
57-
^~~~
55+
error: dereference of raw pointer requires unsafe function or block [E0133]
56+
println!("raw points at {}", *raw);
57+
^~~~
5858
```
5959

6060
When you dereference a raw pointer, you’re taking responsibility that it’s not

branches/tmp/src/doc/trpl/strings.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,30 @@ let dog = hachiko.chars().nth(1); // kinda like hachiko[1]
117117

118118
This emphasizes that we have to go through the whole list of `chars`.
119119

120+
## Slicing
121+
122+
You can get a slice of a string with slicing syntax:
123+
124+
```rust
125+
let dog = "hachiko";
126+
let hachi = &dog[0..5];
127+
```
128+
129+
But note that these are _byte_ offsets, not _character_ offsets. So
130+
this will fail at runtime:
131+
132+
```rust,should_panic
133+
let dog = "忠犬ハチ公";
134+
let hachi = &dog[0..2];
135+
```
136+
137+
with this error:
138+
139+
```text
140+
thread '<main>' panicked at 'index 0 and/or 2 in `忠犬ハチ公` do not lie on
141+
character boundary'
142+
```
143+
120144
## Concatenation
121145

122146
If you have a `String`, you can concatenate a `&str` to the end of it:

branches/tmp/src/liballoc/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
//!
2323
//! ## Boxed values
2424
//!
25-
//! The [`Box`](boxed/index.html) type is the core owned pointer type in Rust.
26-
//! There can only be one owner of a `Box`, and the owner can decide to mutate
27-
//! the contents, which live on the heap.
25+
//! The [`Box`](boxed/index.html) type is a smart pointer type. There can
26+
//! only be one owner of a `Box`, and the owner can decide to mutate the
27+
//! contents, which live on the heap.
2828
//!
2929
//! This type can be sent among threads efficiently as the size of a `Box` value
3030
//! is the same as that of a pointer. Tree-like data structures are often built

branches/tmp/src/libcollections/borrow.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use core::ops::Deref;
2121
use core::option::Option;
2222

2323
use fmt;
24-
use alloc::{rc, arc};
24+
use alloc::{boxed, rc, arc};
2525

2626
use self::Cow::*;
2727

@@ -116,6 +116,14 @@ impl<'a, T: ?Sized> BorrowMut<T> for &'a mut T {
116116
fn borrow_mut(&mut self) -> &mut T { &mut **self }
117117
}
118118

119+
impl<T: ?Sized> Borrow<T> for boxed::Box<T> {
120+
fn borrow(&self) -> &T { &**self }
121+
}
122+
123+
impl<T: ?Sized> BorrowMut<T> for boxed::Box<T> {
124+
fn borrow_mut(&mut self) -> &mut T { &mut **self }
125+
}
126+
119127
impl<T: ?Sized> Borrow<T> for rc::Rc<T> {
120128
fn borrow(&self) -> &T { &**self }
121129
}

branches/tmp/src/libcollections/slice.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ impl<T> [T] {
370370
core_slice::SliceExt::get_unchecked_mut(self, index)
371371
}
372372

373-
/// Returns an unsafe pointer to the slice's buffer
373+
/// Returns an raw pointer to the slice's buffer
374374
///
375375
/// The caller must ensure that the slice outlives the pointer this
376376
/// function returns, or else it will end up pointing to garbage.

0 commit comments

Comments
 (0)