Commit Graph

53 Commits

Author SHA1 Message Date
Tobias Bucher
b4a43f3864 Kill more isizes 2015-01-31 17:40:40 +01:00
Aaron Turon
537889aa78 Fix type inference problems in tests and docs 2015-01-21 11:16:00 -08:00
Aaron Turon
a506d4cbfe Fallout from stabilization. 2015-01-21 08:11:07 -08:00
Andrew Barchuk
5f1ba93ad2 Replace obsolete constructions in into examples
Replace deprecated integer suffixes. Remove integer type notations
altogether where possible. Replace uses of deprecated `range()`
function with range notation.
2015-01-17 10:49:49 -05:00
Andrew Barchuk
f77208972a Remove Thread::detach() call from intro example
The mentioned method are no longer part of Thread. Spawned threads are
detached by default as of now.
2015-01-17 10:49:49 -05:00
Andrew Barchuk
9ed27df180 Fix intro concurrency examples compilation warns
* Use range notation instead of deprecated `range()`

* Remove deprecated `u` integer suffixes used in ranges

* Replace deprecated `i` integer suffixes with `is` for vector numbers

`Thread::spawn()` still gives "use of unstable item" warning which I
hadn't found a way to fix.
2015-01-17 10:49:49 -05:00
Alex Crichton
46a490f42b rollup merge of #21075: iKevinY/intro-changes
- Make punctuation/formatting consistent with the changes made to *The Rust Programming Language* in #20782.
- Use title casing for "Safety and Speed" section.
- Reword some phrases to improve clarity.
2015-01-15 14:11:41 -08:00
Kevin Yap
31ac1fb93d Various changes to Rust Introduction
- Make punctuation/formatting consistent with the changes made to "The
  Rust Programming Language" in #20782.
- Use title casing for "Safety and Speed" section.
- Reword some phrases to improve clarity.
2015-01-12 19:25:17 -08:00
Steve Klabnik
e485d297ea Improve example in the intro.
Thank you @bluss for the suggested implementation.

Fixes #20844
2015-01-12 15:14:17 -05:00
Duncan Regan
c871773f32 Updates fixed-size suffix
Compiler gives the following warning:
`warning: the `u` suffix on integers is deprecated; use `us` or one of the fixed-sized suffixes`
And also the errror:
`error: mismatched types: expected `u64`, found `usize` (expected u64, found usize)`

Changing the suffix to `u64` results in a successful `cargo run` outputting the desired `Versions compared successfully!`
2015-01-10 16:19:11 -05:00
Steve Klabnik
16a6ebd1f6 "The Rust Programming Language"
This pulls all of our long-form documentation into a single document,
nicknamed "the book" and formally titled "The Rust Programming
Language."

A few things motivated this change:

* People knew of The Guide, but not the individual Guides. This merges
  them together, helping discoverability.
* You can get all of Rust's longform documentation in one place, which
  is nice.
* We now have rustbook in-tree, which can generate this kind of
  documentation. While its style is basic, the general idea is much
  better: a table of contents on the left-hand side.
* Rather than a almost 10,000-line guide.md, there are now smaller files
  per section.
2015-01-08 12:02:11 -05:00
Alex Crichton
5b1a285b73 rollup merge of #20693: EchoAce/intro-oboe
Issue #20686, proposed by nstoddard.
2015-01-07 17:17:27 -08:00
FakeKane
da83e4d98a oboe removed 2015-01-07 09:09:37 -05:00
Aaron Turon
caca9b2e71 Fallout from stabilization 2015-01-06 14:57:52 -08:00
Alex Crichton
76e5ed655c std: Return Result from RWLock/Mutex methods
All of the current std::sync primitives have poisoning enable which means that
when a task fails inside of a write-access lock then all future attempts to
acquire the lock will fail. This strategy ensures that stale data whose
invariants are possibly not upheld are never viewed by other tasks to help
propagate unexpected panics (bugs in a program) among tasks.

Currently there is no way to test whether a mutex or rwlock is poisoned. One
method would be to duplicate all the methods with a sister foo_catch function,
for example. This pattern is, however, against our [error guidelines][errors].
As a result, this commit exposes the fact that a task has failed internally
through the return value of a `Result`.

[errors]: https://github.com/rust-lang/rfcs/blob/master/text/0236-error-conventions.md#do-not-provide-both-result-and-fail-variants

