Skip to content

Commit 4dcdad2

Browse files
committed
---
yaml --- r: 153022 b: refs/heads/try2 c: 58133ae h: refs/heads/master v: v3
1 parent a1f0493 commit 4dcdad2

File tree

109 files changed

+1943
-3011
lines changed

Some content is hidden

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

109 files changed

+1943
-3011
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: cb220a86ba18e91a8d373ac757596707275b86d3
8+
refs/heads/try2: 58133ae360ff759d444f7743ec7ac55c9eb7b10b
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ documentation.
5454
When complete, `make install` will place several programs into
5555
`/usr/local/bin`: `rustc`, the Rust compiler, and `rustdoc`, the
5656
API-documentation tool.
57+
system.
5758
3. Read the [tutorial].
5859
4. Enjoy!
5960

branches/try2/mk/dist.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ PKG_FILES := \
5454
driver \
5555
etc \
5656
$(foreach crate,$(CRATES),lib$(crate)) \
57-
libcoretest \
5857
libbacktrace \
5958
rt \
6059
rustllvm \

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,8 @@ the string in response. The child terminates when it receives `0`.
457457
Here is the function that implements the child task:
458458

459459
~~~
460+
#![allow(deprecated)]
461+
460462
use std::comm::DuplexStream;
461463
# fn main() {
462464
fn stringifier(channel: &DuplexStream<String, uint>) {
@@ -481,6 +483,8 @@ response itself is simply the stringified version of the received value,
481483
Here is the code for the parent task:
482484

483485
~~~
486+
#![allow(deprecated)]
487+
484488
use std::comm::duplex;
485489
# use std::task::spawn;
486490
# use std::comm::DuplexStream;

branches/try2/src/doc/guide.md

Lines changed: 12 additions & 223 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ Save the file, and then type this into your terminal window:
160160

161161
```{bash}
162162
$ rustc hello_world.rs
163-
$ ./hello_world # or hello_world.exe on Windows
163+
$ ./hello_world # just 'hello_world' on Windows
164164
Hello, world
165165
```
166166

@@ -243,7 +243,7 @@ There are now two files: our source code, with the `.rs` extension, and the
243243
executable (`hello_world.exe` on Windows, `hello_world` everywhere else)
244244

245245
```{bash}
246-
$ ./hello_world # or hello_world.exe on Windows
246+
$ ./hello_world # or ./hello_world.exe on Windows
247247
```
248248

249249
This prints out our `Hello, world!` text to our terminal.
@@ -413,209 +413,23 @@ rest of your Rust career.
413413
Next, we'll learn more about Rust itself, by starting to write a more complicated
414414
program. We hope you want to do more with Rust than just print "Hello, world!"
415415

416-
## Guessing Game
417-
418-
Let's write a bigger program in Rust. We could just go through a laundry list
419-
of Rust features, but that's boring. Instead, we'll learn more about how to
420-
code in Rust by writing a few example projects.
421-
422-
For our first project, we'll implement a classic beginner programming problem:
423-
the guessing game. Here's how it works: Our program will generate a random
424-
integer between one and a hundred. It will then prompt us to enter a guess.
425-
Upon entering our guess, it will tell us if we're too low or too high. Once we
426-
guess correctly, it will congratulate us, and print the number of guesses we've
427-
taken to the screen. Sound good? It sounds easy, but it'll end up showing off a
428-
number of basic features of Rust.
429-
430-
### Set up
431-
432-
Let's set up a new project. Go to your projects directory, and make a new
433-
directory for the project, as well as a `src` directory for our code:
434-
435-
```{bash}
436-
$ cd ~/projects
437-
$ mkdir guessing_game
438-
$ cd guessing_game
439-
$ mkdir src
440-
```
441-
442-
Great. Next, let's make a `Cargo.toml` file so Cargo knows how to build our
443-
project:
444-
445-
```{ignore}
446-
[package]
447-
448-
name = "guessing_game"
449-
version = "0.1.0"
450-
authors = [ "[email protected]" ]
451-
452-
[[bin]]
453-
454-
name = "guessing_game"
455-
```
456-
457-
Finally, we need our source file. Let's just make it hello world for now, so we
458-
can check that our setup works. In `src/guessing_game.rs`:
459-
460-
```{rust}
461-
fn main() {
462-
println!("Hello world!");
463-
}
464-
```
465-
466-
Let's make sure that worked:
467-
468-
```{bash}
469-
$ cargo build
470-
Compiling guessing_game v0.1.0 (file:/home/you/projects/guessing_game)
471-
$
472-
```
473-
474-
Excellent! Open up your `src/guessing_game.rs` again. We'll be writing all of
475-
our code in this file. The next section of the tutorial will show you how to
476-
build multiple-file projects.
477-
478-
## Variable bindings
479-
480-
The first thing we'll learn about are 'variable bindings.' They look like this:
481-
482-
```{rust}
483-
let x = 5i;
484-
```
485-
486-
In many languages, this is called a 'variable.' But Rust's variable bindings
487-
have a few tricks up their sleeves. Rust has a very powerful feature called
488-
'pattern matching' that we'll get into detail with later, but the left
489-
hand side of a `let` expression is a full pattern, not just a variable name.
490-
This means we can do things like:
491-
492-
```{rust}
493-
let (x, y) = (1i, 2i);
494-
```
495-
496-
After this expression is evaluated, `x` will be one, and `y` will be two.
497-
Patterns are really powerful, but this is about all we can do with them so far.
498-
So let's just keep this in the back of our minds as we go forward.
499-
500-
By the way, in these examples, `i` indicates that the number is an integer.
501-
502-
Rust is a statically typed language, which means that we specify our types up
503-
front. So why does our first example compile? Well, Rust has this thing called
504-
"[Hindley-Milner type
505-
inference](http://en.wikipedia.org/wiki/Hindley%E2%80%93Milner_type_system)",
506-
named after some really smart type theorists. If you clicked that link, don't
507-
be scared: what this means for you is that Rust will attempt to infer the types
508-
in your program, and it's pretty good at it. If it can infer the type, Rust
509-
doesn't require you to actually type it out.
510-
511-
We can add the type if we want to. Types come after a colon (`:`):
512-
513-
```{rust}
514-
let x: int = 5;
515-
```
516-
517-
If I asked you to read this out loud to the rest of the class, you'd say "`x`
518-
is a binding with the type `int` and the value `five`." Rust requires you to
519-
initialize the binding with a value before you're allowed to use it. If
520-
we try...
521-
522-
```{ignore}
523-
let x;
524-
```
525-
526-
...we'll get an error:
527-
528-
```{ignore}
529-
src/guessing_game.rs:2:9: 2:10 error: cannot determine a type for this local variable: unconstrained type
530-
src/guessing_game.rs:2 let x;
531-
^
532-
```
533-
534-
Giving it a type will compile, though:
535-
536-
```{ignore}
537-
let x: int;
538-
```
539-
540-
Let's try it out. Change your `src/guessing_game.rs` file to look like this:
541-
542-
```{rust}
543-
fn main() {
544-
let x: int;
545-
546-
println!("Hello world!");
547-
}
548-
```
549-
550-
You can use `cargo build` on the command line to build it. You'll get a warning,
551-
but it will still print "Hello, world!":
552-
553-
```{ignore,notrust}
554-
Compiling guessing_game v0.1.0 (file:/home/you/projects/guessing_game)
555-
src/guessing_game.rs:2:9: 2:10 warning: unused variable: `x`, #[warn(unused_variable)] on by default
556-
src/guessing_game.rs:2 let x: int;
557-
^
558-
```
559-
560-
Rust warns us that we never use the variable binding, but since we never use it,
561-
no harm, no foul. Things change if we try to actually use this `x`, however. Let's
562-
do that. Change your program to look like this:
563-
564-
```{rust,ignore}
565-
fn main() {
566-
let x: int;
416+
## If
567417

568-
println!("The value of x is: {}", x);
569-
}
570-
```
418+
## Functions
571419

572-
And try to build it. You'll get an error:
420+
return
573421

574-
```{bash}
575-
$ cargo build
576-
Compiling guessing_game v0.1.0 (file:/home/you/projects/guessing_game)
577-
src/guessing_game.rs:4:39: 4:40 error: use of possibly uninitialized variable: `x`
578-
src/guessing_game.rs:4 println!("The value of x is: {}", x);
579-
^
580-
note: in expansion of format_args!
581-
<std macros>:2:23: 2:77 note: expansion site
582-
<std macros>:1:1: 3:2 note: in expansion of println!
583-
src/guessing_game.rs:4:5: 4:42 note: expansion site
584-
error: aborting due to previous error
585-
Could not execute process `rustc src/guessing_game.rs --crate-type bin --out-dir /home/you/projects/guessing_game/target -L /home/you/projects/guessing_game/target -L /home/you/projects/guessing_game/target/deps` (status=101)
586-
```
422+
comments
587423

588-
Rust will not let us use a value that has not been initialized. So why let us
589-
declare a binding without initializing it? You'd think our first example would
590-
have errored. Well, Rust is smarter than that. Before we get to that, let's talk
591-
about this stuff we've added to `println!`.
592-
593-
If you include two curly braces (`{}`, some call them moustaches...) in your
594-
string to print, Rust will interpret this as a request to interpolate some sort
595-
of value. **String interpolation** is a computer science term that means "stick
596-
in the middle of a string." We add a comma, and then `x`, to indicate that we
597-
want `x` to be the value we're interpolating. The comma is used to separate
598-
arguments we pass to functions and macros, if you're passing more than one.
599-
600-
When you just use the double curly braces, Rust will attempt to display the
601-
value in a meaningful way by checking out its type. If you want to specify the
602-
format in a more detailed manner, there are a [wide number of options
603-
available](/std/fmt/index.html). Fow now, we'll just stick to the default:
604-
integers aren't very complicated to print.
605-
606-
So, we've cleared up all of the confusion around bindings, with one exception:
607-
why does Rust let us declare a variable binding without an initial value if we
608-
must initialize the binding before we use it? And how does it know that we have
609-
or have not initialized the binding? For that, we need to learn our next
610-
concept: `if`.
424+
## Testing
611425

612-
## If
426+
attributes
613427

614-
## Functions
428+
stability markers
615429

616-
return
430+
## Crates and Modules
617431

618-
comments
432+
visibility
619433

620434
## Compound Data Types
621435

@@ -637,35 +451,10 @@ loop
637451

638452
break/continue
639453

640-
## Guessing Game: complete
641-
642-
At this point, you have successfully built the Guessing Game! Congratulations!
643-
For reference, [We've placed the sample code on
644-
GitHub](https://github.com/steveklabnik/guessing_game).
645-
646-
You've now learned the basic syntax of Rust. All of this is relatively close to
647-
various other programming languages you have used in the past. These
648-
fundamental syntactical and semantic elements will form the foundation for the
649-
rest of your Rust education.
650-
651-
Now that you're an expert at the basics, it's time to learn about some of
652-
Rust's more unique features.
653-
654-
## iterators
454+
iterators
655455

656456
## Lambdas
657457

658-
## Testing
659-
660-
attributes
661-
662-
stability markers
663-
664-
## Crates and Modules
665-
666-
visibility
667-
668-
669458
## Generics
670459

671460
## 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

0 commit comments

Comments
 (0)