docs: document all public items in rust codebase (#2058)
Some checks failed
tinymist::auto_tag / auto-tag (push) Has been cancelled
tinymist::ci / Duplicate Actions Detection (push) Has been cancelled
tinymist::ci / Check Clippy, Formatting, Completion, Documentation, and Tests (Linux) (push) Has been cancelled
tinymist::ci / Check Minimum Rust version and Tests (Windows) (push) Has been cancelled
tinymist::ci / prepare-build (push) Has been cancelled
tinymist::gh_pages / build-gh-pages (push) Has been cancelled
tinymist::ci / announce (push) Has been cancelled
tinymist::ci / build (push) Has been cancelled

This commit is contained in:
Myriad-Dreamin 2025-08-21 12:50:03 +08:00 committed by GitHub
parent 4ce0a59862
commit 532f25abe9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
75 changed files with 1429 additions and 533 deletions

View file

@ -397,7 +397,6 @@ impl<T, E: std::fmt::Display> WithContextUntyped<T> for Result<T, E> {
/// The error prelude.
pub mod prelude {
#![allow(missing_docs)]
use super::ErrKindExt;
use crate::Error;
@ -405,22 +404,27 @@ pub mod prelude {
pub use super::{IgnoreLogging, WithContext, WithContextUntyped};
pub use crate::{Result, bail};
/// Maps the given string error to an error.
pub fn map_string_err<T: ToString>(loc: &'static str) -> impl Fn(T) -> Error {
move |e| Error::new(loc, e.to_string().to_error_kind(), None)
}
/// Maps the given error to an error.
pub fn map_into_err<S: ErrKindExt, T: Into<S>>(loc: &'static str) -> impl Fn(T) -> Error {
move |e| Error::new(loc, e.into().to_error_kind(), None)
}
/// Maps the given error to an error.
pub fn map_err<T: ErrKindExt>(loc: &'static str) -> impl Fn(T) -> Error {
move |e| Error::new(loc, e.to_error_kind(), None)
}
/// Wraps the given error.
pub fn wrap_err(loc: &'static str) -> impl Fn(Error) -> Error {
move |e| Error::new(loc, crate::ErrKind::Inner(e), None)
}
/// Maps the given string error to an error with arguments.
pub fn map_string_err_with_args<
T: ToString,
Args: IntoIterator<Item = (&'static str, String)>,
@ -437,6 +441,7 @@ pub mod prelude {
}
}
/// Maps the given error to an error with arguments.
pub fn map_into_err_with_args<
S: ErrKindExt,
T: Into<S>,
@ -454,6 +459,7 @@ pub mod prelude {
}
}
/// Maps the given error to an error with arguments.
pub fn map_err_with_args<T: ErrKindExt, Args: IntoIterator<Item = (&'static str, String)>>(
loc: &'static str,
args: Args,
@ -467,6 +473,7 @@ pub mod prelude {
}
}
/// Wraps the given error with arguments.
pub fn wrap_err_with_args<Args: IntoIterator<Item = (&'static str, String)>>(
loc: &'static str,
args: Args,
@ -480,16 +487,20 @@ pub mod prelude {
}
}
/// Creates an error with arguments.
pub fn _error_once(loc: &'static str, args: Box<[(&'static str, String)]>) -> Error {
Error::new(loc, crate::ErrKind::None, Some(args))
}
/// Creates an error with a message.
pub fn _msg(loc: &'static str, msg: EcoString) -> Error {
Error::new(loc, crate::ErrKind::Msg(msg), None)
}
/// Formats a string.
pub use ecow::eco_format as _eco_format;
/// Bails with the given arguments.
#[macro_export]
macro_rules! bail {
($($arg:tt)+) => {{
@ -498,6 +509,7 @@ pub mod prelude {
}};
}
/// Creates an error with a message.
#[macro_export]
macro_rules! error_once {
($loc:expr, $($arg_key:ident: $arg:expr),+ $(,)?) => {
@ -508,6 +520,7 @@ pub mod prelude {
};
}
/// Maps the given error to an error with arguments.
#[macro_export]
macro_rules! error_once_map {
($loc:expr, $($arg_key:ident: $arg:expr),+ $(,)?) => {
@ -518,6 +531,7 @@ pub mod prelude {
};
}
/// Maps the given string error to an error with arguments.
#[macro_export]
macro_rules! error_once_map_string {
($loc:expr, $($arg_key:ident: $arg:expr),+ $(,)?) => {