File tree 1 file changed +7
-7
lines changed
1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -21,20 +21,20 @@ library like [`rand`].
21
21
22
22
## Usage
23
23
24
- Add this to your ` Cargo.toml ` :
24
+ Add the ` getrandom ` dependency to your ` Cargo.toml ` file :
25
25
26
26
``` toml
27
27
[dependencies ]
28
- getrandom = " 0.2 "
28
+ getrandom = " 0.3 "
29
29
```
30
30
31
- Then invoke the ` fill ` function:
31
+ Then invoke the ` fill ` function on a byte buffer to fill it with random data :
32
32
33
33
``` rust
34
- fn get_random_buf () -> Result <[ u8 ; 32 ] , getrandom :: Error > {
35
- let mut buf = [0u8 ; 32 ];
34
+ fn get_random_u128 () -> Result <u128 , getrandom :: Error > {
35
+ let mut buf = [0u8 ; 16 ];
36
36
getrandom :: fill (& mut buf )? ;
37
- Ok (buf )
37
+ Ok (u128 :: from_ne_bytes ( buf ) )
38
38
}
39
39
```
40
40
@@ -259,7 +259,7 @@ If your code uses [`fill_uninit`] and you enable memory sanitization
259
259
configuration flag to enable unpoisoning of the destination buffer
260
260
filled by ` fill_uninit ` .
261
261
262
- For example, this can be done as follows (requires a Nightly compiler):
262
+ For example, it can be done as follows (requires a Nightly compiler):
263
263
``` sh
264
264
RUSTFLAGS=" -Zsanitizer=memory --cfg getrandom_sanitize" \
265
265
cargo test -Zbuild-std --target=x86_64-unknown-linux-gnu
You can’t perform that action at this time.
0 commit comments