Skip to content

Commit 5bf25bc

Browse files
authored
readme: minor tweaks (#537)
1 parent 3fd0872 commit 5bf25bc

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,20 @@ library like [`rand`].
2121

2222
## Usage
2323

24-
Add this to your `Cargo.toml`:
24+
Add the `getrandom` dependency to your `Cargo.toml` file:
2525

2626
```toml
2727
[dependencies]
28-
getrandom = "0.2"
28+
getrandom = "0.3"
2929
```
3030

31-
Then invoke the `fill` function:
31+
Then invoke the `fill` function on a byte buffer to fill it with random data:
3232

3333
```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];
3636
getrandom::fill(&mut buf)?;
37-
Ok(buf)
37+
Ok(u128::from_ne_bytes(buf))
3838
}
3939
```
4040

@@ -259,7 +259,7 @@ If your code uses [`fill_uninit`] and you enable memory sanitization
259259
configuration flag to enable unpoisoning of the destination buffer
260260
filled by `fill_uninit`.
261261

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):
263263
```sh
264264
RUSTFLAGS="-Zsanitizer=memory --cfg getrandom_sanitize" \
265265
cargo test -Zbuild-std --target=x86_64-unknown-linux-gnu

0 commit comments

Comments
 (0)