All methods now return a `LockResult<T>` or a `TryLockResult<T>` which
communicates whether the lock was poisoned or not. In a `LockResult`, both the
`Ok` and `Err` variants contains the `MutexGuard<T>` that is being returned in
order to allow access to the data if poisoning is not desired. This also means
that the lock is *always* held upon returning from `.lock()`.

A new type, `PoisonError`, was added with one method `into_guard` which can
consume the assertion that a lock is poisoned to gain access to the underlying
data.

This is a breaking change because the signatures of these methods have changed,
often incompatible ways. One major difference is that the `wait` methods on a
condition variable now consume the guard and return it in as a `LockResult` to
indicate whether the lock was poisoned while waiting. Most code can be updated
by calling `.unwrap()` on the return value of `.lock()`.

[breaking-change]
2014-12-29 09:18:09 -08:00
Aaron Turon
a27fbac868 Revise std::thread API to join by default
This commit is part of a series that introduces a `std::thread` API to
replace `std::task`.

In the new API, `spawn` returns a `JoinGuard`, which by default will
join the spawned thread when dropped. It can also be used to join
explicitly at any time, returning the thread's result. Alternatively,
the spawned thread can be explicitly detached (so no join takes place).

As part of this change, Rust processes now terminate when the main
thread exits, even if other detached threads are still running, moving
Rust closer to standard threading models. This new behavior may break code
that was relying on the previously implicit join-all.

In addition to the above, the new thread API also offers some built-in
support for building blocking abstractions in user space; see the module
doc for details.

Closes #18000

[breaking-change]
2014-12-18 23:31:52 -08:00
Brian Anderson
36f7f1e301 rollup merge of #19735: sethpollack/patch-1 2014-12-15 06:45:33 -08:00
Brian Anderson
42f4d636fa rollup merge of #19714: steveklabnik/gh16219
These should be properly annotated instead.

Fixes #16219.
2014-12-15 06:44:21 -08:00
Niko Matsakis
112faabf94 Update guide/intro to take into account the removal of proc.
cc @steveklabnick
2014-12-14 04:21:57 -05:00
Seth Pollack
7676d0164f Update intro.md 2014-12-11 11:21:48 -05:00
Steve Klabnik
3c9d8983be Fix up some {ignore} and {notrust}s
These should be properly annotated instead.

Fixes #16219.
2014-12-10 15:14:18 -05:00
Alex Crichton
1a61fe4280 Test fixes and rebase conflicts from the rollup 2014-12-09 10:26:04 -08:00
Alex Crichton
fb587f1f9b rollup merge of #19614: steveklabnik/gh19599
Fixes #19599
2014-12-09 09:25:04 -08:00
Steve Klabnik
8ba5605233 remove usage of notrust from the docs
Fixes #19599
2014-12-07 04:18:56 -05:00
jbranchaud
2171c95553 Add missing semicolon to hello world program in intro. 2014-12-06 17:36:32 -06:00
Carol Nichols
fc47dd9c0f Prepend should be append in the 30 minute intro
The examples are about adding to the end of the array, not the
beginning.
2014-11-07 14:59:42 -05:00
Rolf van de Krol
66b8cc8692 small fix to output of code sample in intro.md 2014-10-31 20:28:58 +01:00
Steve Klabnik
4a74af62c6 Improve code in the intro.
All these stars aren't needed anymore.
2014-10-23 09:36:34 -04:00
Neil Pankey
66939dfe64 [Docs] more intro typos 2014-10-18 17:40:57 -07:00
Neil Pankey
e1389530cf [Docs] intro typo 2014-10-18 17:37:54 -07:00
Steve Klabnik
6c5bf9f2a4 Re-do the 30 minute intro
This was originally on my blog, so it's incredibly informal. Let's make
it better.
2014-10-03 11:22:44 -04:00
Alfie John
9d95729af4 doc: Removing repeated variable name to make it less ambiguious 2014-09-22 20:48:10 +00:00
Steve Klabnik
a99ba25f2b Replace the Tutorial with the Guide.
The Guide isn't 100% perfect, but it's basically complete. It's
certainly better than the tutorial is. Time to start pointing more
people its way.

I also just made it consistent to call all things 'guides' rather than
tutorials.

Fixes #9874. This is the big one.

And two bugs that just go away.

