about summary refs log tree commit diff
path: root/src/doc/tutorial.md
AgeCommit message (Collapse)AuthorLines
2014-04-14auto merge of #13477 : Manishearth/rust/newattr, r=brsonbors-7/+7
See #13476
2014-04-12Update tutorials to use new attribute syntax (#13476)Manish Goregaokar-7/+7
2014-04-10libstd: Implement `StrBuf`, a new string buffer type like `Vec`, andPatrick Walton-1/+3
port all code over to use it.
2014-04-04Removed all instance of `@` in code examples.Christopher Kendell-8/+7
2014-04-04Small change to example to make variable values more sensible.Christopher Kendell-2/+2
2014-04-04auto merge of #13298 : ckendell/rust/remove_managed_pointers_from_tutorial, ↵bors-21/+14
r=cmr Work on #13287 This is not ready for a merge yet, but I wanted to get some eyes on what I have done so far. As of right now, all references in the text to managed boxes or pointers are removed. Code associated with those specific sections of text have likewise been altered. I also removed all references to managed closures. There is a small change I would like to add to the work done in 3137cd5, on the new lines 1495 and 1496, I would like to change those values to 10 and 20. I did the same in a later change on lines 1596 and 1508. There are still bits of sample code that use managed pointers and the sigil @. Those are next on my list to remove, but I wanted to have the outstanding changes reviewed first. The uses of @ in the code samples are a bit more embedded, and I will need to be more careful changing them as to not change the purpose of the code examples. I ensured that make check still passes, although I'm not sure if that actually tests the code in tutorial.md. One issues I ran into, and tried to avoid, was that `tutorial.md` is formatted with a nice column limit. I was unsure how this was enforced, so wherever I edited a line, I did my best to keep edits on the line they previously existed on. As such, the plain text of `tutorial.md` looks a bit strange as I've left it, and I will clean that up as suggested. The rendered markdown output should not be affected.
2014-04-03auto merge of #13296 : brson/rust/0.11-pre, r=alexcrichtonbors-5/+5
This also changes some of the download links in the documentation to 'nightly'.
2014-04-03auto merge of #13290 : alexcrichton/rust/rollup, r=alexcrichtonbors-8/+5
Closes #13285 (rustc: Stop using LLVMGetSectionName) Closes #13280 (std: override clone_from for Vec.) Closes #13277 (serialize: add a few missing pubs to base64) Closes #13275 (Add and remove some ignore-win32 flags) Closes #13273 (Removed managed boxes from libarena.) Closes #13270 (Minor copy-editing for the tutorial) Closes #13267 (fix Option<~ZeroSizeType>) Closes #13265 (Update emacs mode to support new `#![inner(attribute)]` syntax.) Closes #13263 (syntax: Remove AbiSet, use one Abi)
2014-04-03Bump version to 0.11-preBrian Anderson-5/+5
This also changes some of the download links in the documentation to 'nightly'.
2014-04-03Removed all references to managed closures.Christopher Kendell-3/+3
2014-04-03Removed references to managed boxes/pointers from the tutorial text. CodeChristopher Kendell-19/+12
examples in relevant sections were similarly altered.
2014-04-03auto merge of #13286 : alexcrichton/rust/release, r=brsonbors-5/+5
Merging the 0.10 release into the master branch.
2014-04-03Minor spelling/grammar/usage fixes.Matt Brubeck-4/+4
Note: "different to" is not exactly incorrect, but "different from" is more commonly accepted in both US and Commonwealth English, and also more consistent with other usage within this tutorial.
2014-04-03Fix reference to "these two traits."Matt Brubeck-1/+1
There are actually three traits listed.
2014-04-03`extern crate` and `mod` are not easily confusedMatt Brubeck-3/+0
Remove some statements that used to refer to similarities between `mod` and `extern mod`, before the latter was renamed to `extern crate`.
2014-04-01auto merge of #13225 : thestinger/rust/num, r=cmrbors-5/+3
The `Float` trait methods will be usable as functions via UFCS, and we came to a consensus to remove duplicate functions like this a long time ago. It does still make sense to keep the duplicate functions when the trait methods are static, unless the decision to leave out the in-scope trait name resolution for static methods changes.
2014-03-31doc: Update with changes in field privacyAlex Crichton-4/+4
2014-03-31num: rm wrapping of `Float` methods as functionsDaniel Micay-5/+3
The `Float` trait methods will be usable as functions via UFCS, and we came to a consensus to remove duplicate functions like this a long time ago. It does still make sense to keep the duplicate functions when the trait methods are static, unless the decision to leave out the in-scope trait name resolution for static methods changes.
2014-03-31Bump version to 0.10Alex Crichton-5/+5
2014-03-30Removed deprecated functions `map` and `flat_map` for vectors and slices.Marvin Löbel-1/+4
2014-03-27doc: Update the tutorial about bounds for traitsAlex Crichton-15/+17
2014-03-23docs: named lifetimesnoam-1/+2
* Include tip given by Leo Testard in mailing list about labeled `break` and `continue`: https://mail.mozilla.org/pipermail/rust-dev/2014-March/009145.html * cross-reference named lifetimes in tutorial -> lifetimes guide * Broke named lifetimes section into two sub-sections. * Added mention of `'static` lifetime.
2014-03-22auto merge of #13076 : FlaPer87/rust/remove-freeze, r=alexcrichtonbors-9/+5
This PR removes the `Freeze` kind and the `NoFreeze` marker completely. Fixes #12577 cc @nikomatsakis r?
2014-03-22doc: Remove Freeze / NoFreeze from docsFlavio Percoco-9/+5
2014-03-21Copy-edit a sentence about borrowing referencesMatt Brubeck-1/+1
2014-03-20auto merge of #13023 : thestinger/rust/deep_clone, r=alexcrichtonbors-1/+1
2014-03-20Mention Share in the tutorialFlavio Percoco-0/+4
2014-03-20rm obsolete references to `DeepClone`Daniel Micay-1/+1
2014-03-15log: Introduce liblog, the old std::loggingAlex Crichton-3/+3
This commit moves all logging out of the standard library into an external crate. This crate is the new crate which is responsible for all logging macros and logging implementation. A few reasons for this change are: * The crate map has always been a bit of a code smell among rust programs. It has difficulty being loaded on almost all platforms, and it's used almost exclusively for logging and only logging. Removing the crate map is one of the end goals of this movement. * The compiler has a fair bit of special support for logging. It has the __log_level() expression as well as generating a global word per module specifying the log level. This is unfairly favoring the built-in logging system, and is much better done purely in libraries instead of the compiler itself. * Initialization of logging is much easier to do if there is no reliance on a magical crate map being available to set module log levels. * If the logging library can be written outside of the standard library, there's no reason that it shouldn't be. It's likely that we're not going to build the highest quality logging library of all time, so third-party libraries should be able to provide just as high-quality logging systems as the default one provided in the rust distribution. With a migration such as this, the change does not come for free. There are some subtle changes in the behavior of liblog vs the previous logging macros: * The core change of this migration is that there is no longer a physical log-level per module. This concept is still emulated (it is quite useful), but there is now only a global log level, not a local one. This global log level is a reflection of the maximum of all log levels specified. The previously generated logging code looked like: if specified_level <= __module_log_level() { println!(...) } The newly generated code looks like: if specified_level <= ::log::LOG_LEVEL { if ::log::module_enabled(module_path!()) { println!(...) } } Notably, the first layer of checking is still intended to be "super fast" in that it's just a load of a global word and a compare. The second layer of checking is executed to determine if the current module does indeed have logging turned on. This means that if any module has a debug log level turned on, all modules with debug log levels get a little bit slower (they all do more expensive dynamic checks to determine if they're turned on or not). Semantically, this migration brings no change in this respect, but runtime-wise, this will have a perf impact on some code. * A `RUST_LOG=::help` directive will no longer print out a list of all modules that can be logged. This is because the crate map will no longer specify the log levels of all modules, so the list of modules is not known. Additionally, warnings can no longer be provided if a malformed logging directive was supplied. The new "hello world" for logging looks like: #[phase(syntax, link)] extern crate log; fn main() { debug!("Hello, world!"); }
2014-03-14extra: Put the nail in the coffin, delete libextraAlex Crichton-11/+0
This commit shreds all remnants of libextra from the compiler and standard distribution. Two modules, c_vec/tempfile, were moved into libstd after some cleanup, and the other modules were moved to separate crates as seen fit. Closes #8784 Closes #12413 Closes #12576
2014-03-13Remove Rc's borrow method to avoid conflicts with RefCell's borrow in ↵Eduard Burtescu-1/+1
Rc<RefCell<T>>.
2014-03-12Update users for the std::rand -> librand move.Huon Wilson-1/+1
2014-03-11doc: remove outdated tutorial entry, restore removed Makefile entriesAdrien Tétar-6/+3
2014-03-09tutorial: hack a code snippet to make it compile.Huon Wilson-3/+4
This is meant to be compiling a crate, but the crate_id attribute seems to be upsetting it if the attribute is actually on the crate. I.e. this makes this test compile by putting the crate_id attribute on a function and so it's ignored. Such a hack. :(
2014-03-09docs: adjust code blocks to pass with rustdoc.Huon Wilson-20/+22
The changes are basically just because rustdoc runs tests/rendering on more snippets by default (i.e. everything without a `notrust` tag), and not anything significant.
2014-03-06Added missing possessive apostrophe.Mike Boutin-1/+1
2014-02-28std: Change assert_eq!() to use {} instead of {:?}Alex Crichton-2/+2
Formatting via reflection has been a little questionable for some time now, and it's a little unfortunate that one of the standard macros will silently use reflection when you weren't expecting it. This adds small bits of code bloat to libraries, as well as not always being necessary. In light of this information, this commit switches assert_eq!() to using {} in the error message instead of {:?}. In updating existing code, there were a few error cases that I encountered: * It's impossible to define Show for [T, ..N]. I think DST will alleviate this because we can define Show for [T]. * A few types here and there just needed a #[deriving(Show)] * Type parameters needed a Show bound, I often moved this to `assert!(a == b)` * `Path` doesn't implement `Show`, so assert_eq!() cannot be used on two paths. I don't think this is much of a regression though because {:?} on paths looks awful (it's a byte array). Concretely speaking, this shaved 10K off a 656K binary. Not a lot, but sometime significant for smaller binaries.
2014-02-27Minor modifications to Axel's tutorial improvements (see also #12472).Felix S. Klock II-4/+6
2014-02-27Documentation : Tutorial improvement...Axel Viala-5/+14
Refactoring examples on implementation of generics for linked list. Fixing typo of 'Note's for coherancy. Adding internal links inside the tutorial example with traits, generics etc...
2014-02-26tutorial: Missing tildes around .notrust blockJohannes Löthberg-2/+2
Adds a missing tilde to the end and the start of two .notrust blocks.
2014-02-25auto merge of #12547 : jagtalon/rust/jag/rust/tutorial-freezing, r=pnkfelixbors-4/+4
- "Lending an immutable pointer" might be confusing. It was not discussed why borrowed pointers are immutable in the first place. - Make it clear that the borrowed pointers are immutable even if the variable was declared with `mut`. - Make it clear that we cannot even assign anything to the variable while its value is being borrowed. tutorial: change "--" to an em-dash. tutorial: change instances of "--" to em-dash.
2014-02-25tutorial: clearer explanation of freezing.Jag Talon-4/+4
- "Lending an immutable pointer" might be confusing. It was not discussed why borrowed pointers are immutable in the first place. - Make it clear that the borrowed pointers are immutable even if the variable was declared with `mut`. - Make it clear that we cannot even assign anything to the variable while its value is being borrowed. tutorial: change "--" to an em-dash. tutorial: change instances of "--" to em-dash.
2014-02-24Tutorial: Add std::num::sqrt to the example.Jag Talon-1/+1
We should be using the package std::num::sqrt instead of the sqrt function that was defined to return 0.0
2014-02-23Remove all ToStr impls, add Show implsAlex Crichton-1/+1
This commit changes the ToStr trait to: impl<T: fmt::Show> ToStr for T { fn to_str(&self) -> ~str { format!("{}", *self) } } The ToStr trait has been on the chopping block for quite awhile now, and this is the final nail in its coffin. The trait and the corresponding method are not being removed as part of this commit, but rather any implementations of the `ToStr` trait are being forbidden because of the generic impl. The new way to get the `to_str()` method to work is to implement `fmt::Show`. Formatting into a `&mut Writer` (as `format!` does) is much more efficient than `ToStr` when building up large strings. The `ToStr` trait forces many intermediate allocations to be made while the `fmt::Show` trait allows incremental buildup in the same heap allocated buffer. Additionally, the `fmt::Show` trait is much more extensible in terms of interoperation with other `Writer` instances and in more situations. By design the `ToStr` trait requires at least one allocation whereas the `fmt::Show` trait does not require any allocations. Closes #8242 Closes #9806
2014-02-23Merge remote-tracking branch 'kud1ing/patch-1'Brian Anderson-1/+1
2014-02-23Tutorial: fix typokud1ing-1/+1
2014-02-24Transition to new `Hash`, removing IterBytes and std::to_bytes.Huon Wilson-1/+1
2014-02-23Move std::{trie, hashmap} to libcollectionsAlex Crichton-2/+3
These two containers are indeed collections, so their place is in libcollections, not in libstd. There will always be a hash map as part of the standard distribution of Rust, but by moving it out of the standard library it makes libstd that much more portable to more platforms and environments. This conveniently also removes the stuttering of 'std::hashmap::HashMap', although 'collections::HashMap' is only one character shorter.
2014-02-21insignificant fix to rust manual and tutorialLiigo Zhuang-13/+6
2014-02-20auto merge of #12161 : aepsil0n/rust/docs/for-loop, r=alexcrichtonbors-0/+26
I just started learning Rust and the absence of an explanation of the for-loop in the beginning really bugged me about the tutorial. Hence I simply added these lines, where I would have expected them. I know that there is something later on in the section on traits. However, this simple iteration scheme feels like something that you should be aware of right away.