Merge branch 'main' into stream-git-statuses
This commit is contained in:
commit
28ba27c9c5
206 changed files with 5946 additions and 3086 deletions
|
@ -7,8 +7,10 @@ pub mod paths;
|
|||
pub mod test;
|
||||
|
||||
use std::{
|
||||
borrow::Cow,
|
||||
cmp::{self, Ordering},
|
||||
ops::{AddAssign, Range, RangeInclusive},
|
||||
panic::Location,
|
||||
pin::Pin,
|
||||
task::{Context, Poll},
|
||||
};
|
||||
|
@ -129,11 +131,13 @@ where
|
|||
{
|
||||
type Ok = T;
|
||||
|
||||
#[track_caller]
|
||||
fn log_err(self) -> Option<T> {
|
||||
match self {
|
||||
Ok(value) => Some(value),
|
||||
Err(error) => {
|
||||
log::error!("{:?}", error);
|
||||
let caller = Location::caller();
|
||||
log::error!("{}:{}: {:?}", caller.file(), caller.line(), error);
|
||||
None
|
||||
}
|
||||
}
|
||||
|
@ -281,6 +285,14 @@ impl<T: Rng> Iterator for RandomCharIter<T> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Get an embedded file as a string.
|
||||
pub fn asset_str<A: rust_embed::RustEmbed>(path: &str) -> Cow<'static, str> {
|
||||
match A::get(path).unwrap().data {
|
||||
Cow::Borrowed(bytes) => Cow::Borrowed(std::str::from_utf8(bytes).unwrap()),
|
||||
Cow::Owned(bytes) => Cow::Owned(String::from_utf8(bytes).unwrap()),
|
||||
}
|
||||
}
|
||||
|
||||
// copy unstable standard feature option unzip
|
||||
// https://github.com/rust-lang/rust/issues/87800
|
||||
// Remove when this ship in Rust 1.66 or 1.67
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue