about summary refs log tree commit diff
path: root/src/libstd/rand
AgeCommit message (Collapse)AuthorLines
2014-10-06Fixed iOS build (statics name lint)Valerii Hiora-0/+1
2014-10-03rollup merge of #17387 : sneves/masterAlex Crichton-1/+1
2014-09-30Fix libstdSteven Fackler-1/+1
2014-09-30Include ChaCha pseudorandom generatorSamuel Neves-1/+1
2014-09-26Disable runtime split stack support on WindowsBrian Anderson-39/+1
2014-09-16Fallout from renamingAaron Turon-1/+1
2014-08-30Unify non-snake-case lints and non-uppercase statics lintsP1start-1/+1
This unifies the `non_snake_case_functions` and `uppercase_variables` lints into one lint, `non_snake_case`. It also now checks for non-snake-case modules. This also extends the non-camel-case types lint to check type parameters, and merges the `non_uppercase_pattern_statics` lint into the `non_uppercase_statics` lint. Because the `uppercase_variables` lint is now part of the `non_snake_case` lint, all non-snake-case variables that start with lowercase characters (such as `fooBar`) will now trigger the `non_snake_case` lint. New code should be updated to use the new `non_snake_case` lint instead of the previous `non_snake_case_functions` and `uppercase_variables` lints. All use of the `non_uppercase_pattern_statics` should be replaced with the `non_uppercase_statics` lint. Any code that previously contained non-snake-case module or variable names should be updated to use snake case names or disable the `non_snake_case` lint. Any code with non-camel-case type parameters should be changed to use camel case or disable the `non_camel_case_types` lint. [breaking-change]
2014-08-26auto merge of #16742 : vhbit/rust/ios-ffi-fix, r=alexcrichtonbors-0/+1
2014-08-26Use temp vars for implicit coercion to ^[T]Nick Cameron-3/+6
2014-08-25Adopting FFI changes for iOSValerii Hiora-0/+1
2014-08-21auto merge of #16362 : nham/rust/std_rand_pi_example, r=huonwbors-0/+43
Pros: I like this example because it's concise without being trivial. The Monty Hall example code is somewhat lengthy and possibly inaccessible to those unfamiliar with probability. Cons: The Monty Hall example already exists. Do we need another example? Also, this is probably inaccessible to people who don't know basic geometry.
2014-08-21Use unicode pi symbol in pi estimation example. Additional tweaksnham-7/+7
2014-08-21Surround formula in a 'notrust' code blocknham-0/+2
2014-08-18libsyntax: Remove the `use foo = bar` syntax from the language in favorPatrick Walton-2/+2
of `use bar as foo`. Change all uses of `use foo = bar` to `use bar as foo`. Implements RFC #47. Closes #16461. [breaking-change]
2014-08-13std: Rename various slice traits for consistencyBrian Anderson-2/+2
ImmutableVector -> ImmutableSlice ImmutableEqVector -> ImmutableEqSlice ImmutableOrdVector -> ImmutableOrdSlice MutableVector -> MutableSlice MutableVectorAllocating -> MutableSliceAllocating MutableCloneableVector -> MutableCloneableSlice MutableOrdVector -> MutableOrdSlice These are all in the prelude so most code will not break. [breaking-change]
2014-08-08Remove the dist function; it is more efficient to compare squared distancesnham-5/+1
2014-08-08Add example of estimating pi using Monte Carlo simulation to std::randnham-0/+45
2014-08-04Fix crash in OsRng when compiling with -O.Vadim Chugunov-2/+3
2014-07-28doc: use //! instead of /*! ... */ in std::randJonas Hietala-167/+163
2014-07-28doc: More efficient Monty Hall simulationJonas Hietala-8/+8
2014-07-28doc: Monty Hall simulation for std::randJonas Hietala-0/+103
A larger example for std::rand
2014-07-18Improve documentation for rand::randomSteve Klabnik-9/+14
This is now linked to in the guide, so I want to make sure it's good. This adds a bit more explanation, and brings usage in line with current good style.
2014-06-30libstd: set baseline stability levels.Aaron Turon-0/+2
Earlier commits have established a baseline of `experimental` stability for all crates under the facade (so their contents are considered experimental within libstd). Since `experimental` is `allow` by default, we should use the same baseline stability for libstd itself. This commit adds `experimental` tags to all of the modules defined in `std`, and `unstable` to `std` itself.
2014-06-29rand: Small fix in parameter namePiotr Jawniak-5/+5
Documentation didn't match with parameter name. Changes name of parameter in docs and function to 'amount'.
2014-06-28Rename all raw pointers as necessaryAlex Crichton-2/+3
2014-06-24librustc: Remove the fallback to `int` from typechecking.Niko Matsakis-16/+16
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-16auto merge of #14715 : vhbit/rust/ios-pr2, r=alexcrichtonbors-2/+67
2014-06-13auto merge of #14816 : theptrk/rust/unclear-comment, r=huonwbors-1/+1
The old comment left it unclear if this is creating a random value or doing a check as to whether or not the generator is available or some other operation. See: http://stackoverflow.com/questions/24153311/when-is-rng-gen-not-true
2014-06-12Basic iOS supportValerii Hiora-2/+67
2014-06-11rustc: Remove ~[T] from the languageAlex Crichton-14/+12
The following features have been removed * box [a, b, c] * ~[a, b, c] * box [a, ..N] * ~[a, ..N] * ~[T] (as a type) * deprecated_owned_vector lint All users of ~[T] should move to using Vec<T> instead.
2014-06-10Fix unclear wording of commenttheptrk-1/+1
2014-06-09core: Move the collections traits to libcollectionsAlex Crichton-2/+2
This commit moves Mutable, Map, MutableMap, Set, and MutableSet from `core::collections` to the `collections` crate at the top-level. Additionally, this removes the `deque` module and moves the `Deque` trait to only being available at the top-level of the collections crate. All functionality continues to be reexported through `std::collections`. [breaking-change]
2014-06-06Rename Iterator::len to countAaron Turon-6/+6
This commit carries out the request from issue #14678: > The method `Iterator::len()` is surprising, as all the other uses of > `len()` do not consume the value. `len()` would make more sense to be > called `count()`, but that would collide with the current > `Iterator::count(|T| -> bool) -> unit` method. That method, however, is > a bit redundant, and can be easily replaced with > `iter.filter(|x| x < 5).count()`. > After this change, we could then define the `len()` method > on `iter::ExactSize`. Closes #14678. [breaking-change]
2014-05-30windows: Allow snake_case errors for now.Kevin Butler-1/+2
2014-05-30Rename OSRng to OsRngPiotr Jawniak-25/+25
According to Rust's style guide acronyms in type names should be CamelCase. [breaking-change]
2014-05-29std: Recreate a `rand` moduleAlex Crichton-0/+896
This commit shuffles around some of the `rand` code, along with some reorganization. The new state of the world is as follows: * The librand crate now only depends on libcore. This interface is experimental. * The standard library has a new module, `std::rand`. This interface will eventually become stable. Unfortunately, this entailed more of a breaking change than just shuffling some names around. The following breaking changes were made to the rand library: * Rng::gen_vec() was removed. This has been replaced with Rng::gen_iter() which will return an infinite stream of random values. Previous behavior can be regained with `rng.gen_iter().take(n).collect()` * Rng::gen_ascii_str() was removed. This has been replaced with Rng::gen_ascii_chars() which will return an infinite stream of random ascii characters. Similarly to gen_iter(), previous behavior can be emulated with `rng.gen_ascii_chars().take(n).collect()` * {IsaacRng, Isaac64Rng, XorShiftRng}::new() have all been removed. These all relied on being able to use an OSRng for seeding, but this is no longer available in librand (where these types are defined). To retain the same functionality, these types now implement the `Rand` trait so they can be generated with a random seed from another random number generator. This allows the stdlib to use an OSRng to create seeded instances of these RNGs. * Rand implementations for `Box<T>` and `@T` were removed. These seemed to be pretty rare in the codebase, and it allows for librand to not depend on liballoc. Additionally, other pointer types like Rc<T> and Arc<T> were not supported. If this is undesirable, librand can depend on liballoc and regain these implementations. * The WeightedChoice structure is no longer built with a `Vec<Weighted<T>>`, but rather a `&mut [Weighted<T>]`. This means that the WeightedChoice structure now has a lifetime associated with it. * The `sample` method on `Rng` has been moved to a top-level function in the `rand` module due to its dependence on `Vec`. cc #13851 [breaking-change]
2014-03-12std: Move rand to librand.Huon Wilson-3886/+0
This functionality is not super-core and so doesn't need to be included in std. It's possible that std may need rand (it does a little bit now, for io::test) in which case the functionality required could be moved to a secret hidden module and reexposed by librand. Unfortunately, using #[deprecated] here is hard: there's too much to mock to make it feasible, since we have to ensure that programs still typecheck to reach the linting phase.
2014-03-04Rename all variables that have uppercase characters in their names to use ↵Palmer Cox-10/+10
only lowercase characters
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-24Remove std::default::Default from the preludeBrendan Zabarauskas-0/+1
2014-02-20move extra::test to libtestLiigo Zhuang-4/+8
2014-02-17Remove Real trait and move methods into FloatBrendan Zabarauskas-3/+3
This is part of the effort to simplify `std::num`, as tracked in issue #10387.
2014-02-14Fix all code examplesAlex Crichton-1/+1
2014-02-03std: Remove io::io_errorAlex Crichton-10/+10
* All I/O now returns IoResult<T> = Result<T, IoError> * All formatting traits now return fmt::Result = IoResult<()> * The if_ok!() macro was added to libstd
2014-01-31Introduce marker types for indicating variance and for opting outNiko Matsakis-4/+5
of builtin bounds. Fixes #10834. Fixes #11385. cc #5922.
2014-01-30Remove Times traitBrendan Zabarauskas-2/+1
`Times::times` was always a second-class loop because it did not support the `break` and `continue` operations. Its playful appeal was then lost after `do` was disabled for closures. It's time to let this one go.
2014-01-29Removing do keyword from libstd and librustcScott Lawrence-2/+2
2014-01-26Removed all instances of XXX in preparation for relaxing of FIXME ruleSalem Talha-1/+1
2014-01-25Uppercase numeric constantsChris Wong-3/+3
The following are renamed: * `min_value` => `MIN` * `max_value` => `MAX` * `bits` => `BITS` * `bytes` => `BYTES` Fixes #10010.
2014-01-17auto merge of #11503 : FlaPer87/rust/master, r=huonwbors-1/+1
The patch adds the missing pow method for all the implementations of the Integer trait. This is a small addition that will most likely be improved by the work happening in #10387. Fixes #11499