You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asyncband.apache.org by ti...@apache.org on 2026/10/03 06:36:51 UTC

(asyncband) 05/22: docs: remove comments that restate what the code declares

This is an automated email from the ASF dual-hosted git repository.

tisonkun pushed a commit to branch tison/deslopify
in repository https://gitbox.apache.org/repos/asf/asyncband.git

commit a0b741c6f15b241cd5c54ada14498b5bd879c09a
Author: tison <wa...@gmail.com>
AuthorDate: Sat Oct 3 14:20:27 2026 +0800

    docs: remove comments that restate what the code declares
    
    These comments narrate the very line they precede instead of explaining
    a rationale: field docs that paraphrase the field's type ("Container
    storing the protected data" on UnsafeCell<T>, "Non-null pointer to the
    mapped data" on NonNull<T>), the "ownership certificate" voice-over on
    Arc lock fields, "Release the lock by calling release on the semaphore"
    above s.release(1), and the "Use DerefMut ..." meta commentary. The
    broadcast Shared::inner field doc additionally duplicated the Inner
    type's own documentation. Comments carrying real invariants (variance,
    non-zero max_readers) are kept.
---
 asyncband/src/broadcast/mpmc/bounded/mod.rs     |  1 -
 asyncband/src/broadcast/mpmc/unbounded/mod.rs   |  1 -
 asyncband/src/mutex/mod.rs                      | 13 -------------
 asyncband/src/rwlock/mod.rs                     |  2 --
 asyncband/src/rwlock/owned_mapped_read_guard.rs |  4 ----
 5 files changed, 21 deletions(-)

