Skip to content

Standard: Distribution<__m128i> features requirements are undocumented #1410

@dragomang87

Description

@dragomang87

Common issues

Problem: rand::distributions::Standard for __m128i

Quick solution: do not have one

Details: Using version 0.8.5 and the documentation reports that there is impl Distribution<__m128i> for Standard .
However the following code

use rand::Rng;
use rand::distributions::Distribution;

use std::arch::x86_64::*;


pub fn generate_m128i(n: usize) -> Vec<__m128i> {
    // Set up generator
    let mut rng = rand::thread_rng();
    // Set up random variable
    let random_variable: rand::distributions::Standard;
    // Set up vector
    let mut vector: Vec<__m128i>  = Vec::new();
    // Generate vector
    for _ in 0..n {
        //vector.push(rng.gen::<__m128i>());
        //vector.push(rng.sample(Standard));
        vector.push(random_variable.sample(&mut rng));
    }
    return vector;
}

gives the error

error[E0277]: the trait bound `Standard: Distribution<std::arch::x86_64::__m128i>` is not satisfied
  --> src/random_generators.rs:18:21
   |
18 |         vector.push(random_variable.sample(&mut rng));
   |                     ^^^^^^^^^^^^^^^ ------ required by a bound introduced by this call
   |                     |
   |                     the trait `Distribution<std::arch::x86_64::__m128i>` is not implemented for `Standard`
   |
   = help: the following other types implement trait `Distribution<T>`:
             <Standard as Distribution<()>>
             <Standard as Distribution<(A, B)>>
             <Standard as Distribution<(A, B, C)>>
             <Standard as Distribution<(A, B, C, D)>>
             <Standard as Distribution<(A, B, C, D, E)>>
             <Standard as Distribution<(A, B, C, D, E, F)>>
             <Standard as Distribution<(A, B, C, D, E, F, G)>>
             <Standard as Distribution<(A, B, C, D, E, F, G, H)>>
           and 62 others

What am I doing wrong?

Metadata

Metadata

Assignees

Labels

C-docsDocumentation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions