Implement generalized object and type parameter bounds (Fixes #16462)
This commit is contained in:
parent
3ee047ae1f
commit
1b487a8906
272 changed files with 6783 additions and 3154 deletions
|
|
@ -79,6 +79,13 @@ pub struct Weighted<T> {
|
|||
pub item: T,
|
||||
}
|
||||
|
||||
/// Note: stage0-specific version that lacks bound on A.
|
||||
#[cfg(stage0)]
|
||||
pub struct WeightedChoice<'a, T> {
|
||||
items: &'a mut [Weighted<T>],
|
||||
weight_range: Range<uint>
|
||||
}
|
||||
|
||||
/// A distribution that selects from a finite collection of weighted items.
|
||||
///
|
||||
/// Each item has an associated weight that influences how likely it
|
||||
|
|
@ -105,7 +112,8 @@ pub struct Weighted<T> {
|
|||
/// println!("{}", wc.ind_sample(&mut rng));
|
||||
/// }
|
||||
/// ```
|
||||
pub struct WeightedChoice<'a, T> {
|
||||
#[cfg(not(stage0))]
|
||||
pub struct WeightedChoice<'a, T:'a> {
|
||||
items: &'a mut [Weighted<T>],
|
||||
weight_range: Range<uint>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -269,10 +269,17 @@ pub trait Rng {
|
|||
}
|
||||
}
|
||||
|
||||
/// Note: stage0-specific version that lacks bound on A.
|
||||
#[cfg(stage0)]
|
||||
pub struct Generator<'a, T, R> {
|
||||
rng: &'a mut R,
|
||||
}
|
||||
|
||||
/// Iterator which will generate a stream of random items.
|
||||
///
|
||||
/// This iterator is created via the `gen_iter` method on `Rng`.
|
||||
pub struct Generator<'a, T, R> {
|
||||
#[cfg(not(stage0))]
|
||||
pub struct Generator<'a, T, R:'a> {
|
||||
rng: &'a mut R,
|
||||
}
|
||||
|
||||
|
|
@ -282,10 +289,17 @@ impl<'a, T: Rand, R: Rng> Iterator<T> for Generator<'a, T, R> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Note: stage0-specific version.
|
||||
#[cfg(stage0)]
|
||||
pub struct AsciiGenerator<'a, R> {
|
||||
rng: &'a mut R,
|
||||
}
|
||||
|
||||
/// Iterator which will continuously generate random ascii characters.
|
||||
///
|
||||
/// This iterator is created via the `gen_ascii_chars` method on `Rng`.
|
||||
pub struct AsciiGenerator<'a, R> {
|
||||
#[cfg(not(stage0))]
|
||||
pub struct AsciiGenerator<'a, R:'a> {
|
||||
rng: &'a mut R,
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue