Skip to content

Commit

Permalink
Update sway-lib-core to meet SRC-2 inline docs standard (#4882)
Browse files Browse the repository at this point in the history
## Description

This completes the never.sw, ops.sw, primitives.sw, and
primitive_conversions.sw tasks of
#4812

## Checklist

- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.

---------

Co-authored-by: bitzoic <bitzoic.eth@gmail.com>
  • Loading branch information
bitzoic and bitzoic authored Aug 5, 2023
1 parent 3462264 commit 33f17e7
Show file tree
Hide file tree
Showing 5 changed files with 1,278 additions and 4 deletions.
19 changes: 16 additions & 3 deletions sway-lib-core/src/never.sw
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ use ::ops::{Eq, Not, Ord};

/// `Never` represents the type of computations which never resolve to any value at all.
///
/// # Additional Information
///
/// `break`, `continue` and `return` expressions also have type `Never`. For example we are allowed to
/// write:
///
/// ```
/// ```sway
/// let x: Never = {
/// return 123
/// };
Expand All @@ -20,7 +22,7 @@ use ::ops::{Eq, Not, Ord};
///
/// A more realistic usage of `Never` is in this code:
///
/// ```
/// ```sway
/// let num: u32 = match get_a_number() {
/// Some(num) => num,
/// None => break,
Expand All @@ -33,13 +35,24 @@ use ::ops::{Eq, Not, Ord};
///
/// Note that `Never` type coerces into any other type, another example of this would be:
///
/// ```
/// ```sway
/// let x: u32 = {
/// return 123
/// };
/// ```
///
/// Regardless of the type of `x`, the return block of type `Never` will always coerce into `x` type.
///
/// # Examples
///
/// ```sway
/// fn foo() {
/// let num: u64 = match Option::None::<u64> {
/// Some(num) => num,
/// None => return,
/// };
/// }
/// ```
pub enum Never {}

impl Not for Never {
Expand Down
Loading

0 comments on commit 33f17e7

Please sign in to comment.