Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jarvisjiang committed Jul 13, 2024
1 parent 82bfb94 commit fb0d513
Show file tree
Hide file tree
Showing 13 changed files with 392 additions and 404 deletions.
8 changes: 4 additions & 4 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
## Interfaces

| Interface | Description |
| :------ | :------ |
| ------ | ------ |
| [None](interfaces/None.md) | Represents the absence of a value, as a specialized `Option` type. The type parameter is set to `never` because `None` does not hold a value. |
| [Option](interfaces/Option.md) | Type `Option` represents an optional value: every `Option` is either `Some` and contains a value, or `None`, and does not. This interface includes methods that act on the `Option` type, similar to Rust's `Option` enum. |
| [Result](interfaces/Result.md) | The `Result` type is used for returning and propagating errors. It is an enum with the variants, `Ok(T)`, representing success and containing a value, and `Err(E)`, representing error and containing an error value. This interface includes methods that act on the `Result` type, similar to Rust's `Result` enum. |

## Type Aliases

| Type alias | Description |
| :------ | :------ |
| ------ | ------ |
| [AsyncIOResult](type-aliases/AsyncIOResult.md) | Represents an asynchronous I/O operation that yields a `Result<T, Error>`. This is a promise that resolves to `Ok(T)` if the I/O operation was successful, or `Err(Error)` if there was an error. |
| [AsyncOption](type-aliases/AsyncOption.md) | Represents an asynchronous operation that yields an `Option<T>`. This is a promise that resolves to either `Some(T)` if the value is present, or `None` if the value is absent. |
| [AsyncResult](type-aliases/AsyncResult.md) | Represents an asynchronous operation that yields a `Result<T, E>`. This is a promise that resolves to `Ok(T)` if the operation was successful, or `Err(E)` if there was an error. |
Expand All @@ -24,13 +24,13 @@
## Variables

| Variable | Description |
| :------ | :------ |
| ------ | ------ |
| [None](variables/None.md) | A constant representing the `None` case of an `Option`, indicating the absence of a value. This constant is frozen to ensure it is immutable and cannot be altered, preserving the integrity of `None` throughout the application. |

## Functions

| Function | Description |
| :------ | :------ |
| ------ | ------ |
| [Err](functions/Err.md) | Creates a `Result<T, E>` representing a failed outcome containing an error. This function is used to construct a `Result` that signifies the operation failed by containing the error `E`. |
| [Ok](functions/Ok.md) | Creates a `Result<T, E>` representing a successful outcome containing a value. This function is used to construct a `Result` that signifies the operation was successful by containing the value `T`. |
| [Some](functions/Some.md) | Creates an `Option<T>` representing the presence of a value. This function is typically used to construct an `Option` that contains a value, indicating that the operation yielding the value was successful. |
Expand Down
12 changes: 6 additions & 6 deletions docs/functions/Err.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ function Err<T, E>(error): Result<T, E>
Creates a `Result<T, E>` representing a failed outcome containing an error.
This function is used to construct a `Result` that signifies the operation failed by containing the error `E`.

## Type parameters
## Type Parameters

| Type parameter | Description |
| :------ | :------ |
| Type Parameter | Description |
| ------ | ------ |
| `T` | The type of the value that the result could potentially contain (not used in this case). |
| `E` | The type of the error to be wrapped in the `Err` result. |

## Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| ------ | ------ | ------ |
| `error` | `E` | The error to wrap as an `Err` result. |

## Returns
Expand All @@ -41,6 +41,6 @@ if (badResult.isErr()) {
}
```

## Source
## Defined in

[enum/prelude.ts:855](https://github.com/JiangJie/happy-rusty/blob/d102b1cddf6a12ecdb610e0f92d003cc7e0015ee/src/enum/prelude.ts#L855)
[prelude.ts:853](https://github.com/JiangJie/happy-rusty/blob/82bfb94138be23b97750c830432d7e013c0e5b80/src/enum/prelude.ts#L853)
12 changes: 6 additions & 6 deletions docs/functions/Ok.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ function Ok<T, E>(value): Result<T, E>
Creates a `Result<T, E>` representing a successful outcome containing a value.
This function is used to construct a `Result` that signifies the operation was successful by containing the value `T`.

## Type parameters
## Type Parameters

| Type parameter | Description |
| :------ | :------ |
| Type Parameter | Description |
| ------ | ------ |
| `T` | The type of the value to be contained in the `Ok` result. |
| `E` | The type of the error that the result could potentially contain (not used in this case). |

## Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| ------ | ------ | ------ |
| `value` | `T` | The value to wrap as an `Ok` result. |

## Returns
Expand All @@ -41,6 +41,6 @@ if (goodResult.isOk()) {
}
```

## Source
## Defined in

[enum/prelude.ts:776](https://github.com/JiangJie/happy-rusty/blob/d102b1cddf6a12ecdb610e0f92d003cc7e0015ee/src/enum/prelude.ts#L776)
[prelude.ts:774](https://github.com/JiangJie/happy-rusty/blob/82bfb94138be23b97750c830432d7e013c0e5b80/src/enum/prelude.ts#L774)
12 changes: 6 additions & 6 deletions docs/functions/Some.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ function Some<T>(value): Option<T>
Creates an `Option<T>` representing the presence of a value.
This function is typically used to construct an `Option` that contains a value, indicating that the operation yielding the value was successful.

## Type parameters
## Type Parameters

| Type parameter | Description |
| :------ | :------ |
| Type Parameter | Description |
| ------ | ------ |
| `T` | The type of the value to be wrapped in a `Some`. |

## Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| ------ | ------ | ------ |
| `value` | `T` | The value to wrap as a `Some` option. |

## Returns
Expand All @@ -40,6 +40,6 @@ if (maybeValue.isSome()) {
}
```

## Source
## Defined in

[enum/prelude.ts:627](https://github.com/JiangJie/happy-rusty/blob/d102b1cddf6a12ecdb610e0f92d003cc7e0015ee/src/enum/prelude.ts#L627)
[prelude.ts:625](https://github.com/JiangJie/happy-rusty/blob/82bfb94138be23b97750c830432d7e013c0e5b80/src/enum/prelude.ts#L625)
12 changes: 6 additions & 6 deletions docs/functions/promiseToResult.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ function promiseToResult<T, E>(p): Promise<Result<T, E>>
Converts a Promise to a Result type, capturing the resolved value in an `Ok`, or the error in an `Err`.
This allows for promise-based asynchronous operations to be handled in a way that is more in line with the Result pattern.

## Type parameters
## Type Parameters

| Type parameter | Value | Description |
| :------ | :------ | :------ |
| Type Parameter | Default type | Description |
| ------ | ------ | ------ |
| `T` | - | The type of the value that the promise resolves to. |
| `E` | `Error` | The type of the error that the promise may reject with, defaults to `Error`. |

## Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| ------ | ------ | ------ |
| `p` | `Promise`\<`T`\> | The promise to convert into a `Result` type. |

## Returns
Expand All @@ -45,6 +45,6 @@ async function example() {
}
```

## Source
## Defined in

[enum/prelude.ts:959](https://github.com/JiangJie/happy-rusty/blob/d102b1cddf6a12ecdb610e0f92d003cc7e0015ee/src/enum/prelude.ts#L959)
[prelude.ts:957](https://github.com/JiangJie/happy-rusty/blob/82bfb94138be23b97750c830432d7e013c0e5b80/src/enum/prelude.ts#L957)
Loading

0 comments on commit fb0d513

Please sign in to comment.