You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Suppose foo is an Arc<T>. The lint would suggest replacing things like (*foo).clone() with Arc::unwrap_or_clone(foo).
Advantage
As noted in the official docs on Arc::unwrap_or_clone, this is entirely equivalent except that it avoids cloning in the case this was already the last reference to the Arc.
Drawbacks
Arc::unwrap_or_clone was only stabilized in Rust 1.76, I'm not sure if Clippy avoids making suggestions that require recent Rust for some definition of "recent".
Example
let foo:Arc<String> = Arc::new("foo".into());let bar:String = (*foo).clone();
Could be written as:
let foo:Arc<String> = Arc::new("foo".into());let bar:String = Arc::unwrap_or_clone(foo);
The text was updated successfully, but these errors were encountered:
Arc::unwrap_or_clone was only stabilized in Rust 1.76, I'm not sure if Clippy avoids making suggestions that require recent Rust for some definition of "recent".
The MSRV for lints can be configured, so this should be fine as long as the lint respects that.
What it does
Suppose
foo
is anArc<T>
. The lint would suggest replacing things like(*foo).clone()
withArc::unwrap_or_clone(foo)
.Advantage
As noted in the official docs on Arc::unwrap_or_clone, this is entirely equivalent except that it avoids cloning in the case this was already the last reference to the
Arc
.Drawbacks
Arc::unwrap_or_clone
was only stabilized in Rust 1.76, I'm not sure if Clippy avoids making suggestions that require recent Rust for some definition of "recent".Example
Could be written as:
The text was updated successfully, but these errors were encountered: