about summary refs log tree commit diff
path: root/src/doc/tutorial.md
AgeCommit message (Collapse)AuthorLines
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