diff options
Diffstat (limited to '')
-rw-r--r-- | src/tools/clippy/src/docs/rc_buffer.txt | 27 |
1 files changed, 0 insertions, 27 deletions
diff --git a/src/tools/clippy/src/docs/rc_buffer.txt b/src/tools/clippy/src/docs/rc_buffer.txt deleted file mode 100644 index 82ac58eeb..000000000 --- a/src/tools/clippy/src/docs/rc_buffer.txt +++ /dev/null @@ -1,27 +0,0 @@ -### What it does -Checks for `Rc<T>` and `Arc<T>` when `T` is a mutable buffer type such as `String` or `Vec`. - -### Why is this bad? -Expressions such as `Rc<String>` usually have no advantage over `Rc<str>`, since -it is larger and involves an extra level of indirection, and doesn't implement `Borrow<str>`. - -While mutating a buffer type would still be possible with `Rc::get_mut()`, it only -works if there are no additional references yet, which usually defeats the purpose of -enclosing it in a shared ownership type. Instead, additionally wrapping the inner -type with an interior mutable container (such as `RefCell` or `Mutex`) would normally -be used. - -### Known problems -This pattern can be desirable to avoid the overhead of a `RefCell` or `Mutex` for -cases where mutation only happens before there are any additional references. - -### Example -``` -fn foo(interned: Rc<String>) { ... } -``` - -Better: - -``` -fn foo(interned: Rc<str>) { ... } -```
\ No newline at end of file |