Skip to content

Commit

Permalink
Improve Never documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
webmaster128 committed Nov 24, 2022
1 parent ce9d90a commit f7faa61
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/std/src/never.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,23 @@
/// where we want to ensure that no error is returned, such as
/// the `ibc_packet_receive` entry point.
///
/// In contrast to `Empty`, this does not have a JSON schema
/// and cannot be used for message and query types.
///
/// Once the ! type is stable, this is not needed anymore.
/// See <https://github.com/rust-lang/rust/issues/35121>.
pub enum Never {}

// The Debug implementation is needed to allow the use of `Result::unwrap`.
impl core::fmt::Debug for Never {
fn fmt(&self, _f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
// This is unreachable because no instance of Never can exist
unreachable!()
}
}

// The Display implementation is needed to fulfill the ToString requirement of
// entry point errors: `Result<IbcReceiveResponse<C>, E>` with `E: ToString`.
impl core::fmt::Display for Never {
fn fmt(&self, _f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
// This is unreachable because no instance of Never can exist
Expand Down

0 comments on commit f7faa61

Please sign in to comment.