-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add missing examples for panicking objects #38123
Conversation
#[stable(feature = "panic_hooks", since = "1.10.0")] | ||
pub fn location(&self) -> Option<&Location> { | ||
Some(&self.location) | ||
} | ||
} | ||
|
||
/// A struct containing information about the location of a panic. | ||
/// | ||
/// You can get this object by using the [`location()`] method from the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
method of the
@@ -159,6 +159,22 @@ pub fn take_hook() -> Box<Fn(&PanicInfo) + 'static + Sync + Send> { | |||
} | |||
|
|||
/// A struct providing information about a panic. | |||
/// | |||
/// You can get this object from the [`set_hook()`] function. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Firstly this statement sounds like something that might get out of date quickly once we start adding more functions related to PanicInfo.
Secondly, I feel like phrasing of this could be improved. For example:
An instance of
PanicInfo
is passed to a panic hook set byset_hook()
or
PanicInfo
is an argument to the panic hook (seeset_hook()
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Firstly this statement sounds like something that might get out of date quickly once we start adding more functions related to PanicInfo.
Even if more methods related to PanicInfo
get added in the future, it doesn't mean this comment will be inaccurate. I also don't think it's a huge task to update this comment once that happens.
Secondly, I feel like phrasing of this could be improved. For example:
...
Agreed, I like your examples. 👍
#[stable(feature = "panic_hooks", since = "1.10.0")] | ||
pub fn location(&self) -> Option<&Location> { | ||
Some(&self.location) | ||
} | ||
} | ||
|
||
/// A struct containing information about the location of a panic. | ||
/// | ||
/// You can get this object by using the [`location()`] method from the | ||
/// [`PanicInfo`] object. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rust doesn't have 'objects', so this should be 'struct' or 'structure'.
561d190
to
62e1e58
Compare
Updated. |
@@ -159,6 +159,23 @@ pub fn take_hook() -> Box<Fn(&PanicInfo) + 'static + Sync + Send> { | |||
} | |||
|
|||
/// A struct providing information about a panic. | |||
/// | |||
/// `PanicInfo` object is passed to a panic hook set by the [`set_hook()`] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment also applies here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah damn.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It still says 'object' in the latest push
#[stable(feature = "panic_hooks", since = "1.10.0")] | ||
pub fn location(&self) -> Option<&Location> { | ||
Some(&self.location) | ||
} | ||
} | ||
|
||
/// A struct containing information about the location of a panic. | ||
/// | ||
/// You can get a `Location` by using the [`location()`] method of the | ||
/// [`PanicInfo`] structure. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I consider 'you' to be informal and it doesn't seem necessary to directly address the reader when we can just write:
This structure is created by the [`location()`] method on [`PanicInfo`].
62e1e58
to
f2e83ba
Compare
f2e83ba
to
d9b5ae9
Compare
Updated (and for good this time!). |
@bors r+ rollup |
📌 Commit d9b5ae9 has been approved by |
Add missing examples for panicking objects r? @frewsxcv
r? @frewsxcv