mirror of
https://gitee.com/openharmony/third_party_rust_either
synced 2024-11-23 06:59:40 +00:00
DOC: Add readme for crates.io and update docs
This commit is contained in:
parent
b9d79aa014
commit
1d1398857f
@ -6,13 +6,11 @@ authors = ["bluss"]
|
||||
license = "MIT/Apache-2.0"
|
||||
repository = "https://github.com/bluss/either"
|
||||
documentation = "https://docs.rs/either/1/"
|
||||
readme = "README-crates.io.md"
|
||||
|
||||
description = """
|
||||
The enum `Either`, with variants `Left` and `Right` and trait implementations including Iterator, Read, Write.
|
||||
|
||||
Either has methods that are similar to Option and Result.
|
||||
|
||||
Includes convenience macros `try_left!()` and `try_right!()` to use for short-circuiting logic."""
|
||||
The enum [`Either`] with variants `Left` and `Right` is a general purpose sum type with two cases.
|
||||
"""
|
||||
|
||||
keywords = ["data-structure", "no_std"]
|
||||
categories = ["data-structures", "no-std"]
|
||||
|
10
README-crates.io.md
Normal file
10
README-crates.io.md
Normal file
@ -0,0 +1,10 @@
|
||||
The enum `Either` with variants `Left` and `Right` is a general purpose
|
||||
sum type with two cases.
|
||||
|
||||
Either has methods that are similar to Option and Result, and it also implements
|
||||
traits like `Iterator`.
|
||||
|
||||
Includes macros `try_left!()` and `try_right!()` to use for
|
||||
short-circuiting logic, similar to how the `?` operator is used with `Result`.
|
||||
Note that `Either` is general purpose. For describing success or error, use the
|
||||
regular `Result`.
|
14
src/lib.rs
14
src/lib.rs
@ -1,4 +1,7 @@
|
||||
//! The enum [**Either**](enum.Either.html).
|
||||
//! The enum [`Either`] with variants `Left` and `Right` is a general purpose
|
||||
//! sum type with two cases.
|
||||
//!
|
||||
//! [`Either`]: enum.Either.html
|
||||
//!
|
||||
//! **Crate features:**
|
||||
//!
|
||||
@ -30,11 +33,12 @@ use std::error::Error;
|
||||
|
||||
pub use Either::{Left, Right};
|
||||
|
||||
/// `Either` represents an alternative holding one value out of
|
||||
/// either of the two possible values.
|
||||
/// The enum `Either` with variants `Left` and `Right` is a general purpose
|
||||
/// sum type with two cases.
|
||||
///
|
||||
/// `Either` is a general purpose sum type of two parts. For representing
|
||||
/// success or error, use the regular `Result<T, E>` instead.
|
||||
/// The `Either` type is symmetric and treats its variants the same way, without
|
||||
/// preference.
|
||||
/// (For representing success or error, use the regular `Result` enum instead.)
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
||||
pub enum Either<L, R> {
|
||||
|
Loading…
Reference in New Issue
Block a user