Skip to content

Commit

Permalink
Remove misleading use of CriticalSection::new from Mutex docs
Browse files Browse the repository at this point in the history
  • Loading branch information
adamgreig committed Jul 16, 2023
1 parent 4bac682 commit fc95704
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/mutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,22 @@ use core::cell::{Ref, RefCell, RefMut, UnsafeCell};
/// To reduce verbosity when using `Mutex<RefCell<T>>`, we reimplement some of
/// `RefCell`'s methods on it directly.
///
/// ```
/// # use critical_section::{CriticalSection, Mutex};
/// ```no_run
/// # use critical_section::Mutex;
/// # use std::cell::RefCell;
///
/// static FOO: Mutex<RefCell<i32>> = Mutex::new(RefCell::new(42));
///
/// fn main() {
/// let cs = unsafe { CriticalSection::new() };
/// // Instead of calling this
/// let _ = FOO.borrow(cs).take();
/// // Call this
/// let _ = FOO.take(cs);
/// // `RefCell::borrow` and `RefCell::borrow_mut` are renamed to
/// // `borrow_ref` and `borrow_ref_mut` to avoid name collisions
/// let _: &mut i32 = &mut *FOO.borrow_ref_mut(cs);
/// critical_section::with(|cs| {
/// // Instead of calling this
/// let _ = FOO.borrow(cs).take();
/// // Call this
/// let _ = FOO.take(cs);
/// // `RefCell::borrow` and `RefCell::borrow_mut` are renamed to
/// // `borrow_ref` and `borrow_ref_mut` to avoid name collisions
/// let _: &mut i32 = &mut *FOO.borrow_ref_mut(cs);
/// })
/// }
/// ```
///
Expand Down

0 comments on commit fc95704

Please sign in to comment.