From d71ca26aeee6d773a5ff1afcbd4a3392ccf379a7 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Mon, 27 Jul 2026 10:32:36 -0400 Subject: [PATCH 1/2] Fix doctests with --no-default-features. --- README.md | 25 +++++++++++++++---------- src/lib.rs | 6 +++++- src/weak_hash_set.rs | 6 +++++- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 5fbbbf7..849a820 100644 --- a/README.md +++ b/README.md @@ -71,8 +71,10 @@ This is because the map holds the strings as `std::sync::Weak`s. ```rust use weak_table::WeakKeyHashMap; use std::sync::{Arc, Weak}; +# fn x() { +# type WeakKeyHashMap = weak_table::WeakKeyHashMap; -let mut table = , u32>>::new(); +let mut table = , u32>>::default(); let one = Arc::::from("one"); let two = Arc::::from("two"); @@ -91,6 +93,8 @@ drop(one); assert_eq!( table.get("one"), None ); assert_eq!( table.get("two"), Some(&2) ); +# } +# x(); ``` Here we use a weak hash set to implement a simple string interning facility: @@ -99,6 +103,8 @@ Here we use a weak hash set to implement a simple string interning facility: use weak_table::WeakHashSet; use std::ops::Deref; use std::rc::{Rc, Weak}; +# fn x() { +# type WeakHashSet = weak_table::WeakHashSet; #[derive(Clone, Debug)] pub struct Symbol(Rc); @@ -137,17 +143,16 @@ impl SymbolTable { } } -fn interning_test() { - let mut tab = SymbolTable::new(); +let mut tab = SymbolTable::new(); - let a0 = tab.intern("a"); - let a1 = tab.intern("a"); - let b = tab.intern("b"); +let a0 = tab.intern("a"); +let a1 = tab.intern("a"); +let b = tab.intern("b"); - assert_eq!(a0, a1); - assert_ne!(a0, b); -} -# interning_test(); +assert_eq!(a0, a1); +assert_ne!(a0, b); +# } +# x(); ``` [ahash-issue]: https://github.com/tov/weak-table-rs/issues/23 diff --git a/src/lib.rs b/src/lib.rs index af581e0..cdb5bc4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -70,10 +70,12 @@ pub struct WeakKeyHashMap(inner::Table, inner::Owned = weak_table::PtrWeakKeyHashMap; /// /// type Table = PtrWeakKeyHashMap, usize>; /// -/// let mut map = Table::new(); +/// let mut map = Table::default(); /// let a = Rc::::from("hello"); /// let b = Rc::::from("hello"); /// @@ -86,6 +88,8 @@ pub struct WeakKeyHashMap(inner::Table, inner::Owned(WeakKeyHashMap, V, S>); diff --git a/src/weak_hash_set.rs b/src/weak_hash_set.rs index 19837ab..1c40066 100644 --- a/src/weak_hash_set.rs +++ b/src/weak_hash_set.rs @@ -39,8 +39,10 @@ impl WeakHashSet { /// use weak_table::WeakHashSet; /// use std::rc::{Rc, Weak}; /// use std::ops::Deref; + /// # fn x() { + /// # type WeakHashSet = weak_table::WeakHashSet; /// - /// let mut set: WeakHashSet> = WeakHashSet::new(); + /// let mut set: WeakHashSet> = WeakHashSet::default(); /// /// let a = Rc::new("a".to_owned()); /// set.insert(a.clone()); @@ -48,6 +50,8 @@ impl WeakHashSet { /// let also_a = set.get("a").unwrap(); /// /// assert!(Rc::ptr_eq( &a, &also_a )); + /// # } + /// # x(); /// ``` /// /// expected *O*(1) time; worst-case *O*(*p*) time From 5c56b4b06a404a2d48660e84668cc7589ba07fce Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Mon, 27 Jul 2026 10:33:40 -0400 Subject: [PATCH 2/2] CI: Return to testing doctests with no-default-features --- .github/workflows/ci.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8c906e1..d2840f4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -56,10 +56,7 @@ jobs: - name: Cargo check run: cargo check --all-targets ${{ matrix.features }} - name: Run tests - run: cargo test ${{ matrix.features }} --tests --examples - - name: Run doctests - if: ${{ ! contains(matrix.features, '--no-default-features') }} - run: cargo test ${{ matrix.features }} --doc + run: cargo test ${{ matrix.features }} clippy: name: Clippy