commit_hash stringlengths 40 40 | author stringlengths 1 57 | date timestamp[s]date 2010-07-26 04:45:09 2026-04-14 18:21:10 | message stringlengths 8 1.39M | diff stringlengths 68 51.2k | files_changed int64 1 136 | insertions int64 0 2.35k | deletions int64 0 1.9k |
|---|---|---|---|---|---|---|---|
b45a7369ca06da4200b99a12b1f6e1f2724fdc2d | Amanieu d'Antras | 2023-02-10T01:29:15 | Remove incorrect `thread_id::try_get` function
This was introduced in #44 but is actually broken since a thread could
be assigned the ID of an existing slot in the table if another thread
previously using that ID has exited. | diff --git a/src/lib.rs b/src/lib.rs
index 2283261..12d25f6 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -190,7 +190,7 @@ impl<T: Send> ThreadLocal<T> {
/// Returns the element for the current thread, if it exists.
pub fn get(&self) -> Option<&T> {
- thread_id::try_get().and_then(|thread| self.get_inn... | 2 | 27 | 32 |
d350189cbdcd996a90baf43ef612cb49754ab84b | Amanieu d'Antras | 2023-02-08T17:49:35 | Bump version to 1.1.5 | diff --git a/Cargo.toml b/Cargo.toml
index 00cb91e..8b8b5d5 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "thread_local"
-version = "1.1.4"
+version = "1.1.5"
authors = ["Amanieu d'Antras <amanieu@gmail.com>"]
description = "Per-object thread-local storage"
documentation = "https://docs... | 1 | 1 | 1 |
cedabb14305b05bd167b2aee3cc33b0c5a5c8f9c | Amanieu d'Antras | 2023-02-03T15:50:07 | Add a "nightly" feature to use `#[thread_local]` | diff --git a/Cargo.toml b/Cargo.toml
index bcfa98d..00cb91e 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -8,13 +8,19 @@ license = "MIT OR Apache-2.0"
repository = "https://github.com/Amanieu/thread_local-rs"
readme = "README.md"
keywords = ["thread_local", "concurrent", "thread"]
-edition = "2018"
+edition = "2021"
+... | 3 | 92 | 35 |
6631b73b8c242c4d4d9f936cd4d6d7efec95e26b | Amanieu d'Antras | 2022-12-12T23:04:05 | Split the thread-id TLS into 2 variables
This allows the fast path to avoid a branch which checks if the TLS
destructor for the thread ID has been registered. | diff --git a/src/lib.rs b/src/lib.rs
index 3e30d66..7ba7102 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -189,8 +189,7 @@ impl<T: Send> ThreadLocal<T> {
/// Returns the element for the current thread, if it exists.
pub fn get(&self) -> Option<&T> {
- let thread = thread_id::get();
- self.get_in... | 2 | 41 | 19 |
a9687ee92adffd0322e2e11facc25aa2bedbd6ea | Alex Touchet | 2022-11-16T06:35:17 | Use SPDX license format | diff --git a/Cargo.toml b/Cargo.toml
index fc737c2..bcfa98d 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -4,7 +4,7 @@ version = "1.1.4"
authors = ["Amanieu d'Antras <amanieu@gmail.com>"]
description = "Per-object thread-local storage"
documentation = "https://docs.rs/thread_local/"
-license = "Apache-2.0/MIT"
+licens... | 1 | 1 | 1 |
0a1d9cba9ec123861465061010a46a5393f7da23 | threadexception | 2022-11-12T20:19:47 | Inline nice function | diff --git a/Cargo.toml b/Cargo.toml
index f2e8ff0..fc737c2 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -17,7 +17,7 @@ travis-ci = { repository = "Amanieu/thread_local-rs" }
once_cell = "1.5.2"
# This is actually a dev-dependency, see https://github.com/rust-lang/cargo/issues/1596
-criterion = { version = "0.3.3", ... | 2 | 2 | 1 |
8ba40ceb79b00e642985e87be159696e5e398269 | Ibraheem Ahmed | 2022-06-14T23:15:02 | fix bucket deallocation with incorrect layout | diff --git a/src/lib.rs b/src/lib.rs
index 2fc3a76..3e30d66 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -149,7 +149,7 @@ impl<T: Send> Drop for ThreadLocal<T> {
continue;
}
- unsafe { Box::from_raw(std::slice::from_raw_parts_mut(bucket_ptr, this_bucket_size)) };
+ u... | 1 | 6 | 5 |
4937bab1117f41e59228cb15f5352dc437f146b4 | Ibraheem Ahmed | 2022-01-30T20:06:40 | remove mutex from `ThreadLocal` | diff --git a/src/lib.rs b/src/lib.rs
index 33b79d6..2fc3a76 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -81,7 +81,6 @@ use std::mem::MaybeUninit;
use std::panic::UnwindSafe;
use std::ptr;
use std::sync::atomic::{AtomicBool, AtomicPtr, AtomicUsize, Ordering};
-use std::sync::Mutex;
use thread_id::Thread;
use unreac... | 1 | 22 | 17 |
4a54e5702e0968bdda77366738ba646f646044e8 | Amanieu d'Antras | 2022-01-24T01:26:31 | Bump version to 1.1.4 | diff --git a/Cargo.toml b/Cargo.toml
index a56288f..f2e8ff0 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "thread_local"
-version = "1.1.3"
+version = "1.1.4"
authors = ["Amanieu d'Antras <amanieu@gmail.com>"]
description = "Per-object thread-local storage"
documentation = "https://docs... | 1 | 1 | 1 |
3d69afaab242fc1dd3a0658eb363b2df5e02fcd6 | Ibraheem Ahmed | 2022-01-23T00:11:24 | Fix memory ordering in `RawIter::next` | diff --git a/src/lib.rs b/src/lib.rs
index f26f6ed..33b79d6 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -378,7 +378,7 @@ impl RawIter {
fn next<'a, T: Send + Sync>(&mut self, thread_local: &'a ThreadLocal<T>) -> Option<&'a T> {
while self.bucket < BUCKETS {
let bucket = unsafe { thread_local.... | 1 | 1 | 1 |
c7d8dcdf4b93a5d80ec4075c3d8e7351c1a32012 | Amanieu d'Antras | 2021-02-04T17:46:45 | Bump version to 1.1.3 | diff --git a/Cargo.toml b/Cargo.toml
index a23f3fa..a56288f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "thread_local"
-version = "1.1.2"
+version = "1.1.3"
authors = ["Amanieu d'Antras <amanieu@gmail.com>"]
description = "Per-object thread-local storage"
documentation = "https://docs... | 1 | 1 | 1 |
a44b836f90e0317d256ed1dd4cff745feff285ea | Markus Westerlind | 2021-02-04T15:30:47 | fix: Drop the value in the ThreadLocal on drop
Regressed in (1.1.1) https://github.com/Amanieu/thread_local-rs/commit/fc5bfba36ed1f0aac527eb0a814fec104adc69ed | diff --git a/src/lib.rs b/src/lib.rs
index 98387ed..f26f6ed 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -119,6 +119,16 @@ struct Entry<T> {
value: UnsafeCell<MaybeUninit<T>>,
}
+impl<T> Drop for Entry<T> {
+ fn drop(&mut self) {
+ unsafe {
+ if *self.present.get_mut() {
+ ptr... | 1 | 27 | 0 |
322cf34816a62f1519d005cc44d623741740324e | Amanieu d'Antras | 2021-01-24T19:16:36 | Bump version to 1.1.2 | diff --git a/Cargo.toml b/Cargo.toml
index 9f75317..a23f3fa 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "thread_local"
-version = "1.1.1"
+version = "1.1.2"
authors = ["Amanieu d'Antras <amanieu@gmail.com>"]
description = "Per-object thread-local storage"
documentation = "https://docs... | 1 | 1 | 1 |
33ad4052309ba8b48b7436bf82d66be07103fa3f | Kestrer | 2021-01-24T18:59:36 | Add #[inline] to non-generic functions | diff --git a/src/lib.rs b/src/lib.rs
index 792a5b2..98387ed 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -355,6 +355,7 @@ struct RawIter {
index: usize,
}
impl RawIter {
+ #[inline]
fn new() -> Self {
Self {
yielded: 0,
@@ -411,6 +412,7 @@ impl RawIter {
}
}
+ #[in... | 1 | 2 | 0 |
810c043ff71ef66b96ca5d92319df4aa7134bf44 | Kestrer | 2021-01-24T06:56:40 | Implement iterator logic in RawIter | diff --git a/src/lib.rs b/src/lib.rs
index 16eadb6..792a5b2 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -76,7 +76,6 @@ pub use cached::{CachedIntoIter, CachedIterMut, CachedThreadLocal};
use std::cell::UnsafeCell;
use std::fmt;
use std::iter::FusedIterator;
-use std::marker::PhantomData;
use std::mem;
use std::mem... | 1 | 80 | 102 |
4bedfff87bb89f7eefd2dff005b31f3c34431812 | Koxiaet | 2021-01-23T06:59:06 | Implement missing traits on iterators
This implements Send, Sync, Debug and FusedIterator for
Iter/IterMut/IntoIter where appropriate. | diff --git a/src/lib.rs b/src/lib.rs
index 24ff4b2..8b98541 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -353,6 +353,7 @@ impl<T: Send + fmt::Debug> fmt::Debug for ThreadLocal<T> {
impl<T: Send + UnwindSafe> UnwindSafe for ThreadLocal<T> {}
/// Iterator over the contents of a `ThreadLocal`.
+#[derive(Debug)]
pub st... | 1 | 30 | 0 |
d779c7dfcf20eb9d6e4b01c7bbe431270fb3b106 | Koxiaet | 2021-01-23T06:42:27 | Implement IntoIterator for &ThreadLocal | diff --git a/src/lib.rs b/src/lib.rs
index 24ff4b2..43c670f 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -327,6 +327,15 @@ impl<T: Send> IntoIterator for ThreadLocal<T> {
}
}
+impl<'a, T: Send + Sync> IntoIterator for &'a ThreadLocal<T> {
+ type Item = &'a T;
+ type IntoIter = Iter<'a, T>;
+
+ fn into_i... | 1 | 9 | 0 |
c994299ec16b7d0f9af77e01dd9f8b0b67bf13d9 | Amanieu d'Antras | 2021-01-22T21:30:03 | Bump version to 1.1.1 | diff --git a/Cargo.toml b/Cargo.toml
index 82e263a..9f75317 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "thread_local"
-version = "1.1.0"
+version = "1.1.1"
authors = ["Amanieu d'Antras <amanieu@gmail.com>"]
description = "Per-object thread-local storage"
documentation = "https://docs... | 1 | 1 | 1 |
fc5bfba36ed1f0aac527eb0a814fec104adc69ed | Koxiaet | 2021-01-21T07:08:26 | Use MaybeUninit on rustc >= 1.36.0 | diff --git a/build.rs b/build.rs
new file mode 100644
index 0000000..3d3deb9
--- /dev/null
+++ b/build.rs
@@ -0,0 +1,48 @@
+use std::error::Error;
+use std::ffi::OsString;
+use std::process::{exit, Command};
+
+fn main() {
+ let rustc = std::env::var_os("RUSTC").unwrap_or_else(|| OsString::from("rustc"));
+ let c... | 3 | 107 | 11 |
1be15df2d1d72d1bc8757e0bde5fb3a5b0ebe870 | Koxiaet | 2021-01-20T06:49:50 | Add Iter | diff --git a/src/lib.rs b/src/lib.rs
index 78bdcc3..ae96a9c 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -78,11 +78,12 @@ pub use cached::{CachedIntoIter, CachedIterMut, CachedThreadLocal};
use std::cell::UnsafeCell;
use std::fmt;
+use std::iter::FusedIterator;
use std::marker::PhantomData;
use std::mem;
use std:... | 1 | 114 | 34 |
d9e93cbc8b8ff57351c65eb432323808da67744d | Amanieu d'Antras | 2021-01-07T21:40:41 | Bump version to 1.1.0 | diff --git a/Cargo.toml b/Cargo.toml
index e640fad..d81a344 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "thread_local"
-version = "1.0.1"
+version = "1.1.0"
authors = ["Amanieu d'Antras <amanieu@gmail.com>"]
description = "Per-object thread-local storage"
documentation = "https://aman... | 1 | 1 | 1 |
fe072dcfcbb14b4ab68efa205eb64369b1282f5b | Koxiaet | 2021-01-04T15:08:34 | Use a concurrent vector | diff --git a/src/cached.rs b/src/cached.rs
index 7955d3e..ebae662 100644
--- a/src/cached.rs
+++ b/src/cached.rs
@@ -4,7 +4,7 @@ use std::fmt;
use std::panic::UnwindSafe;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::usize;
-use thread_id;
+use thread_id::{self, Thread};
use unreachable::{UncheckedOption... | 3 | 202 | 133 |
d7b2b1d6a6572ea3d9a02d865bfe77ac46006e48 | Koxiaet | 2021-01-03T18:14:35 | Use criterion for benchmarks and add more of them | diff --git a/Cargo.toml b/Cargo.toml
index 83921af..9d36d7a 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -14,3 +14,10 @@ travis-ci = { repository = "Amanieu/thread_local-rs" }
[dependencies]
lazy_static = "1.0"
+
+[dev-dependencies]
+criterion = "0.3.3"
+
+[[bench]]
+name = "thread_local"
+harness = false
diff --git... | 2 | 62 | 14 |
6e46d4f23c49f7672efe18ed7b351f0cbaafa76f | Koxiaet | 2021-01-03T17:30:24 | Reverse the thread id binary heap | diff --git a/src/thread_id.rs b/src/thread_id.rs
index 3944fd9..238b895 100644
--- a/src/thread_id.rs
+++ b/src/thread_id.rs
@@ -5,6 +5,7 @@
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according to those terms.
+use std::cmp::Reverse;
use ... | 1 | 4 | 3 |
14c5889b5b5d95e8d270dbe6e85950ca635be559 | Koxiaet | 2021-01-02T10:57:05 | Save space with NonNull instead of a raw pointer | diff --git a/src/lib.rs b/src/lib.rs
index 4301cd6..2507241 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -84,6 +84,7 @@ use std::cell::UnsafeCell;
use std::fmt;
use std::marker::PhantomData;
use std::panic::UnwindSafe;
+use std::ptr::NonNull;
use std::sync::atomic::{AtomicPtr, Ordering};
use std::sync::Mutex;
use ... | 1 | 6 | 5 |
50c5c7d77427ea48084e50c1cf61962b564dd46d | Koxiaet | 2021-01-02T08:17:51 | Use a list instead of a hash map | diff --git a/src/cached.rs b/src/cached.rs
index ab43c86..7955d3e 100644
--- a/src/cached.rs
+++ b/src/cached.rs
@@ -3,6 +3,7 @@ use std::cell::UnsafeCell;
use std::fmt;
use std::panic::UnwindSafe;
use std::sync::atomic::{AtomicUsize, Ordering};
+use std::usize;
use thread_id;
use unreachable::{UncheckedOptionExt,... | 3 | 117 | 146 |
e9bfb9f163d73f146b9c9622254714e0552e223c | Koxiaet | 2020-11-13T19:46:56 | Update to 2018 edition | diff --git a/Cargo.toml b/Cargo.toml
index 83921af..0b24081 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -8,9 +8,10 @@ license = "Apache-2.0/MIT"
repository = "https://github.com/Amanieu/thread_local-rs"
readme = "README.md"
keywords = ["thread_local", "concurrent", "thread"]
+edition = "2018"
[badges]
travis-ci ... | 6 | 50 | 62 |
34011020194908f3aa852cac59a83e81a325767e | Amanieu d'Antras | 2020-01-11T12:55:42 | Bump version to 1.0.1 | diff --git a/Cargo.toml b/Cargo.toml
index 367adf7..83921af 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "thread_local"
-version = "1.0.0"
+version = "1.0.1"
authors = ["Amanieu d'Antras <amanieu@gmail.com>"]
description = "Per-object thread-local storage"
documentation = "https://aman... | 1 | 1 | 1 |
bc6ab4e4a3a9d5b0ea8ea769da27828946c57098 | Tomasz Miąsko | 2020-01-11T00:00:00 | Synchronize with release store in ThreadLocal::insert | diff --git a/src/lib.rs b/src/lib.rs
index 212fdac..9fd6d19 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -229,7 +229,7 @@ impl<T: Send> ThreadLocal<T> {
// Fast path: try to find our thread in the top-level hash table
fn get_fast(&self, id: usize) -> Option<&T> {
- let table = unsafe { &*self.table.lo... | 1 | 1 | 1 |
c3e3f9a1c192cffc3887add381d1f806b7ede483 | yjhmelody | 2019-10-31T08:01:12 | fix warnings and remove marker | diff --git a/src/cached.rs b/src/cached.rs
index 90944b5..ab43c86 100644
--- a/src/cached.rs
+++ b/src/cached.rs
@@ -85,13 +85,13 @@ impl<T: Send> CachedThreadLocal<T> {
{
if owner == 0 && self.owner.compare_and_swap(0, id, Ordering::Relaxed) == 0 {
unsafe {
- (*self.local.get(... | 2 | 3 | 7 |
6722893ba342d2aa9440fb152854c5b8dac07078 | Amanieu d'Antras | 2019-09-06T21:20:07 | Remove boxing from the API | diff --git a/src/cached.rs b/src/cached.rs
new file mode 100644
index 0000000..90944b5
--- /dev/null
+++ b/src/cached.rs
@@ -0,0 +1,198 @@
+use super::{IntoIter, IterMut, ThreadLocal};
+use std::cell::UnsafeCell;
+use std::fmt;
+use std::panic::UnwindSafe;
+use std::sync::atomic::{AtomicUsize, Ordering};
+use thread_id... | 2 | 286 | 234 |
8a0a184617f513b8f1807764e5f79c9df9f95791 | Amanieu d'Antras | 2019-09-06T09:59:33 | Rename get_default to get_or_default | diff --git a/src/lib.rs b/src/lib.rs
index 2f8e579..e7cfc18 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -364,7 +364,7 @@ impl<'a, T: ?Sized + Send + 'a> IntoIterator for &'a mut ThreadLocal<T> {
impl<T: Send + Default> ThreadLocal<T> {
/// Returns the element for the current thread, or creates a default one if
... | 1 | 2 | 2 |
8c956ed8642175f1a3afc409bf5f8844d3ea994a | Amanieu d'Antras | 2018-08-15T18:24:54 | Bump version to 0.3.6 | diff --git a/Cargo.toml b/Cargo.toml
index 7a84a6d..53d4645 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "thread_local"
-version = "0.3.5"
+version = "0.3.6"
authors = ["Amanieu d'Antras <amanieu@gmail.com>"]
description = "Per-object thread-local storage"
documentation = "https://aman... | 1 | 1 | 1 |
4edbd1c0fa2cfab47de472f177c10a0bfe480006 | Finkelman | 2018-08-15T17:14:04 | inline the code from unreachable and void | diff --git a/Cargo.toml b/Cargo.toml
index 4f0d264..7a84a6d 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,6 +13,4 @@ keywords = ["thread_local", "concurrent", "thread"]
travis-ci = { repository = "Amanieu/thread_local-rs" }
[dependencies]
-unreachable = "1.0"
-void = "1.0.2" # required only for minimal-versions. ... | 3 | 76 | 4 |
e7af2cfcb4b8e57de2639a1a8ce46c33eb48e782 | Finkelman | 2018-08-15T15:39:52 | void 1.0.1 does not build on modern rust | diff --git a/Cargo.toml b/Cargo.toml
index 2a41904..4f0d264 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -14,4 +14,5 @@ travis-ci = { repository = "Amanieu/thread_local-rs" }
[dependencies]
unreachable = "1.0"
+void = "1.0.2" # required only for minimal-versions. brought in by unreachable.
lazy_static = "1.0" | 1 | 1 | 0 |
c3fe9ef7187f88e83055c4eb9a745e11e76e3f9c | Amanieu d'Antras | 2017-12-09T14:32:15 | Bump version to 0.3.5 | diff --git a/Cargo.toml b/Cargo.toml
index 8199294..2a41904 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "thread_local"
-version = "0.3.4"
+version = "0.3.5"
authors = ["Amanieu d'Antras <amanieu@gmail.com>"]
description = "Per-object thread-local storage"
documentation = "https://aman... | 1 | 2 | 2 |
24aaf0cf530e26381192ec70c380e0f2cb654588 | Igor Gnatenko | 2017-11-30T16:40:36 | bump lazy_static to 1 | diff --git a/Cargo.toml b/Cargo.toml
index 3271eb6..8199294 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -14,4 +14,4 @@ travis-ci = { repository = "Amanieu/thread_local-rs" }
[dependencies]
unreachable = "1.0"
-lazy_static = "0.2"
+lazy_static = "1" | 1 | 1 | 1 |
9991d31b21d59f723f94dbf3b1bc3aa805c7923c | Martin Geisler | 2017-07-24T22:52:13 | Add CI badge | diff --git a/Cargo.toml b/Cargo.toml
index 8286cf1..3271eb6 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -9,6 +9,9 @@ repository = "https://github.com/Amanieu/thread_local-rs"
readme = "README.md"
keywords = ["thread_local", "concurrent", "thread"]
+[badges]
+travis-ci = { repository = "Amanieu/thread_local-rs" }
+
... | 1 | 3 | 0 |
19d951ae4201fb62cbc39f09ba3abac209489ac5 | Amanieu d'Antras | 2017-06-27T00:16:11 | Bump version to 0.3.4 | diff --git a/Cargo.toml b/Cargo.toml
index e5df477..8286cf1 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "thread_local"
-version = "0.3.3"
+version = "0.3.4"
authors = ["Amanieu d'Antras <amanieu@gmail.com>"]
description = "Per-object thread-local storage"
documentation = "https://aman... | 1 | 1 | 1 |
5767dd5b298df109b757e544f6ed2b9a5194646f | Amanieu d'Antras | 2017-06-27T00:13:01 | Refactor allocation of thread IDs to avoid unbounded growth | diff --git a/Cargo.toml b/Cargo.toml
index 8ef62ce..e5df477 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -11,6 +11,4 @@ keywords = ["thread_local", "concurrent", "thread"]
[dependencies]
unreachable = "1.0"
-
-[target.'cfg(not(target_os = "emscripten"))'.dependencies]
-thread-id = "3.0"
+lazy_static = "0.2"
diff --g... | 3 | 127 | 64 |
507fab6e630d4e723ac45cc626eb1596ce94c73d | Igor Gnatenko | 2017-06-14T14:28:42 | bump unreachable to 1.0 | diff --git a/Cargo.toml b/Cargo.toml
index b59399f..8ef62ce 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -10,7 +10,7 @@ readme = "README.md"
keywords = ["thread_local", "concurrent", "thread"]
[dependencies]
-unreachable = "0.1"
+unreachable = "1.0"
[target.'cfg(not(target_os = "emscripten"))'.dependencies]
thre... | 1 | 1 | 1 |
de2328f3019cd8379b8b8f7eab84a3e15be06484 | Amanieu d'Antras | 2017-02-20T01:15:54 | Bump version to 0.3.3 | diff --git a/Cargo.toml b/Cargo.toml
index 6c8240d..b59399f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "thread_local"
-version = "0.3.2"
+version = "0.3.3"
authors = ["Amanieu d'Antras <amanieu@gmail.com>"]
description = "Per-object thread-local storage"
documentation = "https://aman... | 1 | 1 | 1 |
4ac0aae346ee8705ef3732fbd0ce5a0f4956890d | Amanieu d'Antras | 2017-02-20T01:13:04 | Implement UnwindSafe for ThreadLocal and CachedThreadLocal | diff --git a/src/lib.rs b/src/lib.rs
index c6065c8..b8d68b2 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -81,6 +81,7 @@ use std::cell::UnsafeCell;
use std::fmt;
use std::iter::Chain;
use std::option::IntoIter as OptionIter;
+use std::panic::UnwindSafe;
use unreachable::{UncheckedOptionExt, UncheckedResultExt};
//... | 1 | 5 | 0 |
3cb1e16aac7d505e33169f14464e8eab55f72569 | Amanieu d'Antras | 2016-12-28T06:00:28 | Bump version to 0.3.2 | diff --git a/Cargo.toml b/Cargo.toml
index dd65ef5..6c8240d 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "thread_local"
-version = "0.3.1"
+version = "0.3.2"
authors = ["Amanieu d'Antras <amanieu@gmail.com>"]
description = "Per-object thread-local storage"
documentation = "https://aman... | 1 | 2 | 2 |
130c89c94ab5f3036a0e9f3b1d63cdd439cda951 | Amanieu d'Antras | 2016-12-28T05:58:48 | Fix compile error on emscripten | diff --git a/src/lib.rs b/src/lib.rs
index 2465663..c6065c8 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -157,7 +157,7 @@ fn get_thread_id() -> usize {
// reserved value to indicate an empty slot. We instead fall
// back to using the address of a thread-local variable, which
// is slightly slower but guar... | 1 | 1 | 1 |
0d94132eb9dd984f22bf4b2741f8ed0baa25157c | Amanieu d'Antras | 2016-12-24T15:52:12 | Bump version to 0.3.1 | diff --git a/Cargo.toml b/Cargo.toml
index ca34a4c..dd65ef5 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "thread_local"
-version = "0.3.0"
+version = "0.3.1"
authors = ["Amanieu d'Antras <amanieu@gmail.com>"]
description = "Per-object thread-local storage"
documentation = "https://aman... | 1 | 1 | 1 |
053d8128106e995e3fdd8b91fdad1ad02fa3417f | Amanieu d'Antras | 2016-12-24T15:49:38 | Fix emscripten support | diff --git a/Cargo.toml b/Cargo.toml
index a24bd24..ca34a4c 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -10,5 +10,7 @@ readme = "README.md"
keywords = ["thread_local", "concurrent", "thread"]
[dependencies]
-thread-id = "3.0"
unreachable = "0.1"
+
+[target.'cfg(not(target_os = "emscripten"))'.dependencies]
+thread... | 2 | 23 | 5 |
c4fd0ba34460aa5f00ccccfe345aee0005171263 | Amanieu d'Antras | 2016-10-30T01:29:34 | Bump version to 0.3.0 | diff --git a/Cargo.toml b/Cargo.toml
index e53b15b..a24bd24 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "thread_local"
-version = "0.2.7"
+version = "0.3.0"
authors = ["Amanieu d'Antras <amanieu@gmail.com>"]
description = "Per-object thread-local storage"
documentation = "https://aman... | 1 | 2 | 2 |
acb50a914d54b36c3d911bde5ff3f7a927034096 | Amanieu d'Antras | 2016-09-17T00:50:56 | Bump version to 0.2.7 | diff --git a/Cargo.toml b/Cargo.toml
index 0d52ef9..30d7002 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "thread_local"
-version = "0.2.6"
+version = "0.2.7"
authors = ["Amanieu d'Antras <amanieu@gmail.com>"]
description = "Per-object thread-local storage"
documentation = "https://aman... | 1 | 1 | 1 |
d2514a160fae02b53e5fc69f4f4992c028e6a45a | Amanieu d'Antras | 2016-09-17T00:50:31 | Add get_or_try | diff --git a/src/lib.rs b/src/lib.rs
index 7db4e97..3dede20 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -85,19 +85,27 @@ use std::option::IntoIter as OptionIter;
trait UncheckedOptionExt<T> {
unsafe fn unchecked_unwrap(self) -> T;
}
+#[inline]
+unsafe fn unreachable() -> ! {
+ enum Void {}
+ match *(1 as *... | 1 | 41 | 15 |
298a280c48f5fc3d2123f760ff872a1e515d3514 | Amanieu d'Antras | 2016-05-30T08:53:33 | Bump version to 0.2.6 | diff --git a/Cargo.toml b/Cargo.toml
index 628180f..0d52ef9 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "thread_local"
-version = "0.2.5"
+version = "0.2.6"
authors = ["Amanieu d'Antras <amanieu@gmail.com>"]
description = "Per-object thread-local storage"
documentation = "https://aman... | 1 | 1 | 1 |
8aaaf10958294cc2c6060c21bbb4b30a64df1696 | Amanieu d'Antras | 2016-05-29T20:01:23 | Add Debug for ThreadLocal and CachedThreadLocal | diff --git a/src/lib.rs b/src/lib.rs
index 28db609..ab462d4 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -43,6 +43,7 @@ use std::sync::Mutex;
use std::marker::PhantomData;
use std::cell::UnsafeCell;
use std::mem;
+use std::fmt;
// Option::unchecked_unwrap
trait UncheckedOptionExt<T> {
@@ -294,6 +295,12 @@ impl<T:... | 1 | 17 | 0 |
dcdcb4895bccbb705d76e3c20bf20d4db586ebb7 | Amanieu d'Antras | 2016-04-22T11:18:42 | Bump version to 0.2.5 | diff --git a/Cargo.toml b/Cargo.toml
index f366acb..628180f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "thread_local"
-version = "0.2.4"
+version = "0.2.5"
authors = ["Amanieu d'Antras <amanieu@gmail.com>"]
description = "Per-object thread-local storage"
documentation = "https://aman... | 1 | 1 | 1 |
03390bc687068d503e929d72c549f360218cc73c | Amanieu d'Antras | 2016-04-22T11:18:15 | Mark unreachable() with #[inline] | diff --git a/src/lib.rs b/src/lib.rs
index 574711e..3fd5599 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -50,6 +50,7 @@ trait UncheckedOptionExt<T> {
}
impl<T> UncheckedOptionExt<T> for Option<T> {
unsafe fn unchecked_unwrap(self) -> T {
+ #[inline]
unsafe fn unreachable() -> ! {
enum... | 1 | 1 | 0 |
3a73a202ea004d550baed7d1fa6e3588043c51d2 | Amanieu d'Antras | 2016-04-22T11:12:11 | Bump version to 0.2.4 | diff --git a/Cargo.toml b/Cargo.toml
index 5f0dc8e..f366acb 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "thread_local"
-version = "0.2.3"
+version = "0.2.4"
authors = ["Amanieu d'Antras <amanieu@gmail.com>"]
description = "Per-object thread-local storage"
documentation = "https://aman... | 1 | 1 | 1 |
80ea8afbe4861fb7795682808ceb59f1e9df6d9c | Amanieu d'Antras | 2016-04-10T14:02:20 | Bump version to 0.2.3 | diff --git a/Cargo.toml b/Cargo.toml
index 94b9b3a..ce7c064 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "thread_local"
-version = "0.2.2"
+version = "0.2.3"
authors = ["Amanieu d'Antras <amanieu@gmail.com>"]
description = "Per-object thread-local storage"
documentation = "https://aman... | 1 | 1 | 1 |
833bd401036b83b7b3d6e2558f0fd82df5723906 | Amanieu d'Antras | 2016-04-10T13:40:29 | get_default() requires T to be Sized | diff --git a/src/lib.rs b/src/lib.rs
index d18e9c8..89ea365 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -252,7 +252,7 @@ impl<T: ?Sized + Send> ThreadLocal<T> {
}
}
-impl<T: ?Sized + Send + Default> ThreadLocal<T> {
+impl<T: Send + Default> ThreadLocal<T> {
/// Returns the element for the current thread, o... | 1 | 2 | 2 |
4954766a5e6557b46b09a675afa46058773d5c38 | Amanieu d'Antras | 2016-04-10T10:53:18 | Bump version to 0.2.2 | diff --git a/Cargo.toml b/Cargo.toml
index 82f6c73..94b9b3a 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "thread_local"
-version = "0.2.1"
+version = "0.2.2"
authors = ["Amanieu d'Antras <amanieu@gmail.com>"]
description = "Per-object thread-local storage"
documentation = "https://aman... | 1 | 2 | 2 |
034653ef4ec8711809ee10fe72e4951352fcb7d2 | Amanieu d'Antras | 2016-04-10T10:52:28 | Add inlining overrides for CachedThreadLocal | diff --git a/src/lib.rs b/src/lib.rs
index 690b4eb..d18e9c8 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -305,6 +305,7 @@ impl<T: ?Sized + Send> CachedThreadLocal<T> {
/// Returns the element for the current thread, or creates it if it doesn't
/// exist.
+ #[inline(always)]
pub fn get_or<F>(&self, cr... | 1 | 2 | 0 |
33a8accb504f70ad1aaa32345e0aac74d92e2a9e | Amanieu d'Antras | 2016-04-09T10:19:39 | Bump version to 0.2.1 | diff --git a/Cargo.toml b/Cargo.toml
index ff383c9..82f6c73 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "thread_local"
-version = "0.2.0"
+version = "0.2.1"
authors = ["Amanieu d'Antras <amanieu@gmail.com>"]
description = "Per-object thread-local storage"
documentation = "https://aman... | 1 | 1 | 1 |
6d5ee50eee1979c994cebaca7149f131b988b630 | Amanieu d'Antras | 2016-04-09T10:19:22 | Use thread-id 2.0.0 | diff --git a/Cargo.toml b/Cargo.toml
index e0f3bab..ff383c9 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -10,5 +10,5 @@ readme = "README.md"
keywords = ["thread_local", "concurrent", "thread"]
[dependencies]
-thread-id = "1"
+thread-id = "2"
unreachable = "0.1"
diff --git a/src/lib.rs b/src/lib.rs
index b368c2f..69... | 2 | 5 | 5 |
90cec3e781265a8f3cee6534914720c454b7de75 | Andre Bogus | 2016-04-08T22:04:35 | fixed some clippy warnings | diff --git a/src/lib.rs b/src/lib.rs
index e2bb2d1..b368c2f 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -188,7 +188,7 @@ impl<T: ?Sized + Send> ThreadLocal<T> {
#[cold]
fn get_slow(&self, id: usize, table_top: &Table<T>) -> Option<&T> {
let mut current = &table_top.prev;
- while let &Some(ref ... | 1 | 5 | 7 |
c98231a13aa907df56d12e914bf4548ddd6c9eeb | Amanieu d'Antras | 2016-04-08T18:07:15 | T needs to be Send | diff --git a/src/lib.rs b/src/lib.rs
index 9e21dbc..78d3280 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -34,7 +34,7 @@
extern crate thread_id;
extern crate unreachable;
-use std::sync::atomic::{AtomicPtr, AtomicUsize, ATOMIC_USIZE_INIT, Ordering};
+use std::sync::atomic::{AtomicPtr, AtomicUsize, Ordering};
use std... | 1 | 13 | 13 |
ec35879964744d18d88b68b8c287dcfdc8a624b0 | Lucy | 2025-06-08T04:44:42 | style: run `cargo fmt --all` | diff --git a/src/entropy.rs b/src/entropy.rs
index b3ba151..841a836 100644
--- a/src/entropy.rs
+++ b/src/entropy.rs
@@ -1,3 +1,8 @@
+#[cfg(all(
+ any(target_os = "openbsd", target_os = "freebsd"),
+ not(feature = "getrandom")
+))]
+pub use bsd::entropy as system;
#[cfg(all(target_vendor = "apple", not(feature = "getr... | 3 | 11 | 7 |
8570492ea964652c749890f3754853c499884087 | Robert Kruszewski | 2025-06-08T04:43:16 | Update getrandom to 0.3 (#54) | diff --git a/Cargo.toml b/Cargo.toml
index 08fe9c2..17e2a07 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -21,22 +21,21 @@ wyrand = []
pcg64 = []
chacha = []
rdseed = ["std"]
-getrandom_custom = ["getrandom/custom"]
[dependencies]
zeroize = { version = "1.5", optional = true, features = ["zeroize_derive"] }
# o... | 2 | 4 | 8 |
f4154607d291024097a306f6ae4f407b9a24efd9 | Cem Akarsubaşı | 2025-06-08T04:42:47 | fix signature of RtlGenRandom and update entropy correspondingly (#53) | diff --git a/src/entropy/windows.rs b/src/entropy/windows.rs
index bb71137..1a73273 100644
--- a/src/entropy/windows.rs
+++ b/src/entropy/windows.rs
@@ -1,9 +1,11 @@
+use core::ffi::{c_void, c_ulong, c_char};
+
extern "system" {
#[link_name = "SystemFunction036"]
- fn RtlGenRandom(pBuffer: *mut u8, cbBuffer: usize) ... | 1 | 4 | 2 |
53cb461bc624098bf44a775766e216ecb5084d28 | David James | 2025-06-08T04:42:28 | feat: add chacha counter initialization (#51)
Co-authored-by: David James <davidcjames@gmail.com> | diff --git a/src/crypto/chacha.rs b/src/crypto/chacha.rs
index 13a8ef8..baa1ab9 100644
--- a/src/crypto/chacha.rs
+++ b/src/crypto/chacha.rs
@@ -48,7 +48,7 @@ pub fn chacha_block<const ROUNDS: u8>(input: [u32; 16]) -> [u32; 16] {
}
/// Initialize the ChaCha internal state, with a 256-bit key and 64-bit nonce.
-pub ... | 2 | 13 | 9 |
b022a4bf0b343b79188fe2b7499c4176efe2d311 | Stefan Tammer | 2025-06-08T04:41:46 | fix: underlying issue of generate_range of signed integers being off by 1 (#48) | diff --git a/src/gen.rs b/src/gen.rs
index 27a8708..141e30e 100644
--- a/src/gen.rs
+++ b/src/gen.rs
@@ -49,7 +49,7 @@ macro_rules! range {
impl<Generator: Rng<OUTPUT>, const OUTPUT: usize> RandomRange<Generator, OUTPUT> for $signed {
fn random_range<Bounds: RangeBounds<Self>>(r: &mut Generator, bounds: Bounds... | 1 | 8 | 2 |
e48f4e3c5903d01269a8865ec08b1672d7e3ac81 | Lucy | 2023-04-28T21:35:36 | 🎨 Format spacing | diff --git a/src/rand.rs b/src/rand.rs
index 0bd314c..11c40b8 100644
--- a/src/rand.rs
+++ b/src/rand.rs
@@ -27,6 +27,7 @@ pub mod chacha;
pub trait Rng<const OUTPUT: usize>: Clone {
/// Generates a random sequence of bytes, seeding from the internal state.
fn rand(&mut self) -> [u8; OUTPUT];
+
/// Generates a r... | 1 | 5 | 0 |
4be7f33567a13769e3d128133d9e5b2fb7693ff7 | Lucy | 2023-04-28T21:32:02 | 🚨 Fix clippy warnings | diff --git a/src/buffer.rs b/src/buffer.rs
index 1c58529..3969457 100644
--- a/src/buffer.rs
+++ b/src/buffer.rs
@@ -24,7 +24,7 @@ pub struct BufferedRng<InternalGenerator: Rng<OUTPUT>, const OUTPUT: usize> {
impl<InternalGenerator: Rng<OUTPUT>, const OUTPUT: usize> BufferedRng<InternalGenerator, OUTPUT> {
/// Wra... | 1 | 2 | 1 |
3440f2ca5241d9e63c3f6db680e0a895064943c1 | Lucy | 2023-04-28T21:29:48 | fix: Build on no_std with getrandom only.
Closes #31 | diff --git a/src/entropy.rs b/src/entropy.rs
index 2a0cdb8..998c198 100644
--- a/src/entropy.rs
+++ b/src/entropy.rs
@@ -58,7 +58,7 @@ pub fn system(out: &mut [u8]) {
windows
)))]
pub fn system(out: &mut [u8]) {
- backup_entropy(out);
+ backup(out);
}
#[cfg(feature = "rdseed")]
@@ -134,6 +134,6 @@ pub fn backup... | 1 | 2 | 2 |
c6f380231d0931cc7664ac3c52fa4043b1439ce2 | Jacob | 2023-02-06T23:36:26 | feat: Implement Fisher-Yates shuffle (#42)
* Implement Fisher-Yates shuffle
Move from naive shuffle to Fisher-Yates shuffle as per https://github.com/Absolucy/nanorand-rs/issues/37
* Update with cargo fmt | diff --git a/src/rand.rs b/src/rand.rs
index 1438196..0bd314c 100644
--- a/src/rand.rs
+++ b/src/rand.rs
@@ -73,8 +73,8 @@ pub trait Rng<const OUTPUT: usize>: Clone {
{
let target = target.as_mut();
let target_len = target.len();
- for idx in 0..target_len {
- let random_idx = self.generate_range(0..target_l... | 1 | 2 | 2 |
8a87ac8d1e10285794d41dbc1e723358e5e5a1ff | Santiago V | 2022-11-01T20:10:21 | fix: fix lower bound for signed `generate_range` function (#38)
* test: add more tests for signed generate_range
* fix: increase lower bound in signed range by 1
* chore: fix format | diff --git a/src/gen.rs b/src/gen.rs
index 8fc0c3d..27a8708 100644
--- a/src/gen.rs
+++ b/src/gen.rs
@@ -49,7 +49,7 @@ macro_rules! range {
impl<Generator: Rng<OUTPUT>, const OUTPUT: usize> RandomRange<Generator, OUTPUT> for $signed {
fn random_range<Bounds: RangeBounds<Self>>(r: &mut Generator, bounds: Bounds... | 1 | 14 | 1 |
907c58a5ffb4f443ef9bfc8c0ae535ad3881b847 | Lucy | 2022-03-23T19:37:59 | 🔧 Add `rust-version` flag to `Cargo.toml` | diff --git a/Cargo.toml b/Cargo.toml
index 747a7b8..08fe9c2 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -6,6 +6,7 @@ keywords = ["rand", "random", "no-std", "entropy"]
categories = ["algorithms", "no-std"]
readme = "README.md"
version = "0.8.0"
+rust-version = "1.56"
authors = ["Lucy <lucy@absolucy.moe>"]
edition ... | 1 | 1 | 0 |
92a5c71aeb40c032f49f91919a8b164e150b9455 | Lucy | 2022-03-23T19:32:55 | 📝 Use `doc_auto_cfg` | diff --git a/Cargo.toml b/Cargo.toml
index 90ffe46..747a7b8 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -11,10 +11,11 @@ edition = "2021"
license = "Zlib"
[features]
-default = ["std", "tls", "wyrand", "pcg64", "chacha"]
+default = ["entropy", "std", "tls", "wyrand", "pcg64", "chacha"]
+entropy = []
alloc = []
st... | 10 | 14 | 18 |
d38b5d1ae880f46f8a43b5ee89e3ac5bc64f0e66 | Lucy | 2022-03-23T19:23:05 | 📝 Add feature flags for docs.rs in documentation | diff --git a/Cargo.toml b/Cargo.toml
index 188e8eb..90ffe46 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -36,12 +36,12 @@ getrandom = { version = "0.2", optional = true, features = ["rdrand"] }
[target.'cfg(not(any(target_arch = "wasm32", target_arch = "x86", target_arch = "x86_64")))'.dependencies]
getrandom = { vers... | 9 | 13 | 1 |
34ba2430a97ee90c03518a5aafe99fae33ff10cf | Lucy | 2022-03-23T19:18:58 | ⬆️ Don't care about dependency patch versions; add `getrandom/custom` feature | diff --git a/Cargo.toml b/Cargo.toml
index 3f6a86b..188e8eb 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -19,10 +19,23 @@ wyrand = []
pcg64 = []
chacha = []
rdseed = ["std"]
+getrandom_custom = ["getrandom/custom"]
[dependencies]
-zeroize = { version = "1.5.3", optional = true, features = ["zeroize_derive"] }
-get... | 3 | 19 | 3 |
8f3a456ae88e16bd0a3a06cd7b18ec95f1b014a0 | Lucy | 2022-03-23T19:13:11 | 🔖 Bump version to 0.8 | diff --git a/Cargo.toml b/Cargo.toml
index 1564aff..3f6a86b 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -5,7 +5,7 @@ repository = "https://github.com/Absolucy/nanorand-rs"
keywords = ["rand", "random", "no-std", "entropy"]
categories = ["algorithms", "no-std"]
readme = "README.md"
-version = "0.7.0"
+version = "0.8.... | 1 | 1 | 2 |
f7c67967cb78dde9629f78e4d8ece384089c2446 | Lucy | 2022-03-09T00:42:29 | fix: Fix README.md path in the Cargo.toml | diff --git a/Cargo.toml b/Cargo.toml
index 0bd4b6d..1564aff 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -4,7 +4,7 @@ description = "A tiny, fast, zero-dep library for random number generation."
repository = "https://github.com/Absolucy/nanorand-rs"
keywords = ["rand", "random", "no-std", "entropy"]
categories = ["al... | 1 | 1 | 1 |
fd84d80a1b2509b5bcb08094f7958f83ae1ccd0e | Lucy | 2022-03-09T00:31:22 | fix: fix generics ordering | diff --git a/nanorand-abi/src/lib.rs b/nanorand-abi/src/lib.rs
index 97c149b..da867d2 100644
--- a/nanorand-abi/src/lib.rs
+++ b/nanorand-abi/src/lib.rs
@@ -65,7 +65,7 @@ macro_rules! define_c_api {
/// Wrap a $type RNG in a buffer.
/// This consumes the RNG, and must be freed later with `free_$name_buffered(pt... | 4 | 27 | 27 |
a9c348fa6aae15567956d3c1fa16dd04ae3943e5 | Lucy | 2022-03-08T22:52:51 | fix: Fix `Rng::fill_bytes` panicking | diff --git a/src/rand.rs b/src/rand.rs
index 2cbab40..2097f1a 100644
--- a/src/rand.rs
+++ b/src/rand.rs
@@ -44,7 +44,7 @@ pub trait Rng<const OUTPUT: usize>: Clone {
while length > 0 {
let chunk = self.rand();
let generated = chunk.len().min(length);
- buffer[..generated].copy_from_slice(&chunk);
+ buff... | 1 | 1 | 1 |
a160701904ea79d5d88d46fe63ee4a12fc656bb8 | Lucy | 2022-03-08T22:43:47 | fix: Fix `pcg64` being named `wyrand` | diff --git a/nanorand-abi/src/wyrand.rs b/nanorand-abi/src/wyrand.rs
index 886136e..4cdf5ae 100644
--- a/nanorand-abi/src/wyrand.rs
+++ b/nanorand-abi/src/wyrand.rs
@@ -1,3 +1,3 @@
use crate::define_c_api;
-define_c_api!(pcg64, WyRand, 8);
+define_c_api!(wyrand, WyRand, 8); | 1 | 1 | 1 |
5d1783b2e544563c8d8b306b5a5d8e56e6af6ac6 | Lucy | 2022-03-08T21:23:31 | refactor: don't do the stupid endianness switching with rdseed | diff --git a/src/entropy.rs b/src/entropy.rs
index 2f575cc..dc6e572 100644
--- a/src/entropy.rs
+++ b/src/entropy.rs
@@ -86,11 +86,7 @@ pub fn rdseed(out: &mut [u8]) -> Option<usize> {
Some(s) => s,
None => return Some(bytes_pulled),
};
- let x = if n % 2 == 0 {
- seed.to_le_bytes()
- } else {
- seed.t... | 1 | 1 | 5 |
89b9ec0717f11d2747eaabca9d7bb29281aafdff | Lucy | 2022-03-08T21:21:14 | feat: Make all generics more readable; implement Rng for InternalGenerator | diff --git a/src/buffer.rs b/src/buffer.rs
index 80092f0..b3438ff 100644
--- a/src/buffer.rs
+++ b/src/buffer.rs
@@ -1,9 +1,6 @@
-use crate::rand::Rng;
+use crate::rand::{Rng, SeedableRng};
use alloc::vec::Vec;
-use core::{
- default::Default,
- ops::{Deref, DerefMut},
-};
+use core::default::Default;
/// A buffere... | 3 | 93 | 68 |
40199c8eceae781c8dff2856accd70e955a9befd | Lucy | 2022-03-08T20:52:36 | fix: fix signed integer generation :) | diff --git a/src/gen.rs b/src/gen.rs
index 61e5288..c25113f 100644
--- a/src/gen.rs
+++ b/src/gen.rs
@@ -34,10 +34,12 @@ macro_rules! range {
Bound::Unbounded => <$type>::MIN,
};
let upper = match bounds.end_bound() {
- Bound::Included(upper) => upper.saturating_sub(lower).saturating_add(1),
- ... | 1 | 20 | 22 |
364ff783b155376f5e50c35d23af366a165ad1b4 | Lucy | 2022-03-06T20:55:17 | feat: add `Debug` implementations for all the RNGs | diff --git a/src/rand/chacha.rs b/src/rand/chacha.rs
index 47eae19..7dd10d5 100644
--- a/src/rand/chacha.rs
+++ b/src/rand/chacha.rs
@@ -2,7 +2,7 @@ use crate::{
crypto::chacha,
rand::{Rng, SeedableRng},
};
-use core::fmt::{self, Display, Formatter};
+use core::fmt::{self, Debug, Display, Formatter};
#[cfg(featur... | 3 | 31 | 3 |
e6b40a3b8b54aa4554ce17127a26b5be0fe1e85e | Lucy | 2022-03-06T20:45:06 | refactor(rng!): rework `Rng::reseed` into the `SeedableRng` trait | diff --git a/src/rand.rs b/src/rand.rs
index ae56966..0bafb11 100644
--- a/src/rand.rs
+++ b/src/rand.rs
@@ -27,8 +27,6 @@ pub mod chacha;
pub trait Rng<const OUTPUT: usize>: Clone {
/// Generates a random sequence of bytes, seeding from the internal state.
fn rand(&mut self) -> [u8; OUTPUT];
- /// Generates a ran... | 5 | 37 | 52 |
da4710fcf2975df15c5e386f1b160987191daea6 | Lucy | 2022-03-06T20:23:16 | refactor: switch from `name/mod.rs` to `name.rs` structure | diff --git a/src/crypto/mod.rs b/src/crypto.rs
similarity index 100%
rename from src/crypto/mod.rs
rename to src/crypto.rs
diff --git a/src/entropy/mod.rs b/src/entropy.rs
similarity index 100%
rename from src/entropy/mod.rs
rename to src/entropy.rs
diff --git a/src/rand/mod.rs b/src/rand.rs
similarity index 100%
renam... | 3 | 0 | 0 |
104abca72c166924bfb8f700e30ce525804dc1ac | Lucy | 2022-03-06T20:21:35 | feat(rand)!: use const generics for traits instead of `type Output: AsRef<[u8]>` | diff --git a/src/gen.rs b/src/gen.rs
index 80997cd..61e5288 100644
--- a/src/gen.rs
+++ b/src/gen.rs
@@ -4,7 +4,7 @@ use core::ops::{Bound, RangeBounds};
macro_rules! gen {
($($type:ty),+) => {
$(
- impl<R: Rng> RandomGen<R> for $type {
+ impl<const OUTPUT: usize, R: Rng<OUTPUT>> RandomGen<OUTPUT, R> for $typ... | 6 | 26 | 37 |
e909c7daa50a485ac7e2dfe09af5218539227ed6 | Lucy | 2022-03-06T20:05:48 | chore: update version to 0.7.0 | diff --git a/Cargo.toml b/Cargo.toml
index 0099bcf..74be4a0 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -5,7 +5,7 @@ repository = "https://github.com/Absolucy/nanorand-rs"
keywords = ["rand", "random", "no-std", "entropy"]
categories = ["algorithms", "no-std"]
readme = "../README.md"
-version = "0.6.1"
+version = "0... | 2 | 2 | 2 |
58bffc504f15e09d14e4005f2ae9e186dbde3b89 | Lucy | 2022-03-06T20:05:14 | chore: Update Rust edition to 2021 | diff --git a/Cargo.toml b/Cargo.toml
index 3ab4ba6..0099bcf 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -7,7 +7,7 @@ categories = ["algorithms", "no-std"]
readme = "../README.md"
version = "0.6.1"
authors = ["Lucy <lucy@absolucy.moe>"]
-edition = "2018"
+edition = "2021"
license = "Zlib"
[features]
diff --git a/... | 4 | 5 | 5 |
340f893dbc9db3e43c6315b05eff4b0b150220d2 | Lucy | 2021-07-24T00:15:21 | fix: Fix aliased mutable references with `TlsWyRand` (fixes #28) | diff --git a/nanorand/src/tls.rs b/nanorand/src/tls.rs
index 5a054c5..3d920a8 100644
--- a/nanorand/src/tls.rs
+++ b/nanorand/src/tls.rs
@@ -1,32 +1,27 @@
-use crate::WyRand;
-use std::{
- cell::UnsafeCell,
- ops::{Deref, DerefMut},
- rc::Rc,
-};
+use crate::{Rng, WyRand};
+use std::{cell::RefCell, rc::Rc};
thread_l... | 1 | 15 | 20 |
ff7814fc40a145a0bb3e3338edea19ffe25ab567 | Lucy | 2021-07-07T22:18:18 | chore: remove some `#[inline(always)]` | diff --git a/nanorand/src/entropy/mod.rs b/nanorand/src/entropy/mod.rs
index a9fe32f..2f575cc 100644
--- a/nanorand/src/entropy/mod.rs
+++ b/nanorand/src/entropy/mod.rs
@@ -53,7 +53,6 @@ pub fn system(out: &mut [u8]) {
#[cfg(feature = "rdseed")]
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
-#[inline(alw... | 2 | 0 | 3 |
47ac7bc3be66e1e7f8039bdbf62670ec6bbed61b | Lucy | 2021-07-07T21:30:37 | feat: `RandomGen` implementation for floats | diff --git a/nanorand/src/gen.rs b/nanorand/src/gen.rs
index 27131b7..80997cd 100644
--- a/nanorand/src/gen.rs
+++ b/nanorand/src/gen.rs
@@ -92,6 +92,18 @@ impl<R: Rng> RandomGen<R> for bool {
}
}
+impl<R: Rng> RandomGen<R> for f32 {
+ fn random(r: &mut R) -> Self {
+ (u32::random(r) as f32) / (u32::MAX as f32)
+... | 1 | 26 | 0 |
9c8c248b757be31886b4e522383b8cc9dfbc0d75 | Lucy | 2021-07-07T21:20:40 | test: Add another test case to `ensure_signed_in_range` | diff --git a/nanorand/src/gen.rs b/nanorand/src/gen.rs
index 4ed7052..27131b7 100644
--- a/nanorand/src/gen.rs
+++ b/nanorand/src/gen.rs
@@ -161,6 +161,9 @@ mod tests {
let number = rng.generate_range(..512);
assert!((..512).contains(&number), "{} was outside of ..512", number);
+
+ let number = rng.generat... | 1 | 3 | 0 |
7f992911535bb415859ab89406c0092ce393a64b | Lucy | 2021-07-07T21:15:37 | fix: signed `RandomRange` now works properly | diff --git a/nanorand/src/gen.rs b/nanorand/src/gen.rs
index f54e5e4..3c37fb0 100644
--- a/nanorand/src/gen.rs
+++ b/nanorand/src/gen.rs
@@ -53,42 +53,21 @@ macro_rules! range {
impl<R: Rng> RandomRange<R> for $signed {
fn random_range<B: RangeBounds<Self>>(r: &mut R, bounds: B) -> Self {
- const BITS: $... | 2 | 70 | 31 |
ff4309dc7c028a2e944f0f072b1dfc448f7292fe | Lucy | 2021-07-07T20:16:17 | fix: fix compile error on Windows | diff --git a/nanorand/src/entropy/windows.rs b/nanorand/src/entropy/windows.rs
index d40ae82..bb71137 100644
--- a/nanorand/src/entropy/windows.rs
+++ b/nanorand/src/entropy/windows.rs
@@ -1,5 +1,3 @@
-use super::backup_entropy;
-
extern "system" {
#[link_name = "SystemFunction036"]
fn RtlGenRandom(pBuffer: *mut u... | 1 | 0 | 2 |
8307f122a6ef66f9f7a4d6e749f81d8ce4a9691b | Lucy | 2021-07-07T20:15:53 | feat: `RandomRange` for signed integers | diff --git a/nanorand/src/gen.rs b/nanorand/src/gen.rs
index e9da125..f54e5e4 100644
--- a/nanorand/src/gen.rs
+++ b/nanorand/src/gen.rs
@@ -23,7 +23,7 @@ macro_rules! gen {
}
macro_rules! range {
- ($(($type:ty, $bigger:ty)),+) => {
+ ($(($type:ty, $bigger:ty, $signed:ty)),+) => {
$(
impl<R: Rng> RandomRang... | 1 | 51 | 5 |
4e67a2eb1611a4ecc331df38b6f0a1a2f7a013a7 | aspen | 2021-06-03T14:57:28 | style: reformat some stuff to use `where` trait bounds | diff --git a/nanorand/src/rand/mod.rs b/nanorand/src/rand/mod.rs
index e12fedd..fcc701c 100644
--- a/nanorand/src/rand/mod.rs
+++ b/nanorand/src/rand/mod.rs
@@ -33,20 +33,34 @@ pub trait Rng: Clone {
/// Generates a random sequence of bytes, with a custom seed.
fn rand_with_seed(seed: &[u8]) -> Self::Output;
/// ... | 1 | 18 | 4 |
b42c6b1383a1ca4a4d3c6825ba5f599b6d78dbaa | aspen | 2021-05-29T19:04:50 | fix: Fix incorrect bitshifting | diff --git a/nanorand/src/lib.rs b/nanorand/src/lib.rs
index d8cd552..2eab9d1 100644
--- a/nanorand/src/lib.rs
+++ b/nanorand/src/lib.rs
@@ -30,7 +30,7 @@
//! use nanorand::{Rng, WyRand};
//!
//! let mut rng = WyRand::new();
-//! println!("Random number between 1 and 100: {}", rng.generate_range::<u64>(1, 100));
+//... | 3 | 6 | 6 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.