Skip to content

Commit 9725caf

Browse files
authored
Rollup merge of #95110 - wmstack:patch-1, r=Dylan-DPC
Provide more useful documentation of conversion methods I thought that the documentation for these methods needed to be a bit more explanatory for new users. For advanced users, the comments are relatively unnecessary. I think it would be useful to explain precisely what the method does. As a new user, when you see the `into` method, where the type is inferred, if you are new you don't even know what you convert to, because it is implicit. I believe this can help new users understand.
2 parents 355d878 + edee46e commit 9725caf

File tree

1 file changed

+4
-4
lines changed
  • library/core/src/convert

1 file changed

+4
-4
lines changed

Diff for: library/core/src/convert/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ pub const fn identity<T>(x: T) -> T {
154154
#[stable(feature = "rust1", since = "1.0.0")]
155155
#[cfg_attr(not(test), rustc_diagnostic_item = "AsRef")]
156156
pub trait AsRef<T: ?Sized> {
157-
/// Performs the conversion.
157+
/// Converts this type into a shared reference of the (usually inferred) input type.
158158
#[stable(feature = "rust1", since = "1.0.0")]
159159
fn as_ref(&self) -> &T;
160160
}
@@ -196,7 +196,7 @@ pub trait AsRef<T: ?Sized> {
196196
#[stable(feature = "rust1", since = "1.0.0")]
197197
#[cfg_attr(not(test), rustc_diagnostic_item = "AsMut")]
198198
pub trait AsMut<T: ?Sized> {
199-
/// Performs the conversion.
199+
/// Converts this type into a mutable reference of the (usually inferred) input type.
200200
#[stable(feature = "rust1", since = "1.0.0")]
201201
fn as_mut(&mut self) -> &mut T;
202202
}
@@ -272,7 +272,7 @@ pub trait AsMut<T: ?Sized> {
272272
#[rustc_diagnostic_item = "Into"]
273273
#[stable(feature = "rust1", since = "1.0.0")]
274274
pub trait Into<T>: Sized {
275-
/// Performs the conversion.
275+
/// Converts this type into the (usually inferred) input type.
276276
#[must_use]
277277
#[stable(feature = "rust1", since = "1.0.0")]
278278
fn into(self) -> T;
@@ -367,7 +367,7 @@ pub trait Into<T>: Sized {
367367
note = "to coerce a `{T}` into a `{Self}`, use `&*` as a prefix",
368368
))]
369369
pub trait From<T>: Sized {
370-
/// Performs the conversion.
370+
/// Converts to this type from the input type.
371371
#[lang = "from"]
372372
#[must_use]
373373
#[stable(feature = "rust1", since = "1.0.0")]

0 commit comments

Comments
 (0)