Skip to content

Commit

Permalink
Rollup merge of #92748 - david-perez:eliminate-boxed-wording-std-erro…
Browse files Browse the repository at this point in the history
…r, r=Mark-Simulacrum

Eliminate "boxed" wording in `std::error::Error` documentation

In commit 29403ee, documentation for the methods on `std::any::Any` was
modified so that they referred to the concrete value behind the trait
object as the "inner" value. This is a more accurate wording than
"boxed": while putting trait objects inside boxes is arguably the most
common use, they can also be placed behind other pointer types like
`&mut` or `std::sync::Arc`.

This commit does the same documentation changes for `std::error::Error`.
  • Loading branch information
matthiaskrgr committed Jan 12, 2022
2 parents bc0a165 + 5786bbd commit 286bb18
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions library/std/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -606,21 +606,21 @@ impl Error for time::FromSecsError {}

// Copied from `any.rs`.
impl dyn Error + 'static {
/// Returns `true` if the boxed type is the same as `T`
/// Returns `true` if the inner type is the same as `T`.
#[stable(feature = "error_downcast", since = "1.3.0")]
#[inline]
pub fn is<T: Error + 'static>(&self) -> bool {
// Get `TypeId` of the type this function is instantiated with.
let t = TypeId::of::<T>();

// Get `TypeId` of the type in the trait object.
let boxed = self.type_id(private::Internal);
// Get `TypeId` of the type in the trait object (`self`).
let concrete = self.type_id(private::Internal);

// Compare both `TypeId`s on equality.
t == boxed
t == concrete
}

/// Returns some reference to the boxed value if it is of type `T`, or
/// Returns some reference to the inner value if it is of type `T`, or
/// `None` if it isn't.
#[stable(feature = "error_downcast", since = "1.3.0")]
#[inline]
Expand All @@ -632,7 +632,7 @@ impl dyn Error + 'static {
}
}

/// Returns some mutable reference to the boxed value if it is of type `T`, or
/// Returns some mutable reference to the inner value if it is of type `T`, or
/// `None` if it isn't.
#[stable(feature = "error_downcast", since = "1.3.0")]
#[inline]
Expand Down

0 comments on commit 286bb18

Please sign in to comment.