diff --git a/asyncband/src/broadcast/mpmc/bounded/mod.rs b/asyncband/src/broadcast/mpmc/bounded/mod.rs
index f91faa2..8fcb79a 100644
--- a/asyncband/src/broadcast/mpmc/bounded/mod.rs
+++ b/asyncband/src/broadcast/mpmc/bounded/mod.rs
@@ -167,7 +167,6 @@ pub fn bounded<T: Clone>(capacity: usize) -> (BoundedSender<T>, BoundedReceiver<
 }
 
 struct Shared<T> {
-    /// Buffer, receiver cursors, and parked receivers, all under a single lock.
     inner: Mutex<Inner<T>>,
     /// Number of active senders.
     senders: AtomicUsize,
diff --git a/asyncband/src/broadcast/mpmc/unbounded/mod.rs b/asyncband/src/broadcast/mpmc/unbounded/mod.rs
index 15366ef..f5e8e99 100644
--- a/asyncband/src/broadcast/mpmc/unbounded/mod.rs
+++ b/asyncband/src/broadcast/mpmc/unbounded/mod.rs
@@ -103,7 +103,6 @@ pub fn unbounded<T: Clone>() -> (UnboundedSender<T>, UnboundedReceiver<T>) {
 }
 
 struct Shared<T> {
-    /// Buffer, receiver cursors, and parked receivers, all under a single lock.
     inner: Mutex<Inner<T>>,
     /// Number of active senders.
     senders: AtomicUsize,
diff --git a/asyncband/src/mutex/mod.rs b/asyncband/src/mutex/mod.rs
index ed04964..9b61e1e 100644
--- a/asyncband/src/mutex/mod.rs
+++ b/asyncband/src/mutex/mod.rs
@@ -78,9 +78,7 @@ use crate::internal::semaphore;
 ///
 /// See the [module level documentation](self) for more.
 pub struct Mutex<T: ?Sized> {
-    /// Semaphore used to control access to protected data, ensuring mutual exclusion
     s: semaphore::Semaphore,
-    /// Container storing the protected data, allowing interior mutability
     c: UnsafeCell<T>,
 }
 
@@ -618,9 +616,7 @@ impl<T: ?Sized> OwnedMutexGuard<T> {
 /// ```
 #[must_use = "dropping the guard releases the mutex immediately"]
 pub struct MappedMutexGuard<'a, T: ?Sized> {
-    /// Non-null pointer to the mapped data
     d: NonNull<T>,
-    /// Reference to the original mutex's semaphore, used for releasing the lock
     s: &'a semaphore::Semaphore,
     // Mutable access requires invariance over T.
     variance: PhantomData<&'a mut T>,
@@ -722,7 +718,6 @@ impl<'a, T: ?Sized> MappedMutexGuard<'a, T> {
         F: FnOnce(&mut T) -> &mut U,
         U: ?Sized,
     {
-        // Use DerefMut to safely get mutable reference, avoiding explicit unsafe block
         let d = NonNull::from(f(&mut *orig));
         let orig = ManuallyDrop::new(orig);
         MappedMutexGuard {
@@ -775,7 +770,6 @@ impl<'a, T: ?Sized> MappedMutexGuard<'a, T> {
         F: FnOnce(&mut T) -> Option<&mut U>,
         U: ?Sized,
     {
-        // Use DerefMut to safely get mutable reference, avoiding explicit unsafe block
         match f(&mut *orig) {
             Some(d) => {
                 let d = NonNull::from(d);
@@ -820,11 +814,7 @@ impl<'a, T: ?Sized> MappedMutexGuard<'a, T> {
 /// ```
 #[must_use = "dropping the guard releases the mutex immediately"]
 pub struct OwnedMappedMutexGuard<T: ?Sized, U: ?Sized> {
-    // This Arc acts as an ownership certificate, ensuring the Mutex remains valid
-    // and the lock is not released
     lock: Arc<Mutex<T>>,
-    // This NonNull pointer precisely points to the subfield U, telling us which
-    // memory location we can operate on, with compile-time guarantee of non-null
     d: NonNull<U>,
     // Mutable access requires invariance over U.
     variance: PhantomData<*mut U>,
@@ -844,7 +834,6 @@ unsafe impl<T: ?Sized + Send + Sync, U: ?Sized + Send + Sync> Sync for OwnedMapp
 
 impl<T: ?Sized, U: ?Sized> Drop for OwnedMappedMutexGuard<T, U> {
     fn drop(&mut self) {
-        // Release the lock by calling release on the semaphore
         self.lock.s.release(1);
     }
 }
@@ -923,7 +912,6 @@ impl<T: ?Sized, U: ?Sized> OwnedMappedMutexGuard<T, U> {
         F: FnOnce(&mut U) -> &mut V,
         V: ?Sized,
     {
-        // Use DerefMut to maintain consistency with other map implementations
         let d = NonNull::from(f(&mut *orig));
         let orig = ManuallyDrop::new(orig);
 
@@ -990,7 +978,6 @@ impl<T: ?Sized, U: ?Sized> OwnedMappedMutexGuard<T, U> {
         F: FnOnce(&mut U) -> Option<&mut V>,
         V: ?Sized,
     {
-        // Use DerefMut to maintain consistency with other filter_map implementations
         match f(&mut *orig) {
             Some(d) => {
                 let d = NonNull::from(d);
diff --git a/asyncband/src/rwlock/mod.rs b/asyncband/src/rwlock/mod.rs
index 346e38b..2c2ee23 100644
--- a/asyncband/src/rwlock/mod.rs
+++ b/asyncband/src/rwlock/mod.rs
@@ -76,9 +76,7 @@ pub struct RwLock<T: ?Sized> {
     ///
     /// This is ensured to be non-zero.
     max_readers: usize,
-    /// Semaphore to coordinate read and write access to T
     s: Semaphore,
-    /// The inner data.
     c: UnsafeCell<T>,
 }
 
diff --git a/asyncband/src/rwlock/owned_mapped_read_guard.rs b/asyncband/src/rwlock/owned_mapped_read_guard.rs
index ae96acd..e9a7365 100644
--- a/asyncband/src/rwlock/owned_mapped_read_guard.rs
+++ b/asyncband/src/rwlock/owned_mapped_read_guard.rs
@@ -62,11 +62,7 @@ use crate::rwlock::RwLock;
 /// ```
 #[must_use = "dropping the guard releases its read access immediately"]
 pub struct OwnedMappedRwLockReadGuard<T: ?Sized, U: ?Sized> {
-    // This Arc acts as an ownership certificate, ensuring the RwLock remains valid
-    // and the lock is not released
     lock: Arc<RwLock<T>>,
-    // This NonNull pointer precisely points to the subfield U, telling us which
-    // memory location we can operate on
     d: NonNull<U>,
     variance: PhantomData<fn() -> U>,
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@asyncband.apache.org
For additional commands, e-mail: commits-help@asyncband.apache.org