Skip to content

Commit

Permalink
Don't say you "should" use fully qualified syntax
Browse files Browse the repository at this point in the history
That recommendation was removed last year; there isn't a particular
style that is officially recommended anymore.
  • Loading branch information
camelid committed Oct 28, 2020
1 parent e0eed3c commit 4e30e10
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
13 changes: 8 additions & 5 deletions library/alloc/src/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,18 @@
//! Rc::downgrade(&my_rc);
//! ```
//!
//! `Rc<T>`'s implementations of traits like `Clone` should also be called using
//! fully qualified syntax to avoid confusion as to whether the *reference* is being
//! cloned or the *backing data* (`T`) is being cloned:
//! `Rc<T>`'s implementations of traits like `Clone` may also be called using
//! fully qualified syntax. Some people prefer to use fully qualified syntax,
//! while others prefer using method-call syntax.
//!
//! ```
//! use std::rc::Rc;
//!
//! let my_rc = Rc::new(());
//! let your_rc = Rc::clone(&my_rc);
//! let rc = Rc::new(());
//! // Method-call syntax
//! let rc2 = rc.clone();
//! // Fully qualified syntax
//! let rc3 = Rc::clone(&rc);
//! ```
//!
//! [`Weak<T>`][`Weak`] does not auto-dereference to `T`, because the inner value may have
Expand Down
13 changes: 8 additions & 5 deletions library/alloc/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,18 @@ macro_rules! acquire {
/// Arc::downgrade(&my_arc);
/// ```
///
/// `Arc<T>`'s implementations of traits like `Clone` should also be called using
/// fully qualified syntax to avoid confusion as to whether the *reference* is being
/// cloned or the *backing data* (`T`) is being cloned:
/// `Arc<T>`'s implementations of traits like `Clone` may also be called using
/// fully qualified syntax. Some people prefer to use fully qualified syntax,
/// while others prefer using method-call syntax.
///
/// ```
/// use std::sync::Arc;
///
/// let my_arc = Arc::new(());
/// let your_arc = Arc::clone(&my_arc);
/// let arc = Arc::new(());
/// // Method-call syntax
/// let arc2 = arc.clone();
/// // Fully qualified syntax
/// let arc3 = Arc::clone(&arc);
/// ```
///
/// [`Weak<T>`][Weak] does not auto-dereference to `T`, because the inner value may have
Expand Down

0 comments on commit 4e30e10

Please sign in to comment.