Absolucy / Absolucy/nanorand-rs
How does/does fill() work at all ?
- Lenguaje dominante
- Rust
- Estrellas
- 251
- Forks
- 24
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
I was trying to generate some uuids and it seems that fill() just takes mutable references to temporary copies of the bytes in an array. I have to map the initial zeroed array and just use generate() to get it to work.
```rust
let mut rng = nanorand::tls_rng();
let random_bytes = [0; 16];
let random_bytes = random_bytes.map(|_| rng.generate::());
```
the above works
```rust
rng.fill(random_bytes);
rng.fill_bytes(random_bytes);
```
the above two do nothing, regardless of the declared mutability of `random_bytes`
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Línea de trabajo
Look at the fill() and fill_bytes() methods in the nanorand crate, likely in src/lib.rs or a similar core file. The issue shows that these methods do not modify the array as expected. Start by reading the method signatures and implementations to understand how they handle mutable references. Then write a small test to reproduce the problem and trace through the code to see where the bytes are being copied or lost.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- rust
- Área
- cli
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 45/100