Skip to content

Commit

Permalink
readme: minor tweaks (#537)
Browse files Browse the repository at this point in the history
  • Loading branch information
newpavlov authored Oct 28, 2024
1 parent 3fd0872 commit 5bf25bc
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,20 @@ library like [`rand`].

## Usage

Add this to your `Cargo.toml`:
Add the `getrandom` dependency to your `Cargo.toml` file:

```toml
[dependencies]
getrandom = "0.2"
getrandom = "0.3"
```

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

```rust
fn get_random_buf() -> Result<[u8; 32], getrandom::Error> {
let mut buf = [0u8; 32];
fn get_random_u128() -> Result<u128, getrandom::Error> {
let mut buf = [0u8; 16];
getrandom::fill(&mut buf)?;
Ok(buf)
Ok(u128::from_ne_bytes(buf))
}
```

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

For example, this can be done as follows (requires a Nightly compiler):
For example, it can be done as follows (requires a Nightly compiler):
```sh
RUSTFLAGS="-Zsanitizer=memory --cfg getrandom_sanitize" \
cargo test -Zbuild-std --target=x86_64-unknown-linux-gnu
Expand Down

0 comments on commit 5bf25bc

Please sign in to comment.