summary refs log tree commit diff
path: root/src/doc/tutorial.md
AgeCommit message (Collapse)AuthorLines
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.
2014-02-18Removing '15.3 Do syntax' in tutorial.Axel Viala-39/+18
The 'do' keyword was deprecated in 0.10 #11868 , and is keep as reserved keyword #12157 . So the tutorial part about it doesn't make sense. The spawning explanation was move into '15.2 Closure compatibility'. Fixing misspelling. Thanks for precisions. Moved from 15.2 to 15.1. Fixed typo, and apply pnkfelix advices.
2014-02-15auto merge of #12272 : alexcrichton/rust/snapshot, r=kballardbors-19/+19
This notably contains the `extern mod` => `extern crate` change. Closes #9880
2014-02-14Remove broken link to old conditions tutorialSteven Fackler-2/+0
2014-02-14extern mod => extern crateAlex Crichton-19/+19
This was previously implemented, and it just needed a snapshot to go through
2014-02-14tutorial: stronger wording in build instructionsCorey Richardson-2/+2
2014-02-12doc: rename 'nil' to 'unit' when describing `()`Matthijs van der Vleuten-3/+3
2014-02-11auto merge of #12171 : chromatic/rust/fix_crate_tutorial_typos, r=brsonbors-39/+34
This commit attempts to clarify a section of the tutorial. It also fixes some typos.
2014-02-11 Explain container iteration in the loop tutorialEduard Bopp-2/+16
As suggested by @pnkfelix in #12161, this extends the examples by a for-loop that iterates over a string as an example for container iteration.
2014-02-11Factoring bigint, rational, and complex out of libextra into libnum.Felix S. Klock II-7/+7
Removed use of globs present in earlier versions of modules. Fix tutorial.md to reflect `extra::rational` ==> `num::rational`.
2014-02-10Revised Crate section of tutorial for clarity.chromatic-39/+34
2014-02-10Document for-loop in tutorial section on loopsEduard Bopp-0/+12
2014-02-09Rearranged enum section of tutorial for clarity.chromatic-43/+40
This version starts with the simple case and builds on it.
2014-02-08Update docs and tests for #[deriving(Show)].Huon Wilson-1/+1
2014-02-07Removed @self and @Trait.Eduard Burtescu-17/+10
2014-02-06Redesign output flags for rustcAlex Crichton-2/+2
This commit removes the -c, --emit-llvm, -s, --rlib, --dylib, --staticlib, --lib, and --bin flags from rustc, adding the following flags: * --emit=[asm,ir,bc,obj,link] * --crate-type=[dylib,rlib,staticlib,bin,lib] The -o option has also been redefined to be used for *all* flavors of outputs. This means that we no longer ignore it for libraries. The --out-dir remains the same as before. The new logic for files that rustc emits is as follows: 1. Output types are dictated by the --emit flag. The default value is --emit=link, and this option can be passed multiple times and have all options stacked on one another. 2. Crate types are dictated by the --crate-type flag and the #[crate_type] attribute. The flags can be passed many times and stack with the crate attribute. 3. If the -o flag is specified, and only one output type is specified, the output will be emitted at this location. If more than one output type is specified, then the filename of -o is ignored, and all output goes in the directory that -o specifies. The -o option always ignores the --out-dir option. 4. If the --out-dir flag is specified, all output goes in this directory. 5. If -o and --out-dir are both not present, all output goes in the current directory of the process. 6. When multiple output types are specified, the filestem of all output is the same as the name of the CrateId (derived from a crate attribute or from the filestem of the crate file). Closes #7791 Closes #11056 Closes #11667
2014-02-04Improved pattern-match code and explanation.chromatic-2/+4
This cleans up a warning about an unused variable and explains the code further.
2014-02-03Remove unnecessary trailing commas.Ivan Enderlin-2/+2
2014-02-02Move doc/ to src/doc/Alex Crichton-0/+3275
We generate documentation into the doc/ directory, so we shouldn't be intermingling source files with generated files