Skip to content

Commit 1bd903f

Browse files
committed
Mention the into_inner() naming convention
1 parent 417fe03 commit 1bd903f

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/naming.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,22 @@ into its underlying representation (`into`). Conversions prefixed `to_`, on the
9696
other hand, typically stay at the same level of abstraction but do some work to
9797
change one representation into another.
9898

99+
When a type wraps a single value to associate it with higher-level semantics,
100+
access to the wrapped value should be provided by an `into_inner()` method. This
101+
applies to wrappers that provide buffering like [`BufReader`], encoding or
102+
decoding like [`GzDecoder`], atomic access like [`AtomicBool`], or any similar
103+
semantics.
104+
105+
[`BufReader`]: https://doc.rust-lang.org/std/io/struct.BufReader.html#method.into_inner
106+
[`GzDecoder`]: https://docs.rs/flate2/0.2.19/flate2/read/struct.GzDecoder.html#method.into_inner
107+
[`AtomicBool`]: https://doc.rust-lang.org/std/sync/atomic/struct.AtomicBool.html#method.into_inner
108+
99109
##### More examples from the standard library
100110

101111
- [`Result::as_ref`](https://doc.rust-lang.org/std/result/enum.Result.html#method.as_ref)
102112
- [`RefCell::as_ptr`](https://doc.rust-lang.org/std/cell/struct.RefCell.html#method.as_ptr)
103113
- [`slice::to_vec`](https://doc.rust-lang.org/std/primitive.slice.html#method.to_vec)
104114
- [`Option::into_iter`](https://doc.rust-lang.org/std/option/enum.Option.html#method.into_iter)
105-
- [`AtomicBool::into_inner`](https://doc.rust-lang.org/std/sync/atomic/struct.AtomicBool.html#method.into_inner)
106115

107116

108117
<a id="c-iter"></a>

0 commit comments

Comments
 (0)