Fixes #14503.
Fixes #15009.
2014-09-11 16:21:32 -04:00
Tim Joseph Dumol
a9979ada47 doc: Fix the 30-minute intro to use += operator.
The 30-minute intro had a comment mentioning that `+=` will be included in the future. It's already included, and this fixes it to use `+=`.
2014-08-05 02:02:41 +08:00
Hugo Jobling
26ca10d2d7 Update disclaimer to improve clarity and intent 2014-07-29 15:43:02 -07:00
Cole Mickens
6bb22a9d6d Remove unnecessary cast from intro 2014-07-22 23:10:18 -07:00
Nick Cameron
aa760a849e deprecate Vec::get 2014-07-17 12:08:31 +12:00
Brian Anderson
d89577b5a2 doc: Clarify that an error is a compiler error
This was asked on HN, and it's easy to clarify.
2014-07-01 10:46:31 -07:00
Patrick Walton
a5bb0a3a45 librustc: Remove the fallback to int for integers and f64 for
floating point numbers for real.

This will break code that looks like:

    let mut x = 0;
    while ... {
        x += 1;
    }
    println!("{}", x);

Change that code to:

    let mut x = 0i;
    while ... {
        x += 1;
    }
    println!("{}", x);

Closes #15201.

[breaking-change]
2014-06-29 11:47:58 -07:00
Niko Matsakis
9e3d0b002a librustc: Remove the fallback to int from typechecking.
This breaks a fair amount of code. The typical patterns are:

* `for _ in range(0, 10)`: change to `for _ in range(0u, 10)`;

* `println!("{}", 3)`: change to `println!("{}", 3i)`;

* `[1, 2, 3].len()`: change to `[1i, 2, 3].len()`.

RFC #30. Closes #6023.

[breaking-change]
2014-06-24 17:18:48 -07:00
Brian Anderson
f4ae8a83f9 Update repo location 2014-06-16 18:16:36 -07:00
Alex Crichton
b1c9ce9c6f sync: Move underneath libstd
This commit is the final step in the libstd facade, #13851. The purpose of this
commit is to move libsync underneath the standard library, behind the facade.
This will allow core primitives like channels, queues, and atomics to all live
in the same location.

There were a few notable changes and a few breaking changes as part of this
movement:

* The `Vec` and `String` types are reexported at the top level of libcollections
* The `unreachable!()` macro was copied to libcore
* The `std::rt::thread` module was moved to librustrt, but it is still
  reexported at the same location.
* The `std::comm` module was moved to libsync
* The `sync::comm` module was moved under `sync::comm`, and renamed to `duplex`.
  It is now a private module with types/functions being reexported under
  `sync::comm`. This is a breaking change for any existing users of duplex
  streams.
* All concurrent queues/deques were moved directly under libsync. They are also
  all marked with #![experimental] for now if they are public.
* The `task_pool` and `future` modules no longer live in libsync, but rather
  live under `std::sync`. They will forever live at this location, but they may
  move to libsync if the `std::task` module moves as well.

[breaking-change]
2014-06-11 10:00:43 -07:00
bors
7fa5baa7ca auto merge of #14622 : reillywatson/rust/master, r=alexcrichton 2014-06-03 10:01:40 -07:00
Reilly Watson
5b80172f10 Doc: grammar fix in intro.md 2014-06-03 10:24:54 -04:00
Florian Gilcher
20fb7c62d4 docs: Stop using notrust
Now that rustdoc understands proper language tags
as the code not being Rust, we can tag everything
properly.

This change tags examples in other languages by
their language. Plain notations are marked as `text`.
Console examples are marked as `console`.

Also fix markdown.rs to not highlight non-rust code.
2014-06-02 12:37:54 +02:00
Jonathan Reem
c3825cbb9d Remove deprecated owned vector from intro. 2014-05-30 21:30:20 -07:00
Patrick Walton
090040bf40 librustc: Remove ~EXPR, ~TYPE, and ~PAT from the language, except
for `~str`/`~[]`.

Note that `~self` still remains, since I forgot to add support for
`Box<self>` before the snapshot.

How to update your code:

* Instead of `~EXPR`, you should write `box EXPR`.

* Instead of `~TYPE`, you should write `Box<Type>`.

* Instead of `~PATTERN`, you should write `box PATTERN`.

[breaking-change]
2014-05-06 23:12:54 -07:00
Richo Healey
6201d6d0d9 docs: change compositionality to composability 2014-05-04 14:17:47 -07:00
Michael Fairley
3124057101 Fix variable name in prose to match code it's describing 2014-04-25 10:15:47 -05:00
Joseph Crail
ae555e3830 Fix spelling mistakes in documentation and code. 2014-04-20 01:35:14 -04:00