Skip to content

Commit d7428db

Browse files
committed
---
yaml --- r: 130930 b: refs/heads/auto c: 1bce869 h: refs/heads/master v: v3
1 parent e796999 commit d7428db

File tree

5 files changed

+14
-94
lines changed

5 files changed

+14
-94
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: 6ceb9b4157a076977b0d782632960bb90a0d39d9
16+
refs/heads/auto: 1bce8698cdeb274f33ecbfbcbb014367eb1ddfd0
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

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

Lines changed: 3 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -92,33 +92,9 @@ fn foo(s: String) {
9292
```
9393

9494
If you have good reason. It's not polite to hold on to ownership you don't
95-
need, and it can make your lifetimes more complex.
96-
97-
## Generic functions
98-
99-
To write a function that's generic over types of strings, use [the `Str`
100-
trait](http://doc.rust-lang.org/std/str/trait.Str.html):
101-
102-
```{rust}
103-
fn some_string_length<T: Str>(x: T) -> uint {
104-
x.as_slice().len()
105-
}
106-
107-
fn main() {
108-
let s = "Hello, world";
109-
110-
println!("{}", some_string_length(s));
111-
112-
let s = "Hello, world".to_string();
113-
114-
println!("{}", some_string_length(s));
115-
}
116-
```
117-
118-
Both of these lines will print `12`.
119-
120-
The only method that the `Str` trait has is `as_slice()`, which gives you
121-
access to a `&str` value from the underlying string.
95+
need, and it can make your lifetimes more complex. Furthermore, you can pass
96+
either kind of string into `foo` by using `.as_slice()` on any `String` you
97+
need to pass in, so the `&str` version is more flexible.
12298

12399
## Comparisons
124100

@@ -145,65 +121,6 @@ fn compare(string: String) {
145121
Converting a `String` to a `&str` is cheap, but converting the `&str` to a
146122
`String` involves an allocation.
147123

148-
## Indexing strings
149-
150-
You may be tempted to try to access a certain character of a `String`, like
151-
this:
152-
153-
```{rust,ignore}
154-
let s = "hello".to_string();
155-
156-
println!("{}", s[0]);
157-
```
158-
159-
This does not compile. This is on purpose. In the world of UTF-8, direct
160-
indexing is basically never what you want to do. The reason is that each
161-
character can be a variable number of bytes. This means that you have to iterate
162-
through the characters anyway, which is a O(n) operation.
163-
164-
To iterate over a string, use the `graphemes()` method on `&str`:
165-
166-
```{rust}
167-
let s = "αἰθήρ";
168-
169-
for l in s.graphemes(true) {
170-
println!("{}", l);
171-
}
172-
```
173-
174-
Note that `l` has the type `&str` here, since a single grapheme can consist of
175-
multiple codepoints, so a `char` wouldn't be appropriate.
176-
177-
This will print out each character in turn, as you'd expect: first "α", then
178-
"ἰ", etc. You can see that this is different than just the individual bytes.
179-
Here's a version that prints out each byte:
180-
181-
```{rust}
182-
let s = "αἰθήρ";
183-
184-
for l in s.bytes() {
185-
println!("{}", l);
186-
}
187-
```
188-
189-
This will print:
190-
191-
```{notrust,ignore}
192-
206
193-
177
194-
225
195-
188
196-
176
197-
206
198-
184
199-
206
200-
174
201-
207
202-
129
203-
```
204-
205-
Many more bytes than graphemes!
206-
207124
# Other Documentation
208125

209126
* [the `&str` API documentation](/std/str/index.html)

branches/auto/src/librustc/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ extern crate flate;
4242
extern crate getopts;
4343
extern crate graphviz;
4444
extern crate libc;
45-
extern crate "rustc_llvm" as llvm;
46-
extern crate "rustc_back" as rustc_back;
45+
extern crate rustc_llvm;
46+
extern crate rustc_back;
4747
extern crate serialize;
4848
extern crate rbml;
4949
extern crate time;
@@ -53,6 +53,8 @@ extern crate time;
5353
#[cfg(test)]
5454
extern crate test;
5555

56+
pub use rustc_llvm as llvm;
57+
5658
mod diagnostics;
5759

5860
pub mod back {

branches/auto/src/libsyntax/parse/obsolete.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ pub enum ObsoleteSyntax {
3636
ObsoleteManagedExpr,
3737
ObsoleteImportRenaming,
3838
ObsoleteSubsliceMatch,
39+
ObsoleteExternCrateRenaming,
3940
}
4041

4142
pub trait ParserObsoleteMethods {
@@ -92,6 +93,10 @@ impl<'a> ParserObsoleteMethods for parser::Parser<'a> {
9293
ObsoleteSubsliceMatch => (
9394
"subslice match syntax",
9495
"instead of `..xs`, write `xs..` in a pattern"
96+
),
97+
ObsoleteExternCrateRenaming => (
98+
"`extern crate foo = bar` syntax",
99+
"write `extern crate bar as foo` instead"
95100
)
96101
};
97102

branches/auto/src/libsyntax/parse/parser.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4783,11 +4783,7 @@ impl<'a> Parser<'a> {
47834783
self.bump();
47844784
let path = self.parse_str();
47854785
let span = self.span;
4786-
self.span_warn(span,
4787-
format!("this extern crate syntax is deprecated. \
4788-
Use: extern crate \"{}\" as {};",
4789-
path.ref0().get(), the_ident.as_str() ).as_slice()
4790-
);
4786+
self.obsolete(span, ObsoleteExternCrateRenaming);
47914787
Some(path)
47924788
} else {None};
47934789

0 commit comments

Comments
 (0)