Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(rust/nanoid): use rand crate instead of getrandom #59

Merged
merged 2 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ jobs:
run: pdm run pytest -n auto -d --cov=src/ --cov-report=xml --cov-branch --benchmark-disable --benchmark-skip

- name: Upload Coverage Report to Codecov
uses: codecov/codecov-action@v4.6.0
uses: codecov/codecov-action@v5.0.4
with:
files: coverage.xml
token: ${{ secrets.CODECOV_TOKEN }}
Expand Down
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ include = [
]

[dependencies]
getrandom = "0.2.15"
pyo3 = { version = "0.23.1", features = ["abi3-py39"] }
rand = "0.8.5"
thiserror = "2.0.3"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ find the benchmark script in the `tests/` directory.
You can run the benchmarks using the following command:

```sh
pytest tests/benchmark.py --benchmark-histogram=assets/benchmark.svg
pytest tests/benchmark.py --benchmark-histogram=assets/benchmark
```

## Credits
Expand Down
56 changes: 28 additions & 28 deletions assets/benchmark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion rust/nanoid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ use rand::Rng;

#[inline(always)]
fn get_random_bytes(buffer: &mut [u8]) -> Result<(), Error> {
getrandom::getrandom(buffer).map_err(|_| Error::FailedToAllocate)?;
rand::thread_rng()
.try_fill(buffer)
.map_err(|_| Error::FailedToAllocate)?;
Ok(())
}

Expand Down
Loading