mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
deps: update Rust crates for V8 14.6.202.34-node.40
PR-URL: https://github.com/nodejs/node/pull/67474 Fixes: https://github.com/nodejs/node/issues/67457 Reviewed-By: LiviaMedeiros <livia@cirno.name> Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
This commit is contained in:
1 parent
07cb738977
commit
c87bb324f3
183 files changed
+2969
-3105
No files matched your search
+16
-15
@@ -4,7 +4,7 @@ version = 4
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.5.0"
|
||||
version = "1.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
@@ -37,7 +37,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "diplomat-runtime"
|
||||
version = "0.15.0"
|
||||
version = "0.15.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
@@ -55,7 +55,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "displaydoc"
|
||||
version = "0.2.5"
|
||||
version = "0.2.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
@@ -146,7 +146,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ixdtf"
|
||||
version = "0.6.4"
|
||||
version = "0.6.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
@@ -156,13 +156,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "litemap"
|
||||
version = "0.8.1"
|
||||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "node_crates"
|
||||
version = "14.6.202"
|
||||
dependencies = [
|
||||
"icu_locale",
|
||||
"icu_locale_core",
|
||||
"icu_provider",
|
||||
"syn",
|
||||
@@ -180,7 +181,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "potential_utf"
|
||||
version = "0.1.4"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"serde_core",
|
||||
@@ -198,7 +199,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.45"
|
||||
version = "1.0.46"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
@@ -242,7 +243,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "smallvec"
|
||||
version = "1.15.1"
|
||||
version = "1.15.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
@@ -260,7 +261,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.117"
|
||||
version = "2.0.118"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
@@ -280,7 +281,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "temporal_capi"
|
||||
version = "0.2.3"
|
||||
version = "0.2.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"diplomat",
|
||||
@@ -296,7 +297,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "temporal_rs"
|
||||
version = "0.2.3"
|
||||
version = "0.2.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"calendrical_calculations",
|
||||
@@ -343,12 +344,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "writeable"
|
||||
version = "0.6.2"
|
||||
version = "0.6.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "yoke"
|
||||
version = "0.8.2"
|
||||
version = "0.8.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"stable_deref_trait",
|
||||
@@ -369,7 +370,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "zerofrom"
|
||||
version = "0.1.6"
|
||||
version = "0.1.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"zerofrom-derive",
|
||||
@@ -377,7 +378,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "zerofrom-derive"
|
||||
version = "0.1.6"
|
||||
version = "0.1.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
|
||||
Vendored
+7
-2
@@ -9,6 +9,11 @@ rust-version = "1.86"
|
||||
[lib]
|
||||
crate-type = [ "staticlib" ]
|
||||
|
||||
[dependencies.icu_locale]
|
||||
version = "2.2.0"
|
||||
default-features = false
|
||||
features = [ "compiled_data" ]
|
||||
|
||||
[dependencies.icu_locale_core]
|
||||
version = "2.2.0"
|
||||
default-features = false
|
||||
@@ -22,10 +27,10 @@ version = "2"
|
||||
features = [ "full" ]
|
||||
|
||||
[dependencies.temporal_capi]
|
||||
version = "0.2.3"
|
||||
version = "0.2.4"
|
||||
features = [ "zoneinfo64" ]
|
||||
|
||||
[dependencies.temporal_rs]
|
||||
version = "0.2.3"
|
||||
version = "0.2.4"
|
||||
default-features = false
|
||||
features = [ "float64_representable_durations" ]
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"git": {
|
||||
"sha1": "d912169ed67977efe5a465269b0e73cb66060c49"
|
||||
"sha1": "2799b09c24e6632f8e653c5cd8fc303e85a906ba"
|
||||
},
|
||||
"path_in_vcs": ""
|
||||
}
|
||||
+1
-1
@@ -2,5 +2,5 @@
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.5.0"
|
||||
version = "1.5.1"
|
||||
|
||||
+2
-3
@@ -12,7 +12,7 @@
|
||||
[package]
|
||||
rust-version = "1.0"
|
||||
name = "autocfg"
|
||||
version = "1.5.0"
|
||||
version = "1.5.1"
|
||||
authors = ["Josh Stone <cuviper@gmail.com>"]
|
||||
build = false
|
||||
exclude = ["/.github/**"]
|
||||
@@ -72,5 +72,4 @@ path = "tests/tests.rs"
|
||||
[[test]]
|
||||
name = "wrappers"
|
||||
path = "tests/wrappers.rs"
|
||||
|
||||
[dependencies]
|
||||
harness = false
|
||||
+13
-2
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "autocfg"
|
||||
version = "1.5.0"
|
||||
version = "1.5.1"
|
||||
authors = ["Josh Stone <cuviper@gmail.com>"]
|
||||
license = "Apache-2.0 OR MIT"
|
||||
repository = "https://github.com/cuviper/autocfg"
|
||||
@@ -12,4 +12,15 @@ categories = ["development-tools::build-utils"]
|
||||
exclude = ["/.github/**"]
|
||||
rust-version = "1.0"
|
||||
|
||||
[dependencies]
|
||||
[[test]]
|
||||
name = "no_std"
|
||||
|
||||
[[test]]
|
||||
name = "rustflags"
|
||||
|
||||
[[test]]
|
||||
name = "tests"
|
||||
|
||||
[[test]]
|
||||
name = "wrappers"
|
||||
harness = false
|
||||
+4
@@ -43,6 +43,10 @@ should only be used when the compiler supports it.
|
||||
|
||||
## Release Notes
|
||||
|
||||
- 1.5.1 (2026-05-22)
|
||||
|
||||
- Refactor the `test_wrappers` test without any shell script.
|
||||
|
||||
- 1.5.0 (2025-06-17)
|
||||
|
||||
- Add `edition` and `set_edition` to control the Rust edition used in probes.
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
for arg in "$@"; do
|
||||
case "$arg" in
|
||||
# Add our own version so we can check that the wrapper is used for that.
|
||||
"--version") echo "release: 12345.6789.0" ;;
|
||||
# Read all input so the writer doesn't get EPIPE when we exit.
|
||||
"-") read -d "" PROBE ;;
|
||||
esac
|
||||
done
|
||||
|
||||
exit 0
|
||||
+31
-4
@@ -1,13 +1,39 @@
|
||||
extern crate autocfg;
|
||||
|
||||
use std::env;
|
||||
use std::io;
|
||||
|
||||
mod support;
|
||||
|
||||
fn main() {
|
||||
let args: Vec<_> = env::args().skip(1).collect();
|
||||
if args.is_empty() {
|
||||
// With no arguments, this must be a (harness-free) test run.
|
||||
// (we're using system binaries as wrappers, so ignore other platforms)
|
||||
if cfg!(unix) {
|
||||
test_wrappers();
|
||||
}
|
||||
} else {
|
||||
// Otherwise we're acting like a no-op rustc wrapper, ignoring almost everything.
|
||||
for arg in args {
|
||||
match &*arg {
|
||||
// Add our own version so we can check that the wrapper is used for that.
|
||||
"--version" => println!("release: 12345.6789.0"),
|
||||
|
||||
// Read all input so the writer doesn't get EPIPE when we exit.
|
||||
"-" => {
|
||||
let stdin = io::stdin();
|
||||
let _ = io::copy(&mut stdin.lock(), &mut io::sink());
|
||||
}
|
||||
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Tests that autocfg uses the RUSTC_WRAPPER and/or RUSTC_WORKSPACE_WRAPPER
|
||||
/// environment variables when running rustc.
|
||||
#[test]
|
||||
#[cfg(unix)] // we're using system binaries as wrappers
|
||||
fn test_wrappers() {
|
||||
fn set(name: &str, value: Option<bool>) {
|
||||
match value {
|
||||
@@ -45,8 +71,9 @@ fn test_wrappers() {
|
||||
}
|
||||
|
||||
// Finally, make sure that `RUSTC_WRAPPER` is applied outermost
|
||||
// by using something that doesn't pass through at all.
|
||||
env::set_var("RUSTC_WRAPPER", "./tests/wrap_ignored");
|
||||
// by using something (ourself) that doesn't pass through at all.
|
||||
let wrap_ignored = env::current_exe().unwrap();
|
||||
env::set_var("RUSTC_WRAPPER", &wrap_ignored);
|
||||
env::set_var("RUSTC_WORKSPACE_WRAPPER", "/bin/false");
|
||||
let ac = autocfg::AutoCfg::with_dir(out.as_ref()).unwrap();
|
||||
assert!(ac.probe_type("mesize")); // anything goes!
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"git": {
|
||||
"sha1": "6559f95efa34658b9e801b45e39f1b306c32e249"
|
||||
"sha1": "95557babd58cf90e65c6175e7b9433f41f686bd2"
|
||||
},
|
||||
"path_in_vcs": "runtime"
|
||||
}
|
||||
+1
-1
@@ -26,7 +26,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "diplomat-runtime"
|
||||
version = "0.15.0"
|
||||
version = "0.15.1"
|
||||
dependencies = [
|
||||
"jni",
|
||||
"log",
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@
|
||||
edition = "2021"
|
||||
rust-version = "1.81"
|
||||
name = "diplomat-runtime"
|
||||
version = "0.15.0"
|
||||
version = "0.15.1"
|
||||
authors = [
|
||||
"Shadaj Laddad <shadaj@users.noreply.github.com>",
|
||||
"Manish Goregaokar <manishsmail@gmail.com>",
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "diplomat-runtime"
|
||||
description = "Common runtime utilities used by diplomat codegen"
|
||||
version.workspace = true
|
||||
version = "0.15.1"
|
||||
rust-version.workspace = true
|
||||
authors.workspace = true
|
||||
categories.workspace = true
|
||||
|
||||
+22
-34
@@ -3,6 +3,23 @@
|
||||
//! This is a private module
|
||||
use alloc::format;
|
||||
|
||||
// https://blog.rust-lang.org/2026/04/04/changes-to-webassembly-targets-and-handling-undefined-symbols/#what-is-going-to-break-and-how-to-fix
|
||||
#[link(wasm_import_module = "env")]
|
||||
extern "C" {
|
||||
fn diplomat_throw_error_js(ptr: *const u8, len: usize);
|
||||
|
||||
#[cfg(feature = "log")]
|
||||
fn diplomat_console_error_js(ptr: *const u8, len: usize);
|
||||
#[cfg(feature = "log")]
|
||||
fn diplomat_console_warn_js(ptr: *const u8, len: usize);
|
||||
#[cfg(feature = "log")]
|
||||
fn diplomat_console_info_js(ptr: *const u8, len: usize);
|
||||
#[cfg(feature = "log")]
|
||||
fn diplomat_console_log_js(ptr: *const u8, len: usize);
|
||||
#[cfg(feature = "log")]
|
||||
fn diplomat_console_debug_js(ptr: *const u8, len: usize);
|
||||
}
|
||||
|
||||
/// In theory, this function may be useful for other backends eventually, but
|
||||
/// currently it is only useful in WASM so it is in this module.
|
||||
#[no_mangle]
|
||||
@@ -34,10 +51,6 @@ fn panic_handler(info: &std::panic::PanicHookInfo) {
|
||||
None => format!("wasm panicked at <unknown location>:\n{msg}"),
|
||||
};
|
||||
|
||||
extern "C" {
|
||||
fn diplomat_throw_error_js(ptr: *const u8, len: usize);
|
||||
}
|
||||
|
||||
unsafe { diplomat_throw_error_js(msg.as_ptr(), msg.len()) }
|
||||
}
|
||||
|
||||
@@ -57,36 +70,11 @@ impl log::Log for ConsoleLogger {
|
||||
}
|
||||
|
||||
let out = match record.level() {
|
||||
log::Level::Error => {
|
||||
extern "C" {
|
||||
fn diplomat_console_error_js(ptr: *const u8, len: usize);
|
||||
}
|
||||
diplomat_console_error_js
|
||||
}
|
||||
log::Level::Warn => {
|
||||
extern "C" {
|
||||
fn diplomat_console_warn_js(ptr: *const u8, len: usize);
|
||||
}
|
||||
diplomat_console_warn_js
|
||||
}
|
||||
log::Level::Info => {
|
||||
extern "C" {
|
||||
fn diplomat_console_info_js(ptr: *const u8, len: usize);
|
||||
}
|
||||
diplomat_console_info_js
|
||||
}
|
||||
log::Level::Debug => {
|
||||
extern "C" {
|
||||
fn diplomat_console_log_js(ptr: *const u8, len: usize);
|
||||
}
|
||||
diplomat_console_log_js
|
||||
}
|
||||
log::Level::Trace => {
|
||||
extern "C" {
|
||||
fn diplomat_console_debug_js(ptr: *const u8, len: usize);
|
||||
}
|
||||
diplomat_console_debug_js
|
||||
}
|
||||
log::Level::Error => diplomat_console_error_js,
|
||||
log::Level::Warn => diplomat_console_warn_js,
|
||||
log::Level::Info => diplomat_console_info_js,
|
||||
log::Level::Debug => diplomat_console_log_js,
|
||||
log::Level::Trace => diplomat_console_debug_js,
|
||||
};
|
||||
|
||||
let msg = alloc::format!("{}", record.args());
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"git": {
|
||||
"sha1": "e4028851bfb82998300237f7568a45f589a19e40"
|
||||
"sha1": "50d6f1fd371f61ef3b031d4f356420b7cbdf5d56"
|
||||
},
|
||||
"path_in_vcs": ""
|
||||
}
|
||||
@@ -1,120 +0,0 @@
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
schedule:
|
||||
- cron: '0 0 * * *'
|
||||
|
||||
name: Continuous integration
|
||||
|
||||
jobs:
|
||||
check:
|
||||
name: Check
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
rust:
|
||||
- stable
|
||||
- 1.56.0
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: ${{ matrix.rust }}
|
||||
override: true
|
||||
- uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: check
|
||||
|
||||
test:
|
||||
name: Test Suite
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
rust:
|
||||
- stable
|
||||
- nightly
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: ${{ matrix.rust }}
|
||||
override: true
|
||||
- uses: Swatinem/rust-cache@v1
|
||||
- name: Install cargo-nextest
|
||||
uses: baptiste0928/cargo-install@v1
|
||||
with:
|
||||
crate: cargo-nextest
|
||||
version: 0.9
|
||||
- uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: nextest
|
||||
args: run
|
||||
- uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: nextest
|
||||
args: run --no-default-features
|
||||
- uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: test
|
||||
args: --doc
|
||||
|
||||
test-msrv:
|
||||
name: msrv Test Suite
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
rust:
|
||||
- 1.56.0
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: ${{ matrix.rust }}
|
||||
override: true
|
||||
- uses: Swatinem/rust-cache@v1
|
||||
- uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: test
|
||||
- uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: test
|
||||
args: --no-default-features
|
||||
|
||||
fmt:
|
||||
name: Rustfmt
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
rust:
|
||||
- stable
|
||||
- 1.56.0
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: ${{ matrix.rust }}
|
||||
override: true
|
||||
- run: rustup component add rustfmt
|
||||
- uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: fmt
|
||||
args: --all -- --check
|
||||
|
||||
clippy:
|
||||
name: Clippy
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
rust:
|
||||
- stable
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: ${{ matrix.rust }}
|
||||
override: true
|
||||
- run: rustup component add clippy
|
||||
- uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: clippy
|
||||
args: -- -D warnings
|
||||
@@ -1,3 +0,0 @@
|
||||
/target
|
||||
**/*.rs.bk
|
||||
Cargo.lock
|
||||
+15
-2
@@ -6,7 +6,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
<!-- next-header -->
|
||||
|
||||
## [Unreleased] - ReleaseDate
|
||||
# [Unreleased] - ReleaseDate
|
||||
|
||||
# [0.2.6] - 2026-05-27
|
||||
|
||||
## Added
|
||||
- Support for multi-line doc comments (#57, #62)
|
||||
|
||||
## Changed
|
||||
- Use `BTreeMap` for determinism in generated code (#52)
|
||||
- Add `#[allow(unused_assignments)]` to generated code (#56)
|
||||
- Exclude development scripts from published package (#60)
|
||||
- Bump `pretty_assertions` dependency to 1.4.0 (#53)
|
||||
|
||||
# [0.2.5] - 2024-06-20
|
||||
|
||||
@@ -50,7 +61,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
lines are needed.
|
||||
|
||||
<!-- next-url -->
|
||||
[Unreleased]: https://github.com/yaahc/displaydoc/compare/v0.2.4...HEAD
|
||||
[Unreleased]: https://github.com/yaahc/displaydoc/compare/v0.2.6...HEAD
|
||||
[0.2.6]: https://github.com/yaahc/displaydoc/compare/v0.2.5...v0.2.6
|
||||
[0.2.5]: https://github.com/yaahc/displaydoc/compare/v0.2.4...v0.2.5
|
||||
[0.2.4]: https://github.com/yaahc/displaydoc/compare/v0.2.3...v0.2.4
|
||||
[0.2.3]: https://github.com/yaahc/displaydoc/compare/v0.2.2...v0.2.3
|
||||
[0.2.2]: https://github.com/yaahc/displaydoc/compare/v0.2.1...v0.2.2
|
||||
|
||||
+113
-208
@@ -3,33 +3,14 @@
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "ansi_term"
|
||||
version = "0.11.0"
|
||||
name = "diff"
|
||||
version = "0.1.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ctor"
|
||||
version = "0.1.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6d2301688392eb071b0bf1a37be05c469d3cc4dbbd95df672fe28ab021e6a096"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "difference"
|
||||
version = "2.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198"
|
||||
checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8"
|
||||
|
||||
[[package]]
|
||||
name = "displaydoc"
|
||||
version = "0.2.5"
|
||||
version = "0.2.6"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"pretty_assertions",
|
||||
@@ -37,34 +18,34 @@ dependencies = [
|
||||
"quote",
|
||||
"rustversion",
|
||||
"static_assertions",
|
||||
"syn 2.0.66",
|
||||
"syn",
|
||||
"thiserror",
|
||||
"trybuild",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "equivalent"
|
||||
version = "1.0.1"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
|
||||
checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
|
||||
|
||||
[[package]]
|
||||
name = "glob"
|
||||
version = "0.3.1"
|
||||
version = "0.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
|
||||
checksum = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280"
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.14.5"
|
||||
version = "0.16.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
|
||||
checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100"
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "2.2.6"
|
||||
version = "2.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26"
|
||||
checksum = "0ad4bb2b565bca0645f4d68c5c9af97fba094e9791da685bf83cb5f3ce74acf2"
|
||||
dependencies = [
|
||||
"equivalent",
|
||||
"hashbrown",
|
||||
@@ -72,111 +53,111 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "1.0.11"
|
||||
version = "1.0.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b"
|
||||
checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.155"
|
||||
version = "0.2.178"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c"
|
||||
checksum = "37c93d8daa9d8a012fd8ab92f088405fb202ea0b6ab73ee2482ae66af4f42091"
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.7.4"
|
||||
version = "2.7.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
|
||||
|
||||
[[package]]
|
||||
name = "output_vt100"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "628223faebab4e3e40667ee0b2336d34a5b960ff60ea743ddfdbcf7770bcfb66"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273"
|
||||
|
||||
[[package]]
|
||||
name = "pretty_assertions"
|
||||
version = "0.6.1"
|
||||
version = "1.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3f81e1644e1b54f5a68959a29aa86cde704219254669da328ecfdf6a1f09d427"
|
||||
checksum = "3ae130e2f271fbc2ac3a40fb1d07180839cdbbe443c7a27e1e3c13c5cac0116d"
|
||||
dependencies = [
|
||||
"ansi_term",
|
||||
"ctor",
|
||||
"difference",
|
||||
"output_vt100",
|
||||
"diff",
|
||||
"yansi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.85"
|
||||
version = "1.0.103"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23"
|
||||
checksum = "5ee95bc4ef87b8d5ba32e8b7714ccc834865276eab0aed5c9958d00ec45f49e8"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.36"
|
||||
version = "1.0.42"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7"
|
||||
checksum = "a338cc41d27e6cc6dce6cefc13a0729dfbb81c262b1f519331575dd80ef3067f"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustversion"
|
||||
version = "1.0.17"
|
||||
version = "1.0.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6"
|
||||
checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
|
||||
|
||||
[[package]]
|
||||
name = "ryu"
|
||||
version = "1.0.18"
|
||||
version = "1.0.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f"
|
||||
checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f"
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.203"
|
||||
version = "1.0.228"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094"
|
||||
checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
|
||||
dependencies = [
|
||||
"serde_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_core"
|
||||
version = "1.0.228"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.203"
|
||||
version = "1.0.228"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba"
|
||||
checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.66",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.117"
|
||||
version = "1.0.145"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3"
|
||||
checksum = "402a6f66d8c709116cf22f558eab210f5a50187f702eb4d7e5ef38d9a7f1c79c"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"memchr",
|
||||
"ryu",
|
||||
"serde",
|
||||
"serde_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_spanned"
|
||||
version = "0.6.6"
|
||||
version = "1.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "79e674e01f999af37c49f70a6ede167a8a60b2503e56c5599532a65baa5969a0"
|
||||
checksum = "e24345aa0fe688594e73770a5f6d1b216508b4f93484c0026d521acd30134392"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -187,9 +168,9 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.109"
|
||||
version = "2.0.111"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
|
||||
checksum = "390cc9a294ab71bdb1aa2e99d13be9c753cd2d7bd6560c77118597410c4d2e87"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -197,15 +178,10 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.66"
|
||||
name = "target-triple"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
checksum = "591ef38edfb78ca4771ee32cf494cb8771944bee237a9b91fc9c1424ac4b777b"
|
||||
|
||||
[[package]]
|
||||
name = "termcolor"
|
||||
@@ -218,187 +194,116 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.61"
|
||||
version = "1.0.69"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709"
|
||||
checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52"
|
||||
dependencies = [
|
||||
"thiserror-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror-impl"
|
||||
version = "1.0.61"
|
||||
version = "1.0.69"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533"
|
||||
checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.66",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "0.8.14"
|
||||
version = "0.9.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6f49eb2ab21d2f26bd6db7bf383edc527a7ebaee412d17af4d40fdccd442f335"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_spanned",
|
||||
"toml_datetime",
|
||||
"toml_edit",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_datetime"
|
||||
version = "0.6.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_edit"
|
||||
version = "0.22.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f21c7aaf97f1bd9ca9d4f9e73b0a6c74bd5afef56f2bc931943a6e1c37e04e38"
|
||||
checksum = "f0dc8b1fb61449e27716ec0e1bdf0f6b8f3e8f6b05391e8497b8b6d7804ea6d8"
|
||||
dependencies = [
|
||||
"indexmap",
|
||||
"serde",
|
||||
"serde_core",
|
||||
"serde_spanned",
|
||||
"toml_datetime",
|
||||
"toml_parser",
|
||||
"toml_writer",
|
||||
"winnow",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "trybuild"
|
||||
version = "1.0.96"
|
||||
name = "toml_datetime"
|
||||
version = "0.7.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "33a5f13f11071020bb12de7a16b925d2d58636175c20c11dc5f96cb64bb6c9b3"
|
||||
checksum = "f2cdb639ebbc97961c51720f858597f7f24c4fc295327923af55b74c3c724533"
|
||||
dependencies = [
|
||||
"serde_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_parser"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c0cbe268d35bdb4bb5a56a2de88d0ad0eb70af5384a99d648cd4b3d04039800e"
|
||||
dependencies = [
|
||||
"winnow",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_writer"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "df8b2b54733674ad286d16267dcfc7a71ed5c776e4ac7aa3c3e2561f7c637bf2"
|
||||
|
||||
[[package]]
|
||||
name = "trybuild"
|
||||
version = "1.0.114"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3e17e807bff86d2a06b52bca4276746584a78375055b6e45843925ce2802b335"
|
||||
dependencies = [
|
||||
"glob",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"serde_json",
|
||||
"target-triple",
|
||||
"termcolor",
|
||||
"toml",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.12"
|
||||
version = "1.0.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
|
||||
dependencies = [
|
||||
"winapi-i686-pc-windows-gnu",
|
||||
"winapi-x86_64-pc-windows-gnu",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-util"
|
||||
version = "0.1.8"
|
||||
version = "0.1.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b"
|
||||
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
|
||||
dependencies = [
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
name = "windows-link"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.52.0"
|
||||
version = "0.61.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
|
||||
checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"
|
||||
dependencies = [
|
||||
"windows-targets",
|
||||
"windows-link",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.52.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb"
|
||||
dependencies = [
|
||||
"windows_aarch64_gnullvm",
|
||||
"windows_aarch64_msvc",
|
||||
"windows_i686_gnu",
|
||||
"windows_i686_gnullvm",
|
||||
"windows_i686_msvc",
|
||||
"windows_x86_64_gnu",
|
||||
"windows_x86_64_gnullvm",
|
||||
"windows_x86_64_msvc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.52.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.52.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.52.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnullvm"
|
||||
version = "0.52.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.52.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.52.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnullvm"
|
||||
version = "0.52.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.52.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0"
|
||||
|
||||
[[package]]
|
||||
name = "winnow"
|
||||
version = "0.6.13"
|
||||
version = "0.7.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "59b5e5f6c299a3c7890b876a2a587f3115162487e704907d9b6cd29473052ba1"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
checksum = "5a5364e9d77fcdeeaa6062ced926ee3381faa2ee02d3eb83a5c27a8825540829"
|
||||
|
||||
[[package]]
|
||||
name = "yansi"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049"
|
||||
+57
-21
@@ -13,8 +13,23 @@
|
||||
edition = "2021"
|
||||
rust-version = "1.56.0"
|
||||
name = "displaydoc"
|
||||
version = "0.2.5"
|
||||
version = "0.2.6"
|
||||
authors = ["Jane Lusby <jlusby@yaah.dev>"]
|
||||
build = false
|
||||
include = [
|
||||
"Cargo.toml",
|
||||
"README.md",
|
||||
"LICENSE-MIT",
|
||||
"LICENSE-APACHE",
|
||||
"CHANGELOG.md",
|
||||
"src/**/*.rs",
|
||||
"tests/**/*.rs",
|
||||
]
|
||||
autolib = false
|
||||
autobins = false
|
||||
autoexamples = false
|
||||
autotests = false
|
||||
autobenches = false
|
||||
description = """
|
||||
A derive macro for implementing the display Trait via a doc comment and string interpolation
|
||||
"""
|
||||
@@ -41,47 +56,72 @@ pre-release-hook = ["./update-readme.sh"]
|
||||
|
||||
[[package.metadata.release.pre-release-replacements]]
|
||||
file = "CHANGELOG.md"
|
||||
replace = "{{version}}"
|
||||
search = "Unreleased"
|
||||
replace = "{{version}}"
|
||||
|
||||
[[package.metadata.release.pre-release-replacements]]
|
||||
exactly = 1
|
||||
file = "src/lib.rs"
|
||||
replace = "#![doc(html_root_url = \"https://docs.rs/{{crate_name}}/{{version}}\")]"
|
||||
search = '#!\[doc\(html_root_url.*'
|
||||
|
||||
[[package.metadata.release.pre-release-replacements]]
|
||||
file = "CHANGELOG.md"
|
||||
replace = "{{date}}"
|
||||
search = "ReleaseDate"
|
||||
|
||||
[[package.metadata.release.pre-release-replacements]]
|
||||
replace = '#![doc(html_root_url = "https://docs.rs/{{crate_name}}/{{version}}")]'
|
||||
exactly = 1
|
||||
|
||||
[[package.metadata.release.pre-release-replacements]]
|
||||
file = "CHANGELOG.md"
|
||||
search = "ReleaseDate"
|
||||
replace = "{{date}}"
|
||||
|
||||
[[package.metadata.release.pre-release-replacements]]
|
||||
file = "CHANGELOG.md"
|
||||
search = "<!-- next-header -->"
|
||||
replace = """
|
||||
<!-- next-header -->
|
||||
|
||||
# [Unreleased] - ReleaseDate"""
|
||||
search = "<!-- next-header -->"
|
||||
exactly = 1
|
||||
|
||||
[[package.metadata.release.pre-release-replacements]]
|
||||
exactly = 1
|
||||
file = "CHANGELOG.md"
|
||||
replace = "...{{tag_name}}"
|
||||
search = '\.\.\.HEAD'
|
||||
replace = "...{{tag_name}}"
|
||||
exactly = 1
|
||||
|
||||
[[package.metadata.release.pre-release-replacements]]
|
||||
exactly = 1
|
||||
file = "CHANGELOG.md"
|
||||
search = "<!-- next-url -->"
|
||||
replace = """
|
||||
<!-- next-url -->
|
||||
[Unreleased]: https://github.com/yaahc/{{crate_name}}/compare/{{tag_name}}...HEAD"""
|
||||
search = "<!-- next-url -->"
|
||||
exactly = 1
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = []
|
||||
|
||||
[lib]
|
||||
name = "displaydoc"
|
||||
path = "src/lib.rs"
|
||||
proc-macro = true
|
||||
|
||||
[[test]]
|
||||
name = "compile_tests"
|
||||
path = "tests/compile_tests.rs"
|
||||
|
||||
[[test]]
|
||||
name = "happy"
|
||||
path = "tests/happy.rs"
|
||||
|
||||
[[test]]
|
||||
name = "no_std"
|
||||
path = "tests/no_std.rs"
|
||||
|
||||
[[test]]
|
||||
name = "num_in_field"
|
||||
path = "tests/num_in_field.rs"
|
||||
|
||||
[[test]]
|
||||
name = "variantless"
|
||||
path = "tests/variantless.rs"
|
||||
|
||||
[dependencies.proc-macro2]
|
||||
version = "1.0"
|
||||
|
||||
@@ -96,7 +136,7 @@ version = "0.2"
|
||||
default-features = false
|
||||
|
||||
[dev-dependencies.pretty_assertions]
|
||||
version = "0.6.1"
|
||||
version = "1.4.0"
|
||||
|
||||
[dev-dependencies.rustversion]
|
||||
version = "1.0.0"
|
||||
@@ -109,7 +149,3 @@ version = "1.0.24"
|
||||
|
||||
[dev-dependencies.trybuild]
|
||||
version = "1.0"
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = []
|
||||
+3
-2
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "displaydoc"
|
||||
version = "0.2.5"
|
||||
version = "0.2.6"
|
||||
rust-version = "1.56.0"
|
||||
authors = ["Jane Lusby <jlusby@yaah.dev>"]
|
||||
edition = "2021"
|
||||
@@ -13,6 +13,7 @@ keywords = ["display", "derive"]
|
||||
description = """
|
||||
A derive macro for implementing the display Trait via a doc comment and string interpolation
|
||||
"""
|
||||
include = ["Cargo.toml", "README.md", "LICENSE-MIT", "LICENSE-APACHE", "CHANGELOG.md", "src/**/*.rs", "tests/**/*.rs"]
|
||||
|
||||
[lib]
|
||||
proc-macro = true
|
||||
@@ -32,7 +33,7 @@ trybuild = "1.0"
|
||||
static_assertions = "1.1"
|
||||
libc = { version = "0.2", default-features = false }
|
||||
rustversion = "1.0.0"
|
||||
pretty_assertions = "0.6.1"
|
||||
pretty_assertions = "1.4.0"
|
||||
thiserror = "1.0.24"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
|
||||
+3
-3
@@ -75,8 +75,8 @@ assert!("oh no, an error: muahaha i am an error" == &format!("{}", error));
|
||||
- Two optional attributes can be added to your types next to the derive:
|
||||
|
||||
- `#[ignore_extra_doc_attributes]` makes the macro ignore any doc
|
||||
comment attributes (or `///` lines) after the first. Multi-line
|
||||
comments using `///` are otherwise treated as an error, so use this
|
||||
comment attributes (or `///` lines) after the last non-empty line. Multi-line
|
||||
comments with line breaks using `///` are otherwise treated as an error, so use this
|
||||
attribute or consider switching to block doc comments (`/** */`).
|
||||
|
||||
- `#[prefix_enum_doc_attributes]` combines the doc comment message on
|
||||
@@ -85,7 +85,7 @@ assert!("oh no, an error: muahaha i am an error" == &format!("{}", error));
|
||||
becomes mandatory. When added to any other type, it has no effect.
|
||||
|
||||
- In case you want to have an independent doc comment, the
|
||||
`#[displaydoc("...")` atrribute may be used on the variant or struct to
|
||||
`#[displaydoc("...")` attribute may be used on the variant or struct to
|
||||
override it.
|
||||
|
||||
<br>
|
||||
|
||||
-23
@@ -1,23 +0,0 @@
|
||||
derive(Display) /// `From<docs>`
|
||||
===============
|
||||
|
||||
[](https://crates.io/crates/displaydoc)
|
||||
[](https://docs.rs/displaydoc)
|
||||
|
||||
{{readme}}
|
||||
|
||||
|
||||
#### License
|
||||
|
||||
<sup>
|
||||
Licensed under either of <a href="LICENSE-APACHE">Apache License, Version
|
||||
2.0</a> or <a href="LICENSE-MIT">MIT license</a> at your option.
|
||||
</sup>
|
||||
|
||||
<br>
|
||||
|
||||
<sub>
|
||||
Unless you explicitly state otherwise, any contribution intentionally submitted
|
||||
for inclusion in this crate by you, as defined in the Apache-2.0 license, shall
|
||||
be dual licensed as above, without any additional terms or conditions.
|
||||
</sub>
|
||||
@@ -1,36 +0,0 @@
|
||||
use displaydoc::Display;
|
||||
|
||||
#[derive(Debug, Display)]
|
||||
pub enum DataStoreError {
|
||||
/// data store disconnected
|
||||
Disconnect,
|
||||
/// the data for key `{0}` is not available
|
||||
Redaction(String),
|
||||
/// invalid header (expected {expected:?}, found {found:?})
|
||||
InvalidHeader { expected: String, found: String },
|
||||
/// unknown data store error
|
||||
Unknown,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let disconnect = DataStoreError::Disconnect;
|
||||
println!(
|
||||
"Enum value `Disconnect` should be printed as:\n\t{}",
|
||||
disconnect
|
||||
);
|
||||
|
||||
let redaction = DataStoreError::Redaction(String::from("Dummy"));
|
||||
println!(
|
||||
"Enum value `Redaction` should be printed as:\n\t{}",
|
||||
redaction
|
||||
);
|
||||
|
||||
let invalid_header = DataStoreError::InvalidHeader {
|
||||
expected: String::from("https"),
|
||||
found: String::from("http"),
|
||||
};
|
||||
println!(
|
||||
"Enum value `InvalidHeader` should be printed as:\n\t{}",
|
||||
invalid_header
|
||||
);
|
||||
}
|
||||
+41
-37
@@ -69,50 +69,54 @@ impl AttrsHelper {
|
||||
return Ok(Some(display));
|
||||
}
|
||||
|
||||
let num_doc_attrs = attrs
|
||||
let literals = attrs
|
||||
.iter()
|
||||
.filter(|attr| attr.path().is_ident("doc"))
|
||||
.count();
|
||||
.map(|attr| match &attr.meta {
|
||||
Meta::NameValue(syn::MetaNameValue {
|
||||
value:
|
||||
syn::Expr::Lit(syn::ExprLit {
|
||||
lit: syn::Lit::Str(lit),
|
||||
..
|
||||
}),
|
||||
..
|
||||
}) => lit,
|
||||
_ => unimplemented!(),
|
||||
});
|
||||
|
||||
if !self.ignore_extra_doc_attributes && num_doc_attrs > 1 {
|
||||
panic!("Multi-line comments are disabled by default by displaydoc. Please consider using block doc comments (/** */) or adding the #[ignore_extra_doc_attributes] attribute to your type next to the derive.");
|
||||
}
|
||||
let span = match literals.clone().next() {
|
||||
Some(lit) => lit.span(),
|
||||
None => return Ok(None),
|
||||
};
|
||||
|
||||
for attr in attrs {
|
||||
if attr.path().is_ident("doc") {
|
||||
let lit = match &attr.meta {
|
||||
Meta::NameValue(syn::MetaNameValue {
|
||||
value:
|
||||
syn::Expr::Lit(syn::ExprLit {
|
||||
lit: syn::Lit::Str(lit),
|
||||
..
|
||||
}),
|
||||
..
|
||||
}) => lit,
|
||||
_ => unimplemented!(),
|
||||
};
|
||||
let strs = literals.map(|lit| {
|
||||
// Make an attempt at cleaning up multiline doc comments.
|
||||
let doc_str = lit
|
||||
.value()
|
||||
.lines()
|
||||
.map(|line| line.trim().trim_start_matches('*').trim())
|
||||
.collect::<Vec<&str>>()
|
||||
.join("\n")
|
||||
.trim()
|
||||
.to_string();
|
||||
(!doc_str.is_empty()).then(|| doc_str)
|
||||
});
|
||||
|
||||
// Make an attempt at cleaning up multiline doc comments.
|
||||
let doc_str = lit
|
||||
.value()
|
||||
.lines()
|
||||
.map(|line| line.trim().trim_start_matches('*').trim())
|
||||
.collect::<Vec<&str>>()
|
||||
.join("\n");
|
||||
let joined = if self.ignore_extra_doc_attributes {
|
||||
strs.take_while(|x| x.is_some()).collect::<Option<Vec<_>>>()
|
||||
} else {
|
||||
strs.collect::<Option<Vec<_>>>()
|
||||
}.unwrap_or_else(|| {
|
||||
panic!("Paragraph breaks in multi-line doc comments are disabled by default by displaydoc. Please consider using block doc comments (/** */) or adding the #[ignore_extra_doc_attributes] attribute to your type next to the derive");
|
||||
}).join(" ");
|
||||
|
||||
let lit = LitStr::new(doc_str.trim(), lit.span());
|
||||
let mut display = Display {
|
||||
fmt: LitStr::new(&joined, span),
|
||||
args: TokenStream::new(),
|
||||
};
|
||||
|
||||
let mut display = Display {
|
||||
fmt: lit,
|
||||
args: TokenStream::new(),
|
||||
};
|
||||
|
||||
display.expand_shorthand();
|
||||
return Ok(Some(display));
|
||||
}
|
||||
}
|
||||
|
||||
Ok(None)
|
||||
display.expand_shorthand();
|
||||
Ok(Some(display))
|
||||
}
|
||||
|
||||
pub(crate) fn display_with_input(
|
||||
|
||||
+10
-9
@@ -9,7 +9,7 @@ use syn::{
|
||||
TypeParamBound, TypePath, WhereClause, WherePredicate,
|
||||
};
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
pub(crate) fn derive(input: &DeriveInput) -> Result<TokenStream> {
|
||||
let impls = match &input.data {
|
||||
@@ -92,11 +92,12 @@ fn impl_struct(input: &DeriveInput, data: &DataStruct) -> Result<TokenStream> {
|
||||
quote! {
|
||||
impl #impl_generics ::core::fmt::Display for #ty #ty_generics #where_clause {
|
||||
fn fmt(&self, formatter: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
||||
// NB: This destructures the fields of `self` into named variables (for unnamed
|
||||
// fields, it uses _0, _1, etc as above). The `#[allow(unused_variables)]`
|
||||
// section means it doesn't have to parse the individual field references out of
|
||||
// the docstring.
|
||||
#[allow(unused_variables)]
|
||||
// NB: This destructures the fields of `self` into named
|
||||
// variables (for unnamed fields, it uses _0, _1, etc as
|
||||
// above). The `#[allow(unused_variables, unused_assignments)]`
|
||||
// section means it doesn't have to parse the individual field
|
||||
// references out of the docstring.
|
||||
#[allow(unused_variables, unused_assignments)]
|
||||
let #pat = self;
|
||||
#display
|
||||
}
|
||||
@@ -224,9 +225,9 @@ fn add_display_constraint_to_type_predicate(
|
||||
fn extract_trait_constraints_from_source(
|
||||
where_clause: &WhereClause,
|
||||
type_params: &[&TypeParam],
|
||||
) -> HashMap<Ident, Vec<TraitBound>> {
|
||||
) -> BTreeMap<Ident, Vec<TraitBound>> {
|
||||
// Add trait bounds provided at the declaration site of type parameters for the struct/enum.
|
||||
let mut param_constraint_mapping: HashMap<Ident, Vec<TraitBound>> = type_params
|
||||
let mut param_constraint_mapping: BTreeMap<Ident, Vec<TraitBound>> = type_params
|
||||
.iter()
|
||||
.map(|type_param| {
|
||||
let trait_bounds: Vec<TraitBound> = type_param
|
||||
@@ -396,7 +397,7 @@ fn impl_enum(input: &DeriveInput, data: &DataEnum) -> Result<TokenStream> {
|
||||
Ok(quote! {
|
||||
impl #impl_generics ::core::fmt::Display for #ty #ty_generics #where_clause {
|
||||
fn fmt(&self, formatter: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
||||
#[allow(unused_variables)]
|
||||
#[allow(unused_variables, unused_assignments)]
|
||||
match self {
|
||||
#(#arms,)*
|
||||
}
|
||||
|
||||
+4
-4
@@ -70,8 +70,8 @@
|
||||
//! - Two optional attributes can be added to your types next to the derive:
|
||||
//!
|
||||
//! - `#[ignore_extra_doc_attributes]` makes the macro ignore any doc
|
||||
//! comment attributes (or `///` lines) after the first. Multi-line
|
||||
//! comments using `///` are otherwise treated as an error, so use this
|
||||
//! comment attributes (or `///` lines) after the last non-empty line. Multi-line
|
||||
//! comments with line breaks using `///` are otherwise treated as an error, so use this
|
||||
//! attribute or consider switching to block doc comments (`/** */`).
|
||||
//!
|
||||
//! - `#[prefix_enum_doc_attributes]` combines the doc comment message on
|
||||
@@ -80,7 +80,7 @@
|
||||
//! becomes mandatory. When added to any other type, it has no effect.
|
||||
//!
|
||||
//! - In case you want to have an independent doc comment, the
|
||||
//! `#[displaydoc("...")` atrribute may be used on the variant or struct to
|
||||
//! `#[displaydoc("...")` attribute may be used on the variant or struct to
|
||||
//! override it.
|
||||
//!
|
||||
//! <br>
|
||||
@@ -92,7 +92,7 @@
|
||||
//!
|
||||
//! 2. **Does this crate work with `Path` and `PathBuf` via the `Display` trait?**
|
||||
//! * Yuuup. This crate uses @dtolnay's [autoref specialization technique](https://github.com/dtolnay/case-studies/blob/master/autoref-specialization/README.md) to add a special trait for types to get the display impl. It then specializes for `Path` and `PathBuf`, and when either of these types are found, it calls `self.display()` to get a `std::path::Display<'_>` type which can be used with the `Display` format specifier!
|
||||
#![doc(html_root_url = "https://docs.rs/displaydoc/0.2.3")]
|
||||
#![doc(html_root_url = "https://docs.rs/displaydoc/0.2.6")]
|
||||
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||
#![warn(
|
||||
rust_2018_idioms,
|
||||
|
||||
+8
-23
@@ -3,27 +3,12 @@
|
||||
#[test]
|
||||
fn no_std() {
|
||||
let t = trybuild::TestCases::new();
|
||||
#[cfg(not(feature = "std"))]
|
||||
t.compile_fail("tests/no_std/without.rs");
|
||||
#[cfg(not(feature = "std"))]
|
||||
t.compile_fail("tests/no_std/multi_line.rs");
|
||||
#[cfg(not(feature = "std"))]
|
||||
t.pass("tests/no_std/multi_line_allow.rs");
|
||||
#[cfg(not(feature = "std"))]
|
||||
t.compile_fail("tests/no_std/enum_prefix_missing.rs");
|
||||
#[cfg(not(feature = "std"))]
|
||||
t.pass("tests/no_std/enum_prefix.rs");
|
||||
#[cfg(feature = "std")]
|
||||
t.compile_fail("tests/std/without.rs");
|
||||
#[cfg(feature = "std")]
|
||||
t.compile_fail("tests/std/multi_line.rs");
|
||||
#[cfg(feature = "std")]
|
||||
t.pass("tests/std/multi_line_allow.rs");
|
||||
#[cfg(feature = "std")]
|
||||
t.compile_fail("tests/std/enum_prefix_missing.rs");
|
||||
#[cfg(feature = "std")]
|
||||
t.pass("tests/std/enum_prefix.rs");
|
||||
#[cfg(feature = "std")]
|
||||
t.pass("tests/std/multiple.rs");
|
||||
t.pass("tests/no_std/with.rs");
|
||||
t.compile_fail("tests/ui/without.rs");
|
||||
t.compile_fail("tests/ui/multi_line_line_break.rs");
|
||||
t.compile_fail("tests/ui/multi_line_line_break_block.rs");
|
||||
t.pass("tests/ui/multi_line.rs");
|
||||
t.pass("tests/ui/multi_line_allow.rs");
|
||||
t.compile_fail("tests/ui/enum_prefix_missing.rs");
|
||||
t.pass("tests/ui/enum_prefix.rs");
|
||||
t.pass("tests/ui/multiple.rs");
|
||||
}
|
||||
+67
-2
@@ -12,11 +12,53 @@ struct HappyStruct {
|
||||
#[derive(Display)]
|
||||
#[ignore_extra_doc_attributes]
|
||||
/// Just a basic struct {thing}
|
||||
/// and this line should get ignored
|
||||
/// and this line should not get ignored
|
||||
struct HappyStruct2 {
|
||||
thing: &'static str,
|
||||
}
|
||||
|
||||
#[derive(Display)]
|
||||
/// Really fancy first line with thing: {thing}
|
||||
/// Really cool second line
|
||||
struct HappyMultiLine {
|
||||
thing: &'static str,
|
||||
}
|
||||
|
||||
#[derive(Display)]
|
||||
#[ignore_extra_doc_attributes]
|
||||
/// multi
|
||||
/// line
|
||||
///
|
||||
/// new paragraph should be ignored
|
||||
struct HappyMultilineWithIgnore;
|
||||
|
||||
#[derive(Display)]
|
||||
enum MixedBlockAndLineComments {
|
||||
/**
|
||||
* hello
|
||||
* block
|
||||
* comment
|
||||
*/
|
||||
/// line comment
|
||||
BlockFirst,
|
||||
/// line comment
|
||||
/**
|
||||
* hello
|
||||
* block
|
||||
* comment
|
||||
*/
|
||||
LineFirst,
|
||||
/**
|
||||
* block
|
||||
* comment
|
||||
*/
|
||||
/**
|
||||
* block
|
||||
* comment2
|
||||
*/
|
||||
DoubleBlock,
|
||||
}
|
||||
|
||||
#[derive(Display)]
|
||||
enum Happy {
|
||||
/// I really like Variant1
|
||||
@@ -109,7 +151,30 @@ fn does_it_print() {
|
||||
);
|
||||
assert_display(HappyStruct { thing: "hi" }, "Just a basic struct hi");
|
||||
|
||||
assert_display(HappyStruct2 { thing: "hi2" }, "Just a basic struct hi2");
|
||||
assert_display(
|
||||
HappyStruct2 { thing: "hi2" },
|
||||
"Just a basic struct hi2 and this line should not get ignored",
|
||||
);
|
||||
|
||||
assert_display(
|
||||
HappyMultiLine { thing: "rust" },
|
||||
"Really fancy first line with thing: rust Really cool second line",
|
||||
);
|
||||
|
||||
assert_display(HappyMultilineWithIgnore, "multi line");
|
||||
|
||||
assert_display(
|
||||
MixedBlockAndLineComments::BlockFirst,
|
||||
"hello\nblock\ncomment line comment",
|
||||
);
|
||||
assert_display(
|
||||
MixedBlockAndLineComments::LineFirst,
|
||||
"line comment hello\nblock\ncomment",
|
||||
);
|
||||
assert_display(
|
||||
MixedBlockAndLineComments::DoubleBlock,
|
||||
"block\ncomment block\ncomment2",
|
||||
);
|
||||
|
||||
assert_display(inner_mod::InnerHappy::Variant1, "I really like Variant1");
|
||||
assert_display(
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
#![no_std]
|
||||
#![allow(unused)]
|
||||
|
||||
// This test ensures that the generated code doesn't reference any stdlib items.
|
||||
|
||||
use displaydoc::Display;
|
||||
|
||||
#[derive(Display)]
|
||||
/// Just a basic struct {thing}
|
||||
struct HappyStruct {
|
||||
thing: &'static str,
|
||||
}
|
||||
|
||||
#[derive(Display)]
|
||||
#[ignore_extra_doc_attributes]
|
||||
/// Just a basic struct {thing}
|
||||
/// and this line should get ignored
|
||||
struct HappyStruct2 {
|
||||
thing: &'static str,
|
||||
}
|
||||
|
||||
#[derive(Display)]
|
||||
enum Happy {
|
||||
/// I really like Variant1
|
||||
Variant1,
|
||||
/// Variant2 is pretty swell 2
|
||||
Variant2,
|
||||
/// Variant3 is okay {sometimes}
|
||||
Variant3 { sometimes: &'static str },
|
||||
/**
|
||||
* Variant4 wants to have a lot of lines
|
||||
*
|
||||
* Lets see how this works out for it
|
||||
*/
|
||||
Variant4,
|
||||
/// Variant5 has a parameter {0} and some regular comments
|
||||
// A regular comment that won't get picked
|
||||
Variant5(u32),
|
||||
|
||||
/// These docs are ignored
|
||||
#[displaydoc("Variant7 has a parameter {0} and uses #[displaydoc]")]
|
||||
/// These docs are also ignored
|
||||
Variant7(u32),
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
#![cfg_attr(not(feature = "std"), allow(internal_features), feature(lang_items, start))]
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
#[cfg_attr(not(feature = "std"), start)]
|
||||
fn start(_argc: isize, _argv: *const *const u8) -> isize {
|
||||
0
|
||||
}
|
||||
#[lang = "eh_personality"]
|
||||
#[no_mangle]
|
||||
#[cfg(not(feature = "std"))]
|
||||
pub extern "C" fn rust_eh_personality() {}
|
||||
#[panic_handler]
|
||||
#[cfg(not(feature = "std"))]
|
||||
fn panic(_info: &core::panic::PanicInfo) -> ! {
|
||||
unsafe {
|
||||
libc::abort();
|
||||
}
|
||||
}
|
||||
|
||||
use displaydoc::Display;
|
||||
|
||||
/// this type is pretty swell
|
||||
#[derive(Display)]
|
||||
#[prefix_enum_doc_attributes]
|
||||
enum TestType {
|
||||
/// this variant is too
|
||||
Variant1,
|
||||
|
||||
/// this variant is two
|
||||
Variant2,
|
||||
}
|
||||
|
||||
static_assertions::assert_impl_all!(TestType: core::fmt::Display);
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
fn main() {}
|
||||
@@ -1,35 +0,0 @@
|
||||
#![cfg_attr(not(feature = "std"), allow(internal_features), feature(lang_items, start))]
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
#[cfg_attr(not(feature = "std"), start)]
|
||||
fn start(_argc: isize, _argv: *const *const u8) -> isize {
|
||||
0
|
||||
}
|
||||
#[lang = "eh_personality"]
|
||||
#[no_mangle]
|
||||
#[cfg(not(feature = "std"))]
|
||||
pub extern "C" fn rust_eh_personality() {}
|
||||
#[panic_handler]
|
||||
#[cfg(not(feature = "std"))]
|
||||
fn panic(_info: &core::panic::PanicInfo) -> ! {
|
||||
unsafe {
|
||||
libc::abort();
|
||||
}
|
||||
}
|
||||
|
||||
use displaydoc::Display;
|
||||
|
||||
#[derive(Display)]
|
||||
#[prefix_enum_doc_attributes]
|
||||
enum TestType {
|
||||
/// this variant is too
|
||||
Variant1,
|
||||
|
||||
/// this variant is two
|
||||
Variant2,
|
||||
}
|
||||
|
||||
static_assertions::assert_impl_all!(TestType: core::fmt::Display);
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
fn main() {}
|
||||
@@ -1,22 +0,0 @@
|
||||
error: proc-macro derive panicked
|
||||
--> $DIR/enum_prefix_missing.rs:22:10
|
||||
|
|
||||
22 | #[derive(Display)]
|
||||
| ^^^^^^^
|
||||
|
|
||||
= help: message: Missing doc comment on enum with #[prefix_enum_doc_attributes]. Please remove the attribute or add a doc comment to the enum itself.
|
||||
|
||||
error[E0277]: `TestType` doesn't implement `Display`
|
||||
--> $DIR/enum_prefix_missing.rs:32:37
|
||||
|
|
||||
32 | static_assertions::assert_impl_all!(TestType: core::fmt::Display);
|
||||
| ^^^^^^^^ `TestType` cannot be formatted with the default formatter
|
||||
|
|
||||
= help: the trait `Display` is not implemented for `TestType`
|
||||
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
|
||||
note: required by a bound in `assert_impl_all`
|
||||
--> $DIR/enum_prefix_missing.rs:32:1
|
||||
|
|
||||
32 | static_assertions::assert_impl_all!(TestType: core::fmt::Display);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `assert_impl_all`
|
||||
= note: this error originates in the macro `static_assertions::assert_impl_all` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
@@ -1,37 +0,0 @@
|
||||
#![cfg_attr(not(feature = "std"), allow(internal_features), feature(lang_items, start))]
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
#[cfg_attr(not(feature = "std"), start)]
|
||||
fn start(_argc: isize, _argv: *const *const u8) -> isize {
|
||||
0
|
||||
}
|
||||
#[lang = "eh_personality"]
|
||||
#[no_mangle]
|
||||
#[cfg(not(feature = "std"))]
|
||||
pub extern "C" fn rust_eh_personality() {}
|
||||
#[panic_handler]
|
||||
#[cfg(not(feature = "std"))]
|
||||
fn panic(_info: &core::panic::PanicInfo) -> ! {
|
||||
unsafe {
|
||||
libc::abort();
|
||||
}
|
||||
}
|
||||
|
||||
use displaydoc::Display;
|
||||
|
||||
/// this type is pretty swell
|
||||
#[derive(Display)]
|
||||
enum TestType {
|
||||
/// This one is okay
|
||||
Variant1,
|
||||
|
||||
/// Multi
|
||||
/// line
|
||||
/// doc.
|
||||
Variant2,
|
||||
}
|
||||
|
||||
static_assertions::assert_impl_all!(TestType: core::fmt::Display);
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
fn main() {}
|
||||
@@ -1,22 +0,0 @@
|
||||
error: proc-macro derive panicked
|
||||
--> $DIR/multi_line.rs:23:10
|
||||
|
|
||||
23 | #[derive(Display)]
|
||||
| ^^^^^^^
|
||||
|
|
||||
= help: message: Multi-line comments are disabled by default by displaydoc. Please consider using block doc comments (/** */) or adding the #[ignore_extra_doc_attributes] attribute to your type next to the derive.
|
||||
|
||||
error[E0277]: `TestType` doesn't implement `Display`
|
||||
--> $DIR/multi_line.rs:34:37
|
||||
|
|
||||
34 | static_assertions::assert_impl_all!(TestType: core::fmt::Display);
|
||||
| ^^^^^^^^ `TestType` cannot be formatted with the default formatter
|
||||
|
|
||||
= help: the trait `Display` is not implemented for `TestType`
|
||||
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
|
||||
note: required by a bound in `assert_impl_all`
|
||||
--> $DIR/multi_line.rs:34:1
|
||||
|
|
||||
34 | static_assertions::assert_impl_all!(TestType: core::fmt::Display);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `assert_impl_all`
|
||||
= note: this error originates in the macro `static_assertions::assert_impl_all` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
@@ -1,38 +0,0 @@
|
||||
#![cfg_attr(not(feature = "std"), allow(internal_features), feature(lang_items, start))]
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
#[cfg_attr(not(feature = "std"), start)]
|
||||
fn start(_argc: isize, _argv: *const *const u8) -> isize {
|
||||
0
|
||||
}
|
||||
#[lang = "eh_personality"]
|
||||
#[no_mangle]
|
||||
#[cfg(not(feature = "std"))]
|
||||
pub extern "C" fn rust_eh_personality() {}
|
||||
#[panic_handler]
|
||||
#[cfg(not(feature = "std"))]
|
||||
fn panic(_info: &core::panic::PanicInfo) -> ! {
|
||||
unsafe {
|
||||
libc::abort();
|
||||
}
|
||||
}
|
||||
|
||||
use displaydoc::Display;
|
||||
|
||||
/// this type is pretty swell
|
||||
#[derive(Display)]
|
||||
#[ignore_extra_doc_attributes]
|
||||
enum TestType {
|
||||
/// This one is okay
|
||||
Variant1,
|
||||
|
||||
/// Multi
|
||||
/// line
|
||||
/// doc.
|
||||
Variant2,
|
||||
}
|
||||
|
||||
static_assertions::assert_impl_all!(TestType: core::fmt::Display);
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
fn main() {}
|
||||
@@ -1,32 +0,0 @@
|
||||
#![feature(lang_items, start)]
|
||||
#![no_std]
|
||||
|
||||
#[start]
|
||||
#[cfg(not(feature = "std"))]
|
||||
fn start(_argc: isize, _argv: *const *const u8) -> isize {
|
||||
0
|
||||
}
|
||||
|
||||
#[lang = "eh_personality"]
|
||||
#[no_mangle]
|
||||
#[cfg(not(feature = "std"))]
|
||||
pub extern "C" fn rust_eh_personality() {}
|
||||
|
||||
#[panic_handler]
|
||||
#[cfg(not(feature = "std"))]
|
||||
fn panic(_info: &core::panic::PanicInfo) -> ! {
|
||||
unsafe {
|
||||
libc::abort();
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
fn main() {}
|
||||
|
||||
use displaydoc::Display;
|
||||
|
||||
/// this type is pretty swell
|
||||
#[derive(Display)]
|
||||
struct FakeType;
|
||||
|
||||
static_assertions::assert_impl_all!(FakeType: core::fmt::Display);
|
||||
@@ -1,28 +0,0 @@
|
||||
#![cfg_attr(not(feature = "std"), allow(internal_features), feature(lang_items, start))]
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
#[cfg_attr(not(feature = "std"), start)]
|
||||
fn start(_argc: isize, _argv: *const *const u8) -> isize {
|
||||
0
|
||||
}
|
||||
#[lang = "eh_personality"]
|
||||
#[no_mangle]
|
||||
#[cfg(not(feature = "std"))]
|
||||
pub extern "C" fn rust_eh_personality() {}
|
||||
#[panic_handler]
|
||||
#[cfg(not(feature = "std"))]
|
||||
fn panic(_info: &core::panic::PanicInfo) -> ! {
|
||||
unsafe {
|
||||
libc::abort();
|
||||
}
|
||||
}
|
||||
|
||||
use displaydoc::Display;
|
||||
|
||||
/// this type is pretty swell
|
||||
struct FakeType;
|
||||
|
||||
static_assertions::assert_impl_all!(FakeType: core::fmt::Display);
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
fn main() {}
|
||||
@@ -1,22 +0,0 @@
|
||||
warning: unused import: `displaydoc::Display`
|
||||
--> $DIR/without.rs:20:5
|
||||
|
|
||||
20 | use displaydoc::Display;
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `#[warn(unused_imports)]` on by default
|
||||
|
||||
error[E0277]: `FakeType` doesn't implement `Display`
|
||||
--> $DIR/without.rs:25:37
|
||||
|
|
||||
25 | static_assertions::assert_impl_all!(FakeType: core::fmt::Display);
|
||||
| ^^^^^^^^ `FakeType` cannot be formatted with the default formatter
|
||||
|
|
||||
= help: the trait `Display` is not implemented for `FakeType`
|
||||
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
|
||||
note: required by a bound in `assert_impl_all`
|
||||
--> $DIR/without.rs:25:1
|
||||
|
|
||||
25 | static_assertions::assert_impl_all!(FakeType: core::fmt::Display);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `assert_impl_all`
|
||||
= note: this error originates in the macro `static_assertions::assert_impl_all` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
@@ -1,36 +0,0 @@
|
||||
#![cfg_attr(not(feature = "std"), feature(lang_items, start))]
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
#[cfg_attr(not(feature = "std"), start)]
|
||||
fn start(_argc: isize, _argv: *const *const u8) -> isize {
|
||||
0
|
||||
}
|
||||
#[lang = "eh_personality"]
|
||||
#[no_mangle]
|
||||
#[cfg(not(feature = "std"))]
|
||||
pub extern "C" fn rust_eh_personality() {}
|
||||
#[panic_handler]
|
||||
#[cfg(not(feature = "std"))]
|
||||
fn panic(_info: &core::panic::PanicInfo) -> ! {
|
||||
unsafe {
|
||||
libc::abort();
|
||||
}
|
||||
}
|
||||
|
||||
use displaydoc::Display;
|
||||
|
||||
/// this type is pretty swell
|
||||
#[derive(Display)]
|
||||
#[prefix_enum_doc_attributes]
|
||||
enum TestType {
|
||||
/// this variant is too
|
||||
Variant1,
|
||||
|
||||
/// this variant is two
|
||||
Variant2,
|
||||
}
|
||||
|
||||
static_assertions::assert_impl_all!(TestType: core::fmt::Display);
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
fn main() {}
|
||||
@@ -1,35 +0,0 @@
|
||||
#![cfg_attr(not(feature = "std"), feature(lang_items, start))]
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
#[cfg_attr(not(feature = "std"), start)]
|
||||
fn start(_argc: isize, _argv: *const *const u8) -> isize {
|
||||
0
|
||||
}
|
||||
#[lang = "eh_personality"]
|
||||
#[no_mangle]
|
||||
#[cfg(not(feature = "std"))]
|
||||
pub extern "C" fn rust_eh_personality() {}
|
||||
#[panic_handler]
|
||||
#[cfg(not(feature = "std"))]
|
||||
fn panic(_info: &core::panic::PanicInfo) -> ! {
|
||||
unsafe {
|
||||
libc::abort();
|
||||
}
|
||||
}
|
||||
|
||||
use displaydoc::Display;
|
||||
|
||||
#[derive(Display)]
|
||||
#[prefix_enum_doc_attributes]
|
||||
enum TestType {
|
||||
/// this variant is too
|
||||
Variant1,
|
||||
|
||||
/// this variant is two
|
||||
Variant2,
|
||||
}
|
||||
|
||||
static_assertions::assert_impl_all!(TestType: core::fmt::Display);
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
fn main() {}
|
||||
@@ -1,22 +0,0 @@
|
||||
error: proc-macro derive panicked
|
||||
--> $DIR/enum_prefix_missing.rs:22:10
|
||||
|
|
||||
22 | #[derive(Display)]
|
||||
| ^^^^^^^
|
||||
|
|
||||
= help: message: Missing doc comment on enum with #[prefix_enum_doc_attributes]. Please remove the attribute or add a doc comment to the enum itself.
|
||||
|
||||
error[E0277]: `TestType` doesn't implement `std::fmt::Display`
|
||||
--> $DIR/enum_prefix_missing.rs:32:37
|
||||
|
|
||||
32 | static_assertions::assert_impl_all!(TestType: core::fmt::Display);
|
||||
| ^^^^^^^^ `TestType` cannot be formatted with the default formatter
|
||||
|
|
||||
= help: the trait `std::fmt::Display` is not implemented for `TestType`
|
||||
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
|
||||
note: required by a bound in `assert_impl_all`
|
||||
--> $DIR/enum_prefix_missing.rs:32:1
|
||||
|
|
||||
32 | static_assertions::assert_impl_all!(TestType: core::fmt::Display);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `assert_impl_all`
|
||||
= note: this error originates in the macro `static_assertions::assert_impl_all` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
@@ -1,37 +0,0 @@
|
||||
#![cfg_attr(not(feature = "std"), allow(internal_features), feature(lang_items, start))]
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
#[cfg_attr(not(feature = "std"), start)]
|
||||
fn start(_argc: isize, _argv: *const *const u8) -> isize {
|
||||
0
|
||||
}
|
||||
#[lang = "eh_personality"]
|
||||
#[no_mangle]
|
||||
#[cfg(not(feature = "std"))]
|
||||
pub extern "C" fn rust_eh_personality() {}
|
||||
#[panic_handler]
|
||||
#[cfg(not(feature = "std"))]
|
||||
fn panic(_info: &core::panic::PanicInfo) -> ! {
|
||||
unsafe {
|
||||
libc::abort();
|
||||
}
|
||||
}
|
||||
|
||||
use displaydoc::Display;
|
||||
|
||||
/// this type is pretty swell
|
||||
#[derive(Display)]
|
||||
enum TestType {
|
||||
/// This one is okay
|
||||
Variant1,
|
||||
|
||||
/// Multi
|
||||
/// line
|
||||
/// doc.
|
||||
Variant2,
|
||||
}
|
||||
|
||||
static_assertions::assert_impl_all!(TestType: core::fmt::Display);
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
fn main() {}
|
||||
@@ -1,22 +0,0 @@
|
||||
error: proc-macro derive panicked
|
||||
--> $DIR/multi_line.rs:23:10
|
||||
|
|
||||
23 | #[derive(Display)]
|
||||
| ^^^^^^^
|
||||
|
|
||||
= help: message: Multi-line comments are disabled by default by displaydoc. Please consider using block doc comments (/** */) or adding the #[ignore_extra_doc_attributes] attribute to your type next to the derive.
|
||||
|
||||
error[E0277]: `TestType` doesn't implement `std::fmt::Display`
|
||||
--> $DIR/multi_line.rs:34:37
|
||||
|
|
||||
34 | static_assertions::assert_impl_all!(TestType: core::fmt::Display);
|
||||
| ^^^^^^^^ `TestType` cannot be formatted with the default formatter
|
||||
|
|
||||
= help: the trait `std::fmt::Display` is not implemented for `TestType`
|
||||
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
|
||||
note: required by a bound in `assert_impl_all`
|
||||
--> $DIR/multi_line.rs:34:1
|
||||
|
|
||||
34 | static_assertions::assert_impl_all!(TestType: core::fmt::Display);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `assert_impl_all`
|
||||
= note: this error originates in the macro `static_assertions::assert_impl_all` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
@@ -1,38 +0,0 @@
|
||||
#![cfg_attr(not(feature = "std"), feature(lang_items, start))]
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
#[cfg_attr(not(feature = "std"), start)]
|
||||
fn start(_argc: isize, _argv: *const *const u8) -> isize {
|
||||
0
|
||||
}
|
||||
#[lang = "eh_personality"]
|
||||
#[no_mangle]
|
||||
#[cfg(not(feature = "std"))]
|
||||
pub extern "C" fn rust_eh_personality() {}
|
||||
#[panic_handler]
|
||||
#[cfg(not(feature = "std"))]
|
||||
fn panic(_info: &core::panic::PanicInfo) -> ! {
|
||||
unsafe {
|
||||
libc::abort();
|
||||
}
|
||||
}
|
||||
|
||||
use displaydoc::Display;
|
||||
|
||||
/// this type is pretty swell
|
||||
#[derive(Display)]
|
||||
#[ignore_extra_doc_attributes]
|
||||
enum TestType {
|
||||
/// This one is okay
|
||||
Variant1,
|
||||
|
||||
/// Multi
|
||||
/// line
|
||||
/// doc.
|
||||
Variant2,
|
||||
}
|
||||
|
||||
static_assertions::assert_impl_all!(TestType: core::fmt::Display);
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
fn main() {}
|
||||
@@ -1,38 +0,0 @@
|
||||
#![feature(lang_items, start)]
|
||||
#![no_std]
|
||||
|
||||
#[start]
|
||||
#[cfg(not(feature = "std"))]
|
||||
fn start(_argc: isize, _argv: *const *const u8) -> isize {
|
||||
0
|
||||
}
|
||||
|
||||
#[lang = "eh_personality"]
|
||||
#[no_mangle]
|
||||
#[cfg(not(feature = "std"))]
|
||||
pub extern "C" fn rust_eh_personality() {}
|
||||
|
||||
#[panic_handler]
|
||||
#[cfg(not(feature = "std"))]
|
||||
fn panic(_info: &core::panic::PanicInfo) -> ! {
|
||||
unsafe {
|
||||
libc::abort();
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
fn main() {}
|
||||
|
||||
use displaydoc::Display;
|
||||
|
||||
/// this type is pretty swell
|
||||
#[derive(Display)]
|
||||
struct FakeType;
|
||||
|
||||
static_assertions::assert_impl_all!(FakeType: core::fmt::Display);
|
||||
|
||||
/// this type is pretty swell2
|
||||
#[derive(Display)]
|
||||
struct FakeType2;
|
||||
|
||||
static_assertions::assert_impl_all!(FakeType2: core::fmt::Display);
|
||||
@@ -1,28 +0,0 @@
|
||||
#![cfg_attr(not(feature = "std"), allow(internal_features), feature(lang_items, start))]
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
#[cfg_attr(not(feature = "std"), start)]
|
||||
fn start(_argc: isize, _argv: *const *const u8) -> isize {
|
||||
0
|
||||
}
|
||||
#[lang = "eh_personality"]
|
||||
#[no_mangle]
|
||||
#[cfg(not(feature = "std"))]
|
||||
pub extern "C" fn rust_eh_personality() {}
|
||||
#[panic_handler]
|
||||
#[cfg(not(feature = "std"))]
|
||||
fn panic(_info: &core::panic::PanicInfo) -> ! {
|
||||
unsafe {
|
||||
libc::abort();
|
||||
}
|
||||
}
|
||||
|
||||
use displaydoc::Display;
|
||||
|
||||
/// this type is pretty swell
|
||||
struct FakeType;
|
||||
|
||||
static_assertions::assert_impl_all!(FakeType: core::fmt::Display);
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
fn main() {}
|
||||
@@ -1,22 +0,0 @@
|
||||
warning: unused import: `displaydoc::Display`
|
||||
--> $DIR/without.rs:20:5
|
||||
|
|
||||
20 | use displaydoc::Display;
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `#[warn(unused_imports)]` on by default
|
||||
|
||||
error[E0277]: `FakeType` doesn't implement `std::fmt::Display`
|
||||
--> $DIR/without.rs:25:37
|
||||
|
|
||||
25 | static_assertions::assert_impl_all!(FakeType: core::fmt::Display);
|
||||
| ^^^^^^^^ `FakeType` cannot be formatted with the default formatter
|
||||
|
|
||||
= help: the trait `std::fmt::Display` is not implemented for `FakeType`
|
||||
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
|
||||
note: required by a bound in `assert_impl_all`
|
||||
--> $DIR/without.rs:25:1
|
||||
|
|
||||
25 | static_assertions::assert_impl_all!(FakeType: core::fmt::Display);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `assert_impl_all`
|
||||
= note: this error originates in the macro `static_assertions::assert_impl_all` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
@@ -0,0 +1,16 @@
|
||||
use displaydoc::Display;
|
||||
|
||||
/// this type is pretty swell
|
||||
#[derive(Display)]
|
||||
#[prefix_enum_doc_attributes]
|
||||
enum TestType {
|
||||
/// this variant is too
|
||||
Variant1,
|
||||
|
||||
/// this variant is two
|
||||
Variant2,
|
||||
}
|
||||
|
||||
static_assertions::assert_impl_all!(TestType: core::fmt::Display);
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,15 @@
|
||||
use displaydoc::Display;
|
||||
|
||||
#[derive(Display)]
|
||||
#[prefix_enum_doc_attributes]
|
||||
enum TestType {
|
||||
/// this variant is too
|
||||
Variant1,
|
||||
|
||||
/// this variant is two
|
||||
Variant2,
|
||||
}
|
||||
|
||||
static_assertions::assert_impl_all!(TestType: core::fmt::Display);
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,20 @@
|
||||
use displaydoc::Display;
|
||||
|
||||
/// this type is pretty swell
|
||||
#[derive(Display)]
|
||||
enum TestType {
|
||||
/// This one is okay
|
||||
Variant1,
|
||||
|
||||
/// Multi
|
||||
/// line
|
||||
/// doc
|
||||
/// is
|
||||
/// pretty
|
||||
/// swell
|
||||
Variant2,
|
||||
}
|
||||
|
||||
static_assertions::assert_impl_all!(TestType: core::fmt::Display);
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,27 @@
|
||||
use displaydoc::Display;
|
||||
|
||||
/// this type is pretty swell
|
||||
#[derive(Display)]
|
||||
#[ignore_extra_doc_attributes]
|
||||
enum TestType {
|
||||
/// This one is okay
|
||||
Variant1,
|
||||
|
||||
/// Multi
|
||||
/// line
|
||||
/// doc.
|
||||
Variant2,
|
||||
|
||||
/// Multi
|
||||
/// line
|
||||
/// doc
|
||||
///
|
||||
/// with
|
||||
/// line
|
||||
/// breaks
|
||||
Variant3,
|
||||
}
|
||||
|
||||
static_assertions::assert_impl_all!(TestType: core::fmt::Display);
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,20 @@
|
||||
use displaydoc::Display;
|
||||
|
||||
#[derive(Display)]
|
||||
/// Multi
|
||||
/// line
|
||||
/// doc
|
||||
/// with
|
||||
/// line
|
||||
/// break
|
||||
///
|
||||
/// is
|
||||
/// pretty
|
||||
/// not
|
||||
/// swell
|
||||
/// 😞👊
|
||||
struct TestType;
|
||||
|
||||
static_assertions::assert_impl_all!(TestType: core::fmt::Display);
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,14 @@
|
||||
use displaydoc::Display;
|
||||
|
||||
#[derive(Display)]
|
||||
/**
|
||||
* block
|
||||
*/
|
||||
/**
|
||||
*
|
||||
*/
|
||||
struct TestType;
|
||||
|
||||
static_assertions::assert_impl_all!(TestType: core::fmt::Display);
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,15 @@
|
||||
use displaydoc::Display;
|
||||
|
||||
/// this type is pretty swell
|
||||
#[derive(Display)]
|
||||
struct FakeType;
|
||||
|
||||
static_assertions::assert_impl_all!(FakeType: core::fmt::Display);
|
||||
|
||||
/// this type is pretty swell2
|
||||
#[derive(Display)]
|
||||
struct FakeType2;
|
||||
|
||||
static_assertions::assert_impl_all!(FakeType2: core::fmt::Display);
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,8 @@
|
||||
use displaydoc::Display;
|
||||
|
||||
/// this type is pretty swell
|
||||
struct FakeType;
|
||||
|
||||
static_assertions::assert_impl_all!(FakeType: core::fmt::Display);
|
||||
|
||||
fn main() {}
|
||||
@@ -1,5 +0,0 @@
|
||||
#! /usr/bin/env bash
|
||||
|
||||
cargo readme > ./README.md
|
||||
git add ./README.md
|
||||
git commit -m "Update readme" || true
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"git": {
|
||||
"sha1": "59ae1fce0cec62c886fcd486e06b7e219bc7ce48"
|
||||
"sha1": "8f4ecd9964ea909a7f989a3668a2710310a0e62f"
|
||||
},
|
||||
"path_in_vcs": ""
|
||||
}
|
||||
@@ -32,6 +32,13 @@ jobs:
|
||||
path: ~/.cargo/registry/index
|
||||
key: cargo-${{ matrix.rust }}-git-index
|
||||
|
||||
- name: Lock MSRV-compatible dependencies
|
||||
if: startsWith(matrix.rust, '1')
|
||||
env:
|
||||
CARGO_RESOLVER_INCOMPATIBLE_RUST_VERSIONS: fallback
|
||||
# Note that this uses the runner's pre-installed stable cargo
|
||||
run: cargo generate-lockfile
|
||||
|
||||
- name: Set up Rust
|
||||
uses: dtolnay/rust-toolchain@master
|
||||
with:
|
||||
|
||||
+19
-26
@@ -4,7 +4,7 @@ version = 3
|
||||
|
||||
[[package]]
|
||||
name = "either"
|
||||
version = "1.15.0"
|
||||
version = "1.16.0"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_json",
|
||||
@@ -12,54 +12,48 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "1.0.15"
|
||||
version = "1.0.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.7.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
|
||||
checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.94"
|
||||
version = "1.0.71"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84"
|
||||
checksum = "75cb1540fadbd5b8fbccc4dddad2734eba435053f725621c070711a14bb5f4b8"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.39"
|
||||
version = "1.0.33"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c1f1914ce909e1658d9907913b4b91947430c7d9be598b15a1912935b8c04801"
|
||||
checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ryu"
|
||||
version = "1.0.20"
|
||||
version = "1.0.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f"
|
||||
checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c"
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.218"
|
||||
version = "1.0.193"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e8dfc9d19bdbf6d17e22319da49161d5d0108e4188e8b680aef6299eed22df60"
|
||||
checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.218"
|
||||
version = "1.0.193"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f09503e191f4e797cb8aac08e9a4a4695c5edf6a2e70e376d961ddd5c969f82b"
|
||||
checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -68,21 +62,20 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.140"
|
||||
version = "1.0.108"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373"
|
||||
checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"memchr",
|
||||
"ryu",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.99"
|
||||
version = "2.0.43"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e02e925281e18ffd9d640e234264753c43edc62d64b2d4cf898f1bc5e75f3fc2"
|
||||
checksum = "ee659fb5f3d355364e1f3e5bc10fb82068efbf824a1e9d1c9504244a6469ad53"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -91,6 +84,6 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.18"
|
||||
version = "1.0.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
|
||||
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
|
||||
+6
-7
@@ -13,8 +13,7 @@
|
||||
edition = "2021"
|
||||
rust-version = "1.63.0"
|
||||
name = "either"
|
||||
version = "1.15.0"
|
||||
authors = ["bluss"]
|
||||
version = "1.16.0"
|
||||
build = false
|
||||
autolib = false
|
||||
autobins = false
|
||||
@@ -37,17 +36,17 @@ categories = [
|
||||
license = "MIT OR Apache-2.0"
|
||||
repository = "https://github.com/rayon-rs/either"
|
||||
|
||||
[package.metadata.release]
|
||||
allow-branch = ["main"]
|
||||
sign-tag = true
|
||||
tag-name = "{{version}}"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
features = ["serde"]
|
||||
|
||||
[package.metadata.playground]
|
||||
features = ["serde"]
|
||||
|
||||
[package.metadata.release]
|
||||
allow-branch = ["main"]
|
||||
sign-tag = true
|
||||
tag-name = "{{version}}"
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = []
|
||||
|
||||
+1
-2
@@ -1,7 +1,6 @@
|
||||
[package]
|
||||
name = "either"
|
||||
version = "1.15.0"
|
||||
authors = ["bluss"]
|
||||
version = "1.16.0"
|
||||
edition = "2021"
|
||||
rust-version = "1.63.0"
|
||||
|
||||
|
||||
+16
@@ -31,6 +31,22 @@ How to use with cargo::
|
||||
Recent Changes
|
||||
--------------
|
||||
|
||||
- 1.16.0
|
||||
|
||||
- Add many new methods dealing with each side, by @A4-Tacks:
|
||||
|
||||
- ``inspect_left`` and ``inspect_right`` (#124)
|
||||
|
||||
- ``left_and`` and ``right_and`` (#125)
|
||||
|
||||
- ``is_left_and`` and ``is_right_and`` (#126)
|
||||
|
||||
- ``map_left_or`` and ``map_right_or`` (#127)
|
||||
|
||||
- Add a version of ``for_both!`` with a single ``ident``, by @A4-Tacks (#128)
|
||||
|
||||
- Add a ``map_both!`` macro, by @JohnScience (#109) and @ronnodas (#137)
|
||||
|
||||
- 1.15.0
|
||||
|
||||
- Fix ``serde`` support when building without ``std``, by @klkvr (#119)
|
||||
|
||||
+6
-6
@@ -1,4 +1,4 @@
|
||||
use super::{for_both, Either, Left, Right};
|
||||
use super::{Either, Left, Right};
|
||||
use core::iter;
|
||||
|
||||
macro_rules! wrap_either {
|
||||
@@ -185,7 +185,7 @@ where
|
||||
type Item = Either<L::Item, R::Item>;
|
||||
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
Some(map_either!(self.inner, ref mut inner => inner.next()?))
|
||||
Some(map_both!(self.inner, ref mut inner => inner.next()?))
|
||||
}
|
||||
|
||||
fn size_hint(&self) -> (usize, Option<usize>) {
|
||||
@@ -211,11 +211,11 @@ where
|
||||
}
|
||||
|
||||
fn last(self) -> Option<Self::Item> {
|
||||
Some(map_either!(self.inner, inner => inner.last()?))
|
||||
Some(map_both!(self.inner, inner => inner.last()?))
|
||||
}
|
||||
|
||||
fn nth(&mut self, n: usize) -> Option<Self::Item> {
|
||||
Some(map_either!(self.inner, ref mut inner => inner.nth(n)?))
|
||||
Some(map_both!(self.inner, ref mut inner => inner.nth(n)?))
|
||||
}
|
||||
|
||||
fn collect<B>(self) -> B
|
||||
@@ -275,11 +275,11 @@ where
|
||||
R: DoubleEndedIterator,
|
||||
{
|
||||
fn next_back(&mut self) -> Option<Self::Item> {
|
||||
Some(map_either!(self.inner, ref mut inner => inner.next_back()?))
|
||||
Some(map_both!(self.inner, ref mut inner => inner.next_back()?))
|
||||
}
|
||||
|
||||
fn nth_back(&mut self, n: usize) -> Option<Self::Item> {
|
||||
Some(map_either!(self.inner, ref mut inner => inner.nth_back(n)?))
|
||||
Some(map_both!(self.inner, ref mut inner => inner.nth_back(n)?))
|
||||
}
|
||||
|
||||
fn rfold<Acc, G>(self, init: Acc, f: G) -> Acc
|
||||
|
||||
+303
-38
@@ -58,7 +58,12 @@ pub enum Either<L, R> {
|
||||
/// This macro is useful in cases where both sides of [`Either`] can be interacted with
|
||||
/// in the same way even though the don't share the same type.
|
||||
///
|
||||
/// Syntax: `either::for_both!(` *expression* `,` *pattern* `=>` *expression* `)`
|
||||
/// Syntax:
|
||||
///
|
||||
/// - `either::for_both!(` *expression* `,` *pattern* `=>` *expression* `)`
|
||||
/// - `either::for_both!(` *ident* `=>` *expression* `)`
|
||||
///
|
||||
/// Unlike [`map_both!`], this macro converges both variants to the type returned by the expression.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
@@ -77,6 +82,22 @@ pub enum Either<L, R> {
|
||||
/// assert_eq!(length(owned), 12);
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// ```
|
||||
/// use either::Either;
|
||||
///
|
||||
/// fn length(s: Either<String, Vec<u8>>) -> usize {
|
||||
/// either::for_both!(s => s.len())
|
||||
/// }
|
||||
///
|
||||
/// fn main() {
|
||||
/// let string = Either::Left("Hello world!".to_owned());
|
||||
/// let bytes = Either::Right(b"Hello world!".to_vec());
|
||||
///
|
||||
/// assert_eq!(length(string), 12);
|
||||
/// assert_eq!(length(bytes), 12);
|
||||
/// }
|
||||
/// ```
|
||||
#[macro_export]
|
||||
macro_rules! for_both {
|
||||
($value:expr, $pattern:pat => $result:expr) => {
|
||||
@@ -85,6 +106,59 @@ macro_rules! for_both {
|
||||
$crate::Either::Right($pattern) => $result,
|
||||
}
|
||||
};
|
||||
($name:ident => $result:expr) => {
|
||||
match $name {
|
||||
$crate::Either::Left($name) => $result,
|
||||
$crate::Either::Right($name) => $result,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/// Evaluate the provided expression for both [`Either::Left`] and [`Either::Right`],
|
||||
/// returning an [`Either`] with the results.
|
||||
///
|
||||
/// This macro is useful in cases where both sides of [`Either`] can be interacted with
|
||||
/// in the same way even though the don't share the same type.
|
||||
///
|
||||
/// Syntax: `either::map_both!(` *expression* `,` *pattern* `=>` *expression* `)`
|
||||
///
|
||||
/// Unlike [`for_both!`], this macro returns an [`Either`] with the results of the expressions.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use either::Either;
|
||||
///
|
||||
/// struct Wrapper<T>(T);
|
||||
///
|
||||
/// fn wrap(
|
||||
/// owned_or_borrowed: Either<String, &'static str>,
|
||||
/// ) -> Either<Wrapper<String>, Wrapper<&'static str>> {
|
||||
/// either::map_both!(owned_or_borrowed, s => Wrapper(s))
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// ```
|
||||
/// use either::Either;
|
||||
///
|
||||
/// fn widen(x: Either<i32, u32>) -> Either<i64, u64> {
|
||||
/// either::map_both!(x => x.into())
|
||||
/// }
|
||||
/// ```
|
||||
#[macro_export]
|
||||
macro_rules! map_both {
|
||||
($value:expr, $pattern:pat => $result:expr) => {
|
||||
match $value {
|
||||
$crate::Either::Left($pattern) => $crate::Either::Left($result),
|
||||
$crate::Either::Right($pattern) => $crate::Either::Right($result),
|
||||
}
|
||||
};
|
||||
($name:ident => $result:expr) => {
|
||||
match $name {
|
||||
$crate::Either::Left($name) => $crate::Either::Left($result),
|
||||
$crate::Either::Right($name) => $crate::Either::Right($result),
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/// Macro for unwrapping the left side of an [`Either`], which fails early
|
||||
@@ -130,15 +204,6 @@ macro_rules! try_right {
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! map_either {
|
||||
($value:expr, $pattern:pat => $result:expr) => {
|
||||
match $value {
|
||||
Left($pattern) => Left($result),
|
||||
Right($pattern) => Right($result),
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
mod iterator;
|
||||
pub use self::iterator::IterEither;
|
||||
|
||||
@@ -179,6 +244,56 @@ impl<L, R> Either<L, R> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns `true` if the value is [`Left`] and the value inside of it matches a predicate.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use either::*;
|
||||
///
|
||||
/// let left0: Either<i32, i32> = Left(0);
|
||||
/// let left2: Either<i32, i32> = Left(2);
|
||||
/// let right: Either<i32, i32> = Right(2);
|
||||
///
|
||||
/// assert_eq!(left2.is_left_and(|n| n > 1), true);
|
||||
/// assert_eq!(left0.is_left_and(|n| n > 1), false);
|
||||
/// assert_eq!(right.is_left_and(|n| n > 1), false);
|
||||
/// ```
|
||||
pub fn is_left_and<F>(self, f: F) -> bool
|
||||
where
|
||||
F: FnOnce(L) -> bool,
|
||||
{
|
||||
match self {
|
||||
Left(left) => f(left),
|
||||
Right(_) => false,
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns `true` if the value is [`Right`] and the value inside of it matches a predicate.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use either::*;
|
||||
///
|
||||
/// let right0: Either<i32, i32> = Right(0);
|
||||
/// let right2: Either<i32, i32> = Right(2);
|
||||
/// let left: Either<i32, i32> = Left(2);
|
||||
///
|
||||
/// assert_eq!(right2.is_right_and(|n| n > 1), true);
|
||||
/// assert_eq!(right0.is_right_and(|n| n > 1), false);
|
||||
/// assert_eq!(left.is_right_and(|n| n > 1), false);
|
||||
/// ```
|
||||
pub fn is_right_and<F>(self, f: F) -> bool
|
||||
where
|
||||
F: FnOnce(R) -> bool,
|
||||
{
|
||||
match self {
|
||||
Left(_) => false,
|
||||
Right(right) => f(right),
|
||||
}
|
||||
}
|
||||
|
||||
/// Return true if the value is the `Right` variant.
|
||||
///
|
||||
/// ```
|
||||
@@ -240,7 +355,7 @@ impl<L, R> Either<L, R> {
|
||||
/// assert_eq!(right.as_ref(), Right(&"some value"));
|
||||
/// ```
|
||||
pub fn as_ref(&self) -> Either<&L, &R> {
|
||||
map_either!(self, inner => inner)
|
||||
map_both!(self, inner => inner)
|
||||
}
|
||||
|
||||
/// Convert `&mut Either<L, R>` to `Either<&mut L, &mut R>`.
|
||||
@@ -262,7 +377,7 @@ impl<L, R> Either<L, R> {
|
||||
/// assert_eq!(right, Right(123));
|
||||
/// ```
|
||||
pub fn as_mut(&mut self) -> Either<&mut L, &mut R> {
|
||||
map_either!(self, inner => inner)
|
||||
map_both!(self, inner => inner)
|
||||
}
|
||||
|
||||
/// Convert `Pin<&Either<L, R>>` to `Either<Pin<&L>, Pin<&R>>`,
|
||||
@@ -270,7 +385,7 @@ impl<L, R> Either<L, R> {
|
||||
pub fn as_pin_ref(self: Pin<&Self>) -> Either<Pin<&L>, Pin<&R>> {
|
||||
// SAFETY: We can use `new_unchecked` because the `inner` parts are
|
||||
// guaranteed to be pinned, as they come from `self` which is pinned.
|
||||
unsafe { map_either!(Pin::get_ref(self), inner => Pin::new_unchecked(inner)) }
|
||||
unsafe { map_both!(Pin::get_ref(self), inner => Pin::new_unchecked(inner)) }
|
||||
}
|
||||
|
||||
/// Convert `Pin<&mut Either<L, R>>` to `Either<Pin<&mut L>, Pin<&mut R>>`,
|
||||
@@ -281,7 +396,7 @@ impl<L, R> Either<L, R> {
|
||||
// to be pinned, as they come from `self` which is pinned, and we never
|
||||
// offer an unpinned `&mut L` or `&mut R` through `Pin<&mut Self>`. We
|
||||
// also don't have an implementation of `Drop`, nor manual `Unpin`.
|
||||
unsafe { map_either!(Pin::get_unchecked_mut(self), inner => Pin::new_unchecked(inner)) }
|
||||
unsafe { map_both!(Pin::get_unchecked_mut(self), inner => Pin::new_unchecked(inner)) }
|
||||
}
|
||||
|
||||
/// Convert `Either<L, R>` to `Either<R, L>`.
|
||||
@@ -346,6 +461,54 @@ impl<L, R> Either<L, R> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the provided default (if [`Right`]), or
|
||||
/// applies a function to the contained value (if [`Left`]).
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use either::*;
|
||||
///
|
||||
/// let x: Either<_, i32> = Left(123);
|
||||
/// assert_eq!(x.map_left_or(0, |n| n * 2), 246);
|
||||
///
|
||||
/// let x: Either<i32, _> = Right(123);
|
||||
/// assert_eq!(x.map_left_or(0, |n| n * 2), 0);
|
||||
/// ```
|
||||
pub fn map_left_or<F, S>(self, default: S, f: F) -> S
|
||||
where
|
||||
F: FnOnce(L) -> S,
|
||||
{
|
||||
match self {
|
||||
Left(left) => f(left),
|
||||
Right(_) => default,
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the provided default (if [`Left`]), or
|
||||
/// applies a function to the contained value (if [`Right`]).
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use either::*;
|
||||
///
|
||||
/// let x: Either<_, i32> = Left(123);
|
||||
/// assert_eq!(x.map_right_or(0, |n| n * 2), 0);
|
||||
///
|
||||
/// let x: Either<i32, _> = Right(123);
|
||||
/// assert_eq!(x.map_right_or(0, |n| n * 2), 246);
|
||||
/// ```
|
||||
pub fn map_right_or<F, S>(self, default: S, f: F) -> S
|
||||
where
|
||||
F: FnOnce(R) -> S,
|
||||
{
|
||||
match self {
|
||||
Left(_) => default,
|
||||
Right(right) => f(right),
|
||||
}
|
||||
}
|
||||
|
||||
/// Apply the functions `f` and `g` to the `Left` and `Right` variants
|
||||
/// respectively. This is equivalent to
|
||||
/// [bimap](https://hackage.haskell.org/package/bifunctors-5/docs/Data-Bifunctor.html)
|
||||
@@ -462,6 +625,62 @@ impl<L, R> Either<L, R> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns `other` if the value is [`Left`], otherwise returns the [`Right`] value of `self`.
|
||||
///
|
||||
/// Arguments passed to `left_and` are eagerly evaluated; if you are passing the
|
||||
/// result of a function call, it is recommended to use [`left_and_then`], which is
|
||||
/// lazily evaluated.
|
||||
///
|
||||
/// [`left_and_then`]: Either::left_and_then
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use either::*;
|
||||
///
|
||||
/// let left: Either<_, u32> = Left(123);
|
||||
/// assert_eq!(left.left_and::<()>(Right(246)), Right(246));
|
||||
/// assert_eq!(left.left_and(Left(246)), Left(246));
|
||||
///
|
||||
/// let right: Either<u32, _> = Right(123);
|
||||
/// assert_eq!(right.left_and::<()>(Right(246)), Right(123));
|
||||
/// assert_eq!(right.left_and(Left(246)), Right(123));
|
||||
/// ```
|
||||
pub fn left_and<S>(self, other: Either<S, R>) -> Either<S, R> {
|
||||
match self {
|
||||
Left(_) => other,
|
||||
Right(r) => Right(r),
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns `other` if the value is [`Right`], otherwise returns the [`Left`] value of `self`.
|
||||
///
|
||||
/// Arguments passed to `right_and` are eagerly evaluated; if you are passing the
|
||||
/// result of a function call, it is recommended to use [`right_and_then`], which is
|
||||
/// lazily evaluated.
|
||||
///
|
||||
/// [`right_and_then`]: Either::right_and_then
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use either::*;
|
||||
///
|
||||
/// let left: Either<_, u32> = Left(123);
|
||||
/// assert_eq!(left.right_and(Right(246)), Left(123));
|
||||
/// assert_eq!(left.right_and::<()>(Left(246)), Left(123));
|
||||
///
|
||||
/// let right: Either<u32, _> = Right(123);
|
||||
/// assert_eq!(right.right_and(Right(246)), Right(246));
|
||||
/// assert_eq!(right.right_and::<()>(Left(246)), Left(246));
|
||||
/// ```
|
||||
pub fn right_and<S>(self, other: Either<L, S>) -> Either<L, S> {
|
||||
match self {
|
||||
Left(l) => Left(l),
|
||||
Right(_) => other,
|
||||
}
|
||||
}
|
||||
|
||||
/// Apply the function `f` on the value in the `Left` variant if it is present.
|
||||
///
|
||||
/// ```
|
||||
@@ -523,7 +742,7 @@ impl<L, R> Either<L, R> {
|
||||
L: IntoIterator,
|
||||
R: IntoIterator<Item = L::Item>,
|
||||
{
|
||||
map_either!(self, inner => inner.into_iter())
|
||||
map_both!(self, inner => inner.into_iter())
|
||||
}
|
||||
|
||||
/// Borrow the inner value as an iterator.
|
||||
@@ -546,7 +765,7 @@ impl<L, R> Either<L, R> {
|
||||
for<'a> &'a L: IntoIterator,
|
||||
for<'a> &'a R: IntoIterator<Item = <&'a L as IntoIterator>::Item>,
|
||||
{
|
||||
map_either!(self, inner => inner.into_iter())
|
||||
map_both!(self, inner => inner.into_iter())
|
||||
}
|
||||
|
||||
/// Mutably borrow the inner value as an iterator.
|
||||
@@ -577,7 +796,7 @@ impl<L, R> Either<L, R> {
|
||||
for<'a> &'a mut L: IntoIterator,
|
||||
for<'a> &'a mut R: IntoIterator<Item = <&'a mut L as IntoIterator>::Item>,
|
||||
{
|
||||
map_either!(self, inner => inner.into_iter())
|
||||
map_both!(self, inner => inner.into_iter())
|
||||
}
|
||||
|
||||
/// Converts an `Either` of `Iterator`s to be an `Iterator` of `Either`s
|
||||
@@ -594,14 +813,12 @@ impl<L, R> Either<L, R> {
|
||||
/// assert_eq!(right.factor_into_iter().collect::<Vec<_>>(), vec![Right(0), Right(1)]);
|
||||
///
|
||||
/// ```
|
||||
// TODO(MSRV): doc(alias) was stabilized in Rust 1.48
|
||||
// #[doc(alias = "transpose")]
|
||||
pub fn factor_into_iter(self) -> IterEither<L::IntoIter, R::IntoIter>
|
||||
where
|
||||
L: IntoIterator,
|
||||
R: IntoIterator,
|
||||
{
|
||||
IterEither::new(map_either!(self, inner => inner.into_iter()))
|
||||
IterEither::new(map_both!(self, inner => inner.into_iter()))
|
||||
}
|
||||
|
||||
/// Borrows an `Either` of `Iterator`s to be an `Iterator` of `Either`s
|
||||
@@ -625,7 +842,7 @@ impl<L, R> Either<L, R> {
|
||||
for<'a> &'a L: IntoIterator,
|
||||
for<'a> &'a R: IntoIterator,
|
||||
{
|
||||
IterEither::new(map_either!(self, inner => inner.into_iter()))
|
||||
IterEither::new(map_both!(self, inner => inner.into_iter()))
|
||||
}
|
||||
|
||||
/// Mutably borrows an `Either` of `Iterator`s to be an `Iterator` of `Either`s
|
||||
@@ -651,7 +868,7 @@ impl<L, R> Either<L, R> {
|
||||
for<'a> &'a mut L: IntoIterator,
|
||||
for<'a> &'a mut R: IntoIterator,
|
||||
{
|
||||
IterEither::new(map_either!(self, inner => inner.into_iter()))
|
||||
IterEither::new(map_both!(self, inner => inner.into_iter()))
|
||||
}
|
||||
|
||||
/// Return left value or given value
|
||||
@@ -807,6 +1024,7 @@ impl<L, R> Either<L, R> {
|
||||
/// let right: Either<(), _> = Right(3);
|
||||
/// right.unwrap_left();
|
||||
/// ```
|
||||
#[track_caller]
|
||||
pub fn unwrap_left(self) -> L
|
||||
where
|
||||
R: core::fmt::Debug,
|
||||
@@ -838,6 +1056,7 @@ impl<L, R> Either<L, R> {
|
||||
/// let left: Either<_, ()> = Left(3);
|
||||
/// left.unwrap_right();
|
||||
/// ```
|
||||
#[track_caller]
|
||||
pub fn unwrap_right(self) -> R
|
||||
where
|
||||
L: core::fmt::Debug,
|
||||
@@ -867,6 +1086,7 @@ impl<L, R> Either<L, R> {
|
||||
/// let right: Either<(), _> = Right(3);
|
||||
/// right.expect_left("value was Right");
|
||||
/// ```
|
||||
#[track_caller]
|
||||
pub fn expect_left(self, msg: &str) -> L
|
||||
where
|
||||
R: core::fmt::Debug,
|
||||
@@ -896,6 +1116,7 @@ impl<L, R> Either<L, R> {
|
||||
/// let left: Either<_, ()> = Left(3);
|
||||
/// left.expect_right("value was Right");
|
||||
/// ```
|
||||
#[track_caller]
|
||||
pub fn expect_right(self, msg: &str) -> R
|
||||
where
|
||||
L: core::fmt::Debug,
|
||||
@@ -906,6 +1127,56 @@ impl<L, R> Either<L, R> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Calls a function with a reference to the contained value if [`Left`].
|
||||
///
|
||||
/// Returns the original self.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use either::*;
|
||||
///
|
||||
/// # fn foo() -> Either<u32, u32> { Right(2) }
|
||||
/// let x = foo()
|
||||
/// .inspect_left(|n| println!("left: {n}"))
|
||||
/// .left_or(0);
|
||||
/// ```
|
||||
pub fn inspect_left<F>(self, f: F) -> Self
|
||||
where
|
||||
F: FnOnce(&L),
|
||||
{
|
||||
if let Left(ref left) = self {
|
||||
f(left);
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
/// Calls a function with a reference to the contained value if [`Right`].
|
||||
///
|
||||
/// Returns the original self.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use either::*;
|
||||
///
|
||||
/// # fn foo() -> Either<u32, u32> { Right(2) }
|
||||
/// let x = foo()
|
||||
/// .inspect_right(|n| println!("right: {n}"))
|
||||
/// .left_or(0);
|
||||
/// ```
|
||||
pub fn inspect_right<F>(self, f: F) -> Self
|
||||
where
|
||||
F: FnOnce(&R),
|
||||
{
|
||||
if let Right(ref right) = self {
|
||||
f(right);
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
/// Convert the contained value into `T`
|
||||
///
|
||||
/// # Examples
|
||||
@@ -938,8 +1209,7 @@ impl<L, R> Either<Option<L>, Option<R>> {
|
||||
/// let right: Either<Option<Vec<u8>>, _> = Right(Some(String::new()));
|
||||
/// assert_eq!(right.factor_none(), Some(Right(String::new())));
|
||||
/// ```
|
||||
// TODO(MSRV): doc(alias) was stabilized in Rust 1.48
|
||||
// #[doc(alias = "transpose")]
|
||||
#[doc(alias = "transpose")]
|
||||
pub fn factor_none(self) -> Option<Either<L, R>> {
|
||||
match self {
|
||||
Left(l) => l.map(Either::Left),
|
||||
@@ -949,7 +1219,7 @@ impl<L, R> Either<Option<L>, Option<R>> {
|
||||
}
|
||||
|
||||
impl<L, R, E> Either<Result<L, E>, Result<R, E>> {
|
||||
/// Factors out a homogenous type from an `Either` of [`Result`].
|
||||
/// Factors out a homogeneous type from an `Either` of [`Result`].
|
||||
///
|
||||
/// Here, the homogeneous type is the `Err` type of the [`Result`].
|
||||
///
|
||||
@@ -961,8 +1231,7 @@ impl<L, R, E> Either<Result<L, E>, Result<R, E>> {
|
||||
/// let right: Either<Result<Vec<u8>, u32>, _> = Right(Ok(String::new()));
|
||||
/// assert_eq!(right.factor_err(), Ok(Right(String::new())));
|
||||
/// ```
|
||||
// TODO(MSRV): doc(alias) was stabilized in Rust 1.48
|
||||
// #[doc(alias = "transpose")]
|
||||
#[doc(alias = "transpose")]
|
||||
pub fn factor_err(self) -> Result<Either<L, R>, E> {
|
||||
match self {
|
||||
Left(l) => l.map(Either::Left),
|
||||
@@ -972,7 +1241,7 @@ impl<L, R, E> Either<Result<L, E>, Result<R, E>> {
|
||||
}
|
||||
|
||||
impl<T, L, R> Either<Result<T, L>, Result<T, R>> {
|
||||
/// Factors out a homogenous type from an `Either` of [`Result`].
|
||||
/// Factors out a homogeneous type from an `Either` of [`Result`].
|
||||
///
|
||||
/// Here, the homogeneous type is the `Ok` type of the [`Result`].
|
||||
///
|
||||
@@ -984,8 +1253,7 @@ impl<T, L, R> Either<Result<T, L>, Result<T, R>> {
|
||||
/// let right: Either<Result<u32, Vec<u8>>, _> = Right(Err(String::new()));
|
||||
/// assert_eq!(right.factor_ok(), Err(Right(String::new())));
|
||||
/// ```
|
||||
// TODO(MSRV): doc(alias) was stabilized in Rust 1.48
|
||||
// #[doc(alias = "transpose")]
|
||||
#[doc(alias = "transpose")]
|
||||
pub fn factor_ok(self) -> Result<T, Either<L, R>> {
|
||||
match self {
|
||||
Left(l) => l.map_err(Either::Left),
|
||||
@@ -1067,10 +1335,7 @@ impl<T> Either<T, T> {
|
||||
where
|
||||
F: FnOnce(T) -> M,
|
||||
{
|
||||
match self {
|
||||
Left(l) => Left(f(l)),
|
||||
Right(r) => Right(f(r)),
|
||||
}
|
||||
map_both!(self, t => f(t))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1082,7 +1347,7 @@ impl<L, R> Either<&L, &R> {
|
||||
L: Clone,
|
||||
R: Clone,
|
||||
{
|
||||
map_either!(self, inner => inner.clone())
|
||||
map_both!(self, inner => inner.clone())
|
||||
}
|
||||
|
||||
/// Maps an `Either<&L, &R>` to an `Either<L, R>` by copying the contents of
|
||||
@@ -1092,7 +1357,7 @@ impl<L, R> Either<&L, &R> {
|
||||
L: Copy,
|
||||
R: Copy,
|
||||
{
|
||||
map_either!(self, inner => *inner)
|
||||
map_both!(self, inner => *inner)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1104,7 +1369,7 @@ impl<L, R> Either<&mut L, &mut R> {
|
||||
L: Clone,
|
||||
R: Clone,
|
||||
{
|
||||
map_either!(self, inner => inner.clone())
|
||||
map_both!(self, inner => inner.clone())
|
||||
}
|
||||
|
||||
/// Maps an `Either<&mut L, &mut R>` to an `Either<L, R>` by copying the contents of
|
||||
@@ -1114,7 +1379,7 @@ impl<L, R> Either<&mut L, &mut R> {
|
||||
L: Copy,
|
||||
R: Copy,
|
||||
{
|
||||
map_either!(self, inner => *inner)
|
||||
map_both!(self, inner => *inner)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -1,9 +1,9 @@
|
||||
//! Untagged serialization/deserialization support for Either<L, R>.
|
||||
//! Untagged serialization/deserialization support for `Either<L, R>`.
|
||||
//!
|
||||
//! `Either` uses default, externally-tagged representation.
|
||||
//! However, sometimes it is useful to support several alternative types.
|
||||
//! For example, we may have a field which is generally Map<String, i32>
|
||||
//! but in typical cases Vec<String> would suffice, too.
|
||||
//! For example, we may have a field which is generally a `HashMap<String, i32>`
|
||||
//! but in typical cases `Vec<String>` would suffice, too.
|
||||
//!
|
||||
//! ```rust
|
||||
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//! Untagged serialization/deserialization support for Option<Either<L, R>>.
|
||||
//! Untagged serialization/deserialization support for `Option<Either<L, R>>`.
|
||||
//!
|
||||
//! `Either` uses default, externally-tagged representation.
|
||||
//! However, sometimes it is useful to support several alternative types.
|
||||
//! For example, we may have a field which is generally Map<String, i32>
|
||||
//! but in typical cases Vec<String> would suffice, too.
|
||||
//! For example, we may have a field which is generally a `HashMap<String, i32>`
|
||||
//! but in typical cases `Vec<String>` would suffice, too.
|
||||
//!
|
||||
//! ```rust
|
||||
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
+10
-2
@@ -11,7 +11,7 @@
|
||||
//! * [`Unicode Extensions`] - marked as `u`.
|
||||
//! * [`Transform Extensions`] - marked as `t`.
|
||||
//! * [`Private Use Extensions`] - marked as `x`.
|
||||
//! * [`Other Extensions`] - marked as any `a-z` except of `u`, `t` and `x`.
|
||||
//! * [`Other Extensions`] - marked as any `a-z` or `0-9` except `u`, `t`, and `x`.
|
||||
//!
|
||||
//! One can think of extensions as a bag of extra information on top of basic 4 [`subtags`].
|
||||
//!
|
||||
@@ -102,7 +102,7 @@ impl ExtensionType {
|
||||
UNICODE_EXT_CHAR => Ok(Self::Unicode),
|
||||
TRANSFORM_EXT_CHAR => Ok(Self::Transform),
|
||||
PRIVATE_EXT_CHAR => Ok(Self::Private),
|
||||
'a'..='z' => Ok(Self::Other(key)),
|
||||
'a'..='z' | '0'..='9' => Ok(Self::Other(key)),
|
||||
_ => Err(ParseError::InvalidExtension),
|
||||
}
|
||||
}
|
||||
@@ -397,4 +397,12 @@ fn test_writeable() {
|
||||
.extensions,
|
||||
"a-foo-t-foo-u-foo-w-foo-z-foo-x-foo",
|
||||
);
|
||||
assert_writeable_eq!(
|
||||
"en-1-ext-value".parse::<Locale>().unwrap().extensions,
|
||||
"1-ext-value",
|
||||
);
|
||||
assert_writeable_eq!(
|
||||
"und-a-foo-1-bar".parse::<Locale>().unwrap().extensions,
|
||||
"1-bar-a-foo",
|
||||
);
|
||||
}
|
||||
@@ -93,7 +93,7 @@ impl Other {
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
/// Panics if `ext` is not ASCII alphabetic.
|
||||
/// Panics if `ext` is not ASCII alphanumeric.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
@@ -114,7 +114,7 @@ impl Other {
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub(crate) fn from_short_slice_unchecked(ext: u8, keys: ShortBoxSlice<Subtag>) -> Self {
|
||||
assert!(ext.is_ascii_alphabetic());
|
||||
assert!(ext.is_ascii_alphanumeric());
|
||||
// Safety invariant upheld here: ext checked as ASCII above
|
||||
Self { ext, keys }
|
||||
}
|
||||
@@ -156,7 +156,7 @@ impl Other {
|
||||
/// assert_eq!(other_ext.get_ext_str(), "a");
|
||||
/// ```
|
||||
pub fn get_ext_str(&self) -> &str {
|
||||
debug_assert!(self.ext.is_ascii_alphabetic());
|
||||
debug_assert!(self.ext.is_ascii_alphanumeric());
|
||||
// Safety: from safety invariant on self.ext (that it is ASCII)
|
||||
unsafe { core::str::from_utf8_unchecked(core::slice::from_ref(&self.ext)) }
|
||||
}
|
||||
@@ -254,6 +254,9 @@ mod tests {
|
||||
let oe: Other = "o-foo-bar".parse().expect("Failed to parse Other");
|
||||
assert_eq!(oe.to_string(), "o-foo-bar");
|
||||
|
||||
let oe: Other = "1-foo-bar".parse().expect("Failed to parse Other");
|
||||
assert_eq!(oe.to_string(), "1-foo-bar");
|
||||
|
||||
let oe: Result<Other, _> = "o".parse();
|
||||
assert!(oe.is_err());
|
||||
}
|
||||
|
||||
@@ -294,5 +294,38 @@
|
||||
"type": "Locale",
|
||||
"identifier": "en-a-bar-u-foo-w-bar-x-u-foo"
|
||||
}
|
||||
},
|
||||
{
|
||||
"input": {
|
||||
"type": "Locale",
|
||||
"identifier": "en-1-ext-value"
|
||||
},
|
||||
"output": {
|
||||
"type": "Locale",
|
||||
"language": "en",
|
||||
"extensions": {
|
||||
"other": ["1-ext-value"]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"input": {
|
||||
"type": "Locale",
|
||||
"identifier": "en-w-bar-1-foo"
|
||||
},
|
||||
"output": {
|
||||
"type": "Locale",
|
||||
"identifier": "en-1-foo-w-bar"
|
||||
}
|
||||
},
|
||||
{
|
||||
"input": {
|
||||
"type": "Locale",
|
||||
"identifier": "en-w-bar-1-foo-u-baz"
|
||||
},
|
||||
"output": {
|
||||
"type": "Locale",
|
||||
"identifier": "en-1-foo-u-baz-w-bar"
|
||||
}
|
||||
}
|
||||
]
|
||||
+10
-1
@@ -5,6 +5,7 @@
|
||||
use std::collections::HashMap;
|
||||
use std::convert::{TryFrom, TryInto};
|
||||
|
||||
use icu_locale_core::extensions::other;
|
||||
use icu_locale_core::extensions::private;
|
||||
use icu_locale_core::extensions::transform;
|
||||
use icu_locale_core::extensions::unicode;
|
||||
@@ -40,7 +41,8 @@ pub struct LocaleExtensions {
|
||||
transform: Option<LocaleExtensionTransform>,
|
||||
#[serde(default)]
|
||||
private: Vec<String>,
|
||||
_other: Option<String>,
|
||||
#[serde(default)]
|
||||
other: Vec<String>,
|
||||
}
|
||||
|
||||
impl TryFrom<LocaleExtensions> for Extensions {
|
||||
@@ -95,6 +97,13 @@ impl TryFrom<LocaleExtensions> for Extensions {
|
||||
.map(|v| private::Subtag::try_from_str(v).expect("Failed to add field."))
|
||||
.collect();
|
||||
ext.private = private::Private::from_vec_unchecked(v);
|
||||
let mut other: Vec<other::Other> = input
|
||||
.other
|
||||
.iter()
|
||||
.map(|v| other::Other::try_from_str(v).expect("Failed to parse Other extension"))
|
||||
.collect();
|
||||
other.sort();
|
||||
ext.other = other;
|
||||
Ok(ext)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,3 +117,18 @@ fn test_locale_strict_cmp() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_locale_total_cmp() {
|
||||
let l_1_bar = "und-1-bar".parse::<Locale>().unwrap();
|
||||
let l_a_foo = "und-a-foo".parse::<Locale>().unwrap();
|
||||
let l_2_baz = "und-2-baz".parse::<Locale>().unwrap();
|
||||
|
||||
assert_eq!(l_1_bar.total_cmp(&l_a_foo), std::cmp::Ordering::Less);
|
||||
assert_eq!(l_1_bar.total_cmp(&l_2_baz), std::cmp::Ordering::Less);
|
||||
assert_eq!(l_2_baz.total_cmp(&l_a_foo), std::cmp::Ordering::Less);
|
||||
|
||||
let l_en_1 = "en-1-ext-value".parse::<Locale>().unwrap();
|
||||
let l_en_a = "en-a-ext-value".parse::<Locale>().unwrap();
|
||||
assert_eq!(l_en_1.total_cmp(&l_en_a), std::cmp::Ordering::Less);
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"git": {
|
||||
"sha1": "29dfe2790b6cfdab94ca6a6b69f58ce54802dbf7"
|
||||
"sha1": "c9fac4e625ccb2c6a7aa35079fff9709db4385ac"
|
||||
},
|
||||
"path_in_vcs": "utils/ixdtf"
|
||||
}
|
||||
+53
-67
@@ -4,9 +4,9 @@ version = 3
|
||||
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
version = "1.1.3"
|
||||
version = "1.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
|
||||
checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
@@ -19,9 +19,9 @@ checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299"
|
||||
|
||||
[[package]]
|
||||
name = "anstyle"
|
||||
version = "1.0.13"
|
||||
version = "1.0.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78"
|
||||
checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000"
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
@@ -31,9 +31,9 @@ checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
|
||||
|
||||
[[package]]
|
||||
name = "bumpalo"
|
||||
version = "3.19.0"
|
||||
version = "3.20.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43"
|
||||
checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb"
|
||||
|
||||
[[package]]
|
||||
name = "cast"
|
||||
@@ -210,13 +210,13 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "1.0.15"
|
||||
version = "1.0.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
|
||||
checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
|
||||
|
||||
[[package]]
|
||||
name = "ixdtf"
|
||||
version = "0.6.4"
|
||||
version = "0.6.5"
|
||||
dependencies = [
|
||||
"criterion",
|
||||
"serde-json-core",
|
||||
@@ -224,9 +224,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "js-sys"
|
||||
version = "0.3.81"
|
||||
version = "0.3.91"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec48937a97411dcb524a265206ccd4c90bb711fca92b2792c407f268825b9305"
|
||||
checksum = "b49715b7073f385ba4bc528e5747d02e66cb39c6146efb66b781f131f0fb399c"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
"wasm-bindgen",
|
||||
@@ -234,21 +234,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.177"
|
||||
version = "0.2.183"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2874a2af47a2325c2001a6e6fad9b16a53b802102b528163885171cf92b15976"
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.28"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432"
|
||||
checksum = "b5b646652bf6661599e1da8901b3b9522896f01e736bad5f723fe7a3a27f899d"
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.7.6"
|
||||
version = "2.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273"
|
||||
checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79"
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
@@ -261,9 +255,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.21.3"
|
||||
version = "1.21.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
|
||||
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
|
||||
|
||||
[[package]]
|
||||
name = "oorandom"
|
||||
@@ -301,18 +295,18 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.103"
|
||||
version = "1.0.106"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5ee95bc4ef87b8d5ba32e8b7714ccc834865276eab0aed5c9958d00ec45f49e8"
|
||||
checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.41"
|
||||
version = "1.0.45"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ce25767e7b499d1b604768e7cde645d14cc8584231ea6b295e9c9eb22c02e1d1"
|
||||
checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
@@ -339,9 +333,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.12.2"
|
||||
version = "1.12.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "843bc0191f75f3e22651ae5f1e72939ab2f72a4bc30fa80a066bd66edefc24d4"
|
||||
checksum = "e10754a14b9137dd7b1e3e5b0493cc9171fdd105e0ab477f51b72e7f3ac0e276"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
@@ -351,9 +345,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "regex-automata"
|
||||
version = "0.4.13"
|
||||
version = "0.4.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5276caf25ac86c8d810222b3dbb938e512c55c6831a10f3e6ed1c93b84041f1c"
|
||||
checksum = "6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8f"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
@@ -362,9 +356,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.8.8"
|
||||
version = "0.8.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58"
|
||||
checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a"
|
||||
|
||||
[[package]]
|
||||
name = "rustversion"
|
||||
@@ -374,9 +368,9 @@ checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
|
||||
|
||||
[[package]]
|
||||
name = "ryu"
|
||||
version = "1.0.20"
|
||||
version = "1.0.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f"
|
||||
checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f"
|
||||
|
||||
[[package]]
|
||||
name = "same-file"
|
||||
@@ -429,22 +423,22 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.145"
|
||||
version = "1.0.149"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "402a6f66d8c709116cf22f558eab210f5a50187f702eb4d7e5ef38d9a7f1c79c"
|
||||
checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"memchr",
|
||||
"ryu",
|
||||
"serde",
|
||||
"serde_core",
|
||||
"zmij",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.108"
|
||||
version = "2.0.117"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "da58917d35242480a05c2897064da0a80589a2a0476c9a3f2fdc83b53502e917"
|
||||
checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -463,9 +457,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.20"
|
||||
version = "1.0.24"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "462eeb75aeb73aea900253ce739c8e18a67423fadf006037cd3ff27e82748a06"
|
||||
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
|
||||
|
||||
[[package]]
|
||||
name = "walkdir"
|
||||
@@ -479,9 +473,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen"
|
||||
version = "0.2.104"
|
||||
version = "0.2.114"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c1da10c01ae9f1ae40cbfac0bac3b1e724b320abfcf52229f80b547c0d250e2d"
|
||||
checksum = "6532f9a5c1ece3798cb1c2cfdba640b9b3ba884f5db45973a6f442510a87d38e"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"once_cell",
|
||||
@@ -490,25 +484,11 @@ dependencies = [
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-backend"
|
||||
version = "0.2.104"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "671c9a5a66f49d8a47345ab942e2cb93c7d1d0339065d4f8139c486121b43b19"
|
||||
dependencies = [
|
||||
"bumpalo",
|
||||
"log",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro"
|
||||
version = "0.2.104"
|
||||
version = "0.2.114"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7ca60477e4c59f5f2986c50191cd972e3a50d8a95603bc9434501cf156a9a119"
|
||||
checksum = "18a2d50fcf105fb33bb15f00e7a77b772945a2ee45dcf454961fd843e74c18e6"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"wasm-bindgen-macro-support",
|
||||
@@ -516,31 +496,31 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro-support"
|
||||
version = "0.2.104"
|
||||
version = "0.2.114"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9f07d2f20d4da7b26400c9f4a0511e6e0345b040694e8a75bd41d578fa4421d7"
|
||||
checksum = "03ce4caeaac547cdf713d280eda22a730824dd11e6b8c3ca9e42247b25c631e3"
|
||||
dependencies = [
|
||||
"bumpalo",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"wasm-bindgen-backend",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-shared"
|
||||
version = "0.2.104"
|
||||
version = "0.2.114"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bad67dc8b2a1a6e5448428adec4c3e84c43e561d8c9ee8a9e5aabeb193ec41d1"
|
||||
checksum = "75a326b8c223ee17883a4251907455a2431acc2791c98c26279376490c378c16"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "web-sys"
|
||||
version = "0.3.81"
|
||||
version = "0.3.91"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9367c417a924a74cae129e6a2ae3b47fabb1f8995595ab474029da749a8be120"
|
||||
checksum = "854ba17bb104abfb26ba36da9729addc7ce7f06f5c0f90f3c391f8461cca21f9"
|
||||
dependencies = [
|
||||
"js-sys",
|
||||
"wasm-bindgen",
|
||||
@@ -569,3 +549,9 @@ checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"
|
||||
dependencies = [
|
||||
"windows-link",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zmij"
|
||||
version = "1.0.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa"
|
||||
+60
-2
@@ -13,7 +13,7 @@
|
||||
edition = "2021"
|
||||
rust-version = "1.82"
|
||||
name = "ixdtf"
|
||||
version = "0.6.4"
|
||||
version = "0.6.5"
|
||||
authors = ["The ICU4X Project Developers"]
|
||||
build = false
|
||||
include = [
|
||||
@@ -35,7 +35,16 @@ autobenches = false
|
||||
description = "Parser for Internet eXtended DateTime Format"
|
||||
homepage = "https://icu4x.unicode.org"
|
||||
readme = "README.md"
|
||||
categories = ["internationalization"]
|
||||
keywords = [
|
||||
"iso8601",
|
||||
"date-time",
|
||||
]
|
||||
categories = [
|
||||
"internationalization",
|
||||
"localization",
|
||||
"no-std",
|
||||
"embedded",
|
||||
]
|
||||
license = "Unicode-3.0"
|
||||
repository = "https://github.com/unicode-org/icu4x"
|
||||
|
||||
@@ -65,3 +74,52 @@ default-features = false
|
||||
|
||||
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies.criterion]
|
||||
version = "0.5.0"
|
||||
|
||||
[lints.clippy]
|
||||
alloc-instead-of-core = "warn"
|
||||
branches-sharing-code = "warn"
|
||||
collection_is_never_read = "warn"
|
||||
crosspointer_transmute = "warn"
|
||||
dbg_macro = "warn"
|
||||
debug_assert_with_mut_call = "warn"
|
||||
doc_markdown = "warn"
|
||||
exhaustive_enums = "deny"
|
||||
exhaustive_structs = "deny"
|
||||
fn_to_numeric_cast_any = "warn"
|
||||
infinite_loop = "warn"
|
||||
large_stack_arrays = "warn"
|
||||
mismatching_type_param_order = "warn"
|
||||
missing_fields_in_debug = "warn"
|
||||
missing_transmute_annotations = "warn"
|
||||
negative_feature_names = "warn"
|
||||
or-fun-call = "warn"
|
||||
same_functions_in_if_condition = "warn"
|
||||
todo = "warn"
|
||||
transmute_bytes_to_str = "warn"
|
||||
transmute_int_to_bool = "warn"
|
||||
transmute_int_to_non_zero = "warn"
|
||||
transmute_ptr_to_ptr = "warn"
|
||||
transmute_ptr_to_ref = "warn"
|
||||
transmute_undefined_repr = "warn"
|
||||
transmutes_expressible_as_ptr_casts = "warn"
|
||||
trivially_copy_pass_by_ref = "deny"
|
||||
unnecessary-wraps = "warn"
|
||||
useless_transmute = "warn"
|
||||
wildcard_dependencies = "warn"
|
||||
|
||||
[lints.rust]
|
||||
missing_debug_implementations = "deny"
|
||||
trivial_numeric_casts = "deny"
|
||||
unused_lifetimes = "warn"
|
||||
unused_macro_rules = "warn"
|
||||
unused_qualifications = "warn"
|
||||
|
||||
[lints.rust.unexpected_cfgs]
|
||||
level = "warn"
|
||||
priority = 0
|
||||
check-cfg = [
|
||||
"cfg(icu4c_enable_renaming)",
|
||||
"cfg(needs_alloc_error_handler)",
|
||||
"cfg(icu4x_run_size_tests)",
|
||||
"cfg(icu4x_unstable_fast_trie_only)",
|
||||
]
|
||||
+6
-2
@@ -5,10 +5,11 @@
|
||||
[package]
|
||||
name = "ixdtf"
|
||||
description = "Parser for Internet eXtended DateTime Format"
|
||||
version = "0.6.4"
|
||||
version = "0.6.5"
|
||||
categories.workspace = true
|
||||
keywords = ["iso8601", "date-time"]
|
||||
|
||||
authors.workspace = true
|
||||
categories.workspace = true
|
||||
edition.workspace = true
|
||||
homepage.workspace = true
|
||||
include.workspace = true
|
||||
@@ -36,3 +37,6 @@ criterion = { workspace = true }
|
||||
|
||||
[package.metadata.cargo-semver-checks.lints]
|
||||
workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
+3
-76
@@ -4,82 +4,9 @@
|
||||
|
||||
//! Core functionality for `ixdtf`'s parsers
|
||||
|
||||
use crate::encoding::EncodingType;
|
||||
use crate::{ParseError, ParserResult};
|
||||
|
||||
mod private {
|
||||
pub trait Sealed {}
|
||||
}
|
||||
|
||||
/// A trait for defining various supported encodings
|
||||
/// and implementing functionality that is encoding
|
||||
/// sensitive / specific.
|
||||
pub trait EncodingType: private::Sealed {
|
||||
type CodeUnit: PartialEq + core::fmt::Debug + Clone;
|
||||
|
||||
/// Get a slice from the underlying source using for start..end
|
||||
fn slice(source: &[Self::CodeUnit], start: usize, end: usize) -> Option<&[Self::CodeUnit]>;
|
||||
|
||||
/// Retrieve the provided code unit index and returns the value as an ASCII byte
|
||||
/// or None if the value is not ASCII representable.
|
||||
fn get_ascii(source: &[Self::CodeUnit], index: usize) -> ParserResult<Option<u8>>;
|
||||
|
||||
/// Checks for the known calendar annotation key `u-ca`.
|
||||
fn check_calendar_key(key: &[Self::CodeUnit]) -> bool;
|
||||
}
|
||||
|
||||
/// A marker type that signals a parser should parse the source as UTF-16 bytes.
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
#[allow(clippy::exhaustive_structs)] // ZST Marker trait, no fields should be added
|
||||
pub struct Utf16;
|
||||
|
||||
impl private::Sealed for Utf16 {}
|
||||
|
||||
impl EncodingType for Utf16 {
|
||||
type CodeUnit = u16;
|
||||
fn slice(source: &[Self::CodeUnit], start: usize, end: usize) -> Option<&[Self::CodeUnit]> {
|
||||
source.get(start..end)
|
||||
}
|
||||
|
||||
fn get_ascii(source: &[Self::CodeUnit], index: usize) -> ParserResult<Option<u8>> {
|
||||
source.get(index).copied().map(to_ascii_byte).transpose()
|
||||
}
|
||||
|
||||
fn check_calendar_key(key: &[Self::CodeUnit]) -> bool {
|
||||
key == [0x75, 0x2d, 0x63, 0x61]
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn to_ascii_byte(b: u16) -> ParserResult<u8> {
|
||||
if !(0x01..0x7F).contains(&b) {
|
||||
return Err(ParseError::NonAsciiCodePoint);
|
||||
}
|
||||
Ok(b as u8)
|
||||
}
|
||||
|
||||
/// A marker type that signals a parser should parse the source as UTF-8 bytes.
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
#[allow(clippy::exhaustive_structs)] // ZST Marker trait, no fields should be added.
|
||||
pub struct Utf8;
|
||||
|
||||
impl private::Sealed for Utf8 {}
|
||||
|
||||
impl EncodingType for Utf8 {
|
||||
type CodeUnit = u8;
|
||||
|
||||
fn slice<'a>(source: &[Self::CodeUnit], start: usize, end: usize) -> Option<&[Self::CodeUnit]> {
|
||||
source.get(start..end)
|
||||
}
|
||||
|
||||
fn get_ascii(source: &[Self::CodeUnit], index: usize) -> ParserResult<Option<u8>> {
|
||||
Ok(source.get(index).copied())
|
||||
}
|
||||
|
||||
fn check_calendar_key(key: &[Self::CodeUnit]) -> bool {
|
||||
key == "u-ca".as_bytes()
|
||||
}
|
||||
}
|
||||
|
||||
// ==== Mini cursor implementation for Iso8601 targets ====
|
||||
|
||||
/// `Cursor` is a small cursor implementation for parsing Iso8601 grammar.
|
||||
@@ -152,7 +79,7 @@ impl<'a, T: EncodingType> Cursor<'a, T> {
|
||||
/// Returns the next value as a digit
|
||||
///
|
||||
/// # Errors
|
||||
/// - Returns an AbruptEnd error if cursor ends.
|
||||
/// - Returns an [`ParseError::AbruptEnd`] error if cursor ends.
|
||||
pub(crate) fn next_digit(&mut self) -> ParserResult<Option<u8>> {
|
||||
let ascii_char = self.next_or(ParseError::AbruptEnd { location: "digit" })?;
|
||||
if ascii_char.is_ascii_digit() {
|
||||
@@ -162,7 +89,7 @@ impl<'a, T: EncodingType> Cursor<'a, T> {
|
||||
}
|
||||
}
|
||||
|
||||
/// A utility next method that returns an `AbruptEnd` error if invalid.
|
||||
/// A utility next method that returns an [`ParseError::AbruptEnd`] error if invalid.
|
||||
pub(crate) fn next_or(&mut self, err: ParseError) -> ParserResult<u8> {
|
||||
self.next()?.ok_or(err)
|
||||
}
|
||||
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
// This file is part of ICU4X. For terms of use, please see the file
|
||||
// called LICENSE at the top level of the ICU4X source tree
|
||||
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
|
||||
|
||||
//! This module contains the supported encoding for `ixdtf` parsing.
|
||||
|
||||
use crate::{ParseError, ParserResult};
|
||||
|
||||
mod private {
|
||||
pub trait Sealed {}
|
||||
}
|
||||
|
||||
/// A trait for defining various supported encodings
|
||||
/// and implementing functionality that is encoding
|
||||
/// sensitive / specific.
|
||||
pub trait EncodingType: private::Sealed {
|
||||
/// The code unit for the current encoding.
|
||||
type CodeUnit: PartialEq + core::fmt::Debug + Clone;
|
||||
|
||||
/// Get a slice from the underlying source using for start..end
|
||||
#[doc(hidden)]
|
||||
fn slice(source: &[Self::CodeUnit], start: usize, end: usize) -> Option<&[Self::CodeUnit]>;
|
||||
|
||||
/// Retrieve the provided code unit index and returns the value as an ASCII byte
|
||||
/// or None if the value is not ASCII representable.
|
||||
#[doc(hidden)]
|
||||
fn get_ascii(source: &[Self::CodeUnit], index: usize) -> ParserResult<Option<u8>>;
|
||||
|
||||
/// Checks for the known calendar annotation key `u-ca`.
|
||||
#[doc(hidden)]
|
||||
fn check_calendar_key(key: &[Self::CodeUnit]) -> bool;
|
||||
}
|
||||
|
||||
/// A marker type that signals a parser should parse the source as UTF-16 bytes.
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
#[allow(clippy::exhaustive_structs)] // ZST Marker trait, no fields should be added
|
||||
pub struct Utf16;
|
||||
|
||||
impl private::Sealed for Utf16 {}
|
||||
|
||||
impl EncodingType for Utf16 {
|
||||
type CodeUnit = u16;
|
||||
fn slice(source: &[Self::CodeUnit], start: usize, end: usize) -> Option<&[Self::CodeUnit]> {
|
||||
source.get(start..end)
|
||||
}
|
||||
|
||||
fn get_ascii(source: &[Self::CodeUnit], index: usize) -> ParserResult<Option<u8>> {
|
||||
source.get(index).copied().map(to_ascii_byte).transpose()
|
||||
}
|
||||
|
||||
fn check_calendar_key(key: &[Self::CodeUnit]) -> bool {
|
||||
key == [0x75, 0x2d, 0x63, 0x61]
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn to_ascii_byte(b: u16) -> ParserResult<u8> {
|
||||
if !(0x01..0x7F).contains(&b) {
|
||||
return Err(ParseError::NonAsciiCodePoint);
|
||||
}
|
||||
Ok(b as u8)
|
||||
}
|
||||
|
||||
/// A marker type that signals a parser should parse the source as UTF-8 bytes.
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
#[allow(clippy::exhaustive_structs)] // ZST Marker trait, no fields should be added.
|
||||
pub struct Utf8;
|
||||
|
||||
impl private::Sealed for Utf8 {}
|
||||
|
||||
impl EncodingType for Utf8 {
|
||||
type CodeUnit = u8;
|
||||
|
||||
fn slice(source: &[Self::CodeUnit], start: usize, end: usize) -> Option<&[Self::CodeUnit]> {
|
||||
source.get(start..end)
|
||||
}
|
||||
|
||||
fn get_ascii(source: &[Self::CodeUnit], index: usize) -> ParserResult<Option<u8>> {
|
||||
Ok(source.get(index).copied())
|
||||
}
|
||||
|
||||
fn check_calendar_key(key: &[Self::CodeUnit]) -> bool {
|
||||
key == "u-ca".as_bytes()
|
||||
}
|
||||
}
|
||||
-4
@@ -76,10 +76,6 @@ pub enum ParseError {
|
||||
impl core::error::Error for ParseError {}
|
||||
|
||||
impl ParseError {
|
||||
pub(crate) fn abrupt_end(location: &'static str) -> Self {
|
||||
ParseError::AbruptEnd { location }
|
||||
}
|
||||
|
||||
/// Convert this error to a static string representation
|
||||
pub fn to_static_string(&self) -> &'static str {
|
||||
match *self {
|
||||
|
||||
+16
-20
@@ -2,6 +2,19 @@
|
||||
// called LICENSE at the top level of the ICU4X source tree
|
||||
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
|
||||
|
||||
// https://github.com/unicode-org/icu4x/blob/main/documents/process/boilerplate.md#library-annotations
|
||||
#![cfg_attr(not(any(test, doc)), no_std)]
|
||||
#![cfg_attr(
|
||||
not(test),
|
||||
deny(
|
||||
clippy::indexing_slicing,
|
||||
clippy::unwrap_used,
|
||||
clippy::expect_used,
|
||||
clippy::panic,
|
||||
)
|
||||
)]
|
||||
// #![warn(missing_docs)]
|
||||
|
||||
//! Parsers for extended date time string and Duration parsing.
|
||||
//!
|
||||
//! The [Internet Extended Date/Time Fmt (IXDTF)][rfc9557] is laid out by RFC 9557. RFC 9557
|
||||
@@ -373,32 +386,15 @@
|
||||
//! [rfc3339]: https://datatracker.ietf.org/doc/html/rfc3339
|
||||
//! [temporal-grammar]: https://tc39.es/proposal-temporal/#sec-temporal-iso8601grammar
|
||||
|
||||
#![no_std]
|
||||
#![cfg_attr(
|
||||
not(test),
|
||||
deny(
|
||||
clippy::indexing_slicing,
|
||||
clippy::unwrap_used,
|
||||
clippy::expect_used,
|
||||
clippy::panic,
|
||||
clippy::exhaustive_structs,
|
||||
clippy::exhaustive_enums,
|
||||
clippy::trivially_copy_pass_by_ref,
|
||||
missing_debug_implementations,
|
||||
)
|
||||
)]
|
||||
mod error;
|
||||
|
||||
pub(crate) mod core;
|
||||
mod error;
|
||||
|
||||
pub mod encoding;
|
||||
pub mod parsers;
|
||||
pub mod records;
|
||||
|
||||
pub use error::ParseError;
|
||||
|
||||
/// This module contains the supported encoding for `ixdtf` parsing.
|
||||
pub mod encoding {
|
||||
pub use crate::core::{Utf16, Utf8};
|
||||
}
|
||||
|
||||
/// The `ixdtf` crate's Result type.
|
||||
pub type ParserResult<T> = Result<T, ParseError>;
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
use crate::{
|
||||
assert_syntax,
|
||||
core::EncodingType,
|
||||
encoding::EncodingType,
|
||||
parsers::{
|
||||
grammar::{
|
||||
is_a_key_char, is_a_key_leading_char, is_annotation_close,
|
||||
|
||||
+10
-10
@@ -6,7 +6,7 @@
|
||||
|
||||
use crate::{
|
||||
assert_syntax,
|
||||
core::EncodingType,
|
||||
encoding::EncodingType,
|
||||
parsers::{
|
||||
annotations,
|
||||
grammar::{is_annotation_open, is_date_time_separator, is_hyphen, is_utc_designator},
|
||||
@@ -106,7 +106,7 @@ fn parse_date<T: EncodingType>(cursor: &mut Cursor<T>) -> ParserResult<DateRecor
|
||||
let year = parse_date_year(cursor)?;
|
||||
let hyphenated = cursor
|
||||
.check(is_hyphen)?
|
||||
.ok_or(ParseError::abrupt_end("Date"))?;
|
||||
.ok_or(ParseError::AbruptEnd { location: "Date" })?;
|
||||
|
||||
cursor.advance_if(hyphenated);
|
||||
|
||||
@@ -125,7 +125,7 @@ fn parse_date<T: EncodingType>(cursor: &mut Cursor<T>) -> ParserResult<DateRecor
|
||||
|
||||
// ==== `YearMonth` parsing functions ====
|
||||
|
||||
/// Parse an annotated YearMonth
|
||||
/// Parse an annotated `YearMonth`
|
||||
pub(crate) fn parse_annotated_year_month<'a, T: EncodingType>(
|
||||
cursor: &mut Cursor<'a, T>,
|
||||
handler: impl FnMut(Annotation<'a, T>) -> Option<Annotation<'a, T>>,
|
||||
@@ -170,7 +170,7 @@ pub(crate) fn parse_year_month<T: EncodingType>(
|
||||
|
||||
// ==== `MonthDay` parsing functions ====
|
||||
|
||||
/// Parses an AnnotatedMonthDay.
|
||||
/// Parses an `AnnotatedMonthDay`.
|
||||
pub(crate) fn parse_annotated_month_day<'a, T: EncodingType>(
|
||||
cursor: &mut Cursor<'a, T>,
|
||||
handler: impl FnMut(Annotation<'a, T>) -> Option<Annotation<'a, T>>,
|
||||
@@ -202,14 +202,14 @@ pub(crate) fn parse_annotated_month_day<'a, T: EncodingType>(
|
||||
|
||||
/// Parses a `DateSpecMonthDay`
|
||||
pub(crate) fn parse_month_day<T: EncodingType>(cursor: &mut Cursor<T>) -> ParserResult<DateRecord> {
|
||||
let hyphenated = cursor
|
||||
.check(is_hyphen)?
|
||||
.ok_or(ParseError::abrupt_end("MonthDay"))?;
|
||||
let hyphenated = cursor.check(is_hyphen)?.ok_or(ParseError::AbruptEnd {
|
||||
location: "MonthDay",
|
||||
})?;
|
||||
cursor.advance_if(hyphenated);
|
||||
let balanced_hyphens = hyphenated
|
||||
&& cursor
|
||||
.check(is_hyphen)?
|
||||
.ok_or(ParseError::abrupt_end("MonthDay"))?;
|
||||
&& cursor.check(is_hyphen)?.ok_or(ParseError::AbruptEnd {
|
||||
location: "MonthDay",
|
||||
})?;
|
||||
cursor.advance_if(balanced_hyphens);
|
||||
|
||||
if hyphenated && !balanced_hyphens {
|
||||
|
||||
+29
-17
@@ -6,7 +6,7 @@
|
||||
|
||||
use crate::{
|
||||
assert_syntax,
|
||||
core::EncodingType,
|
||||
encoding::EncodingType,
|
||||
parsers::{
|
||||
grammar::{
|
||||
is_ascii_sign, is_day_designator, is_duration_designator, is_hour_designator,
|
||||
@@ -23,24 +23,26 @@ use crate::{
|
||||
pub(crate) fn parse_duration<T: EncodingType>(
|
||||
cursor: &mut Cursor<T>,
|
||||
) -> ParserResult<DurationParseRecord> {
|
||||
let sign = if cursor
|
||||
.check(is_ascii_sign)?
|
||||
.ok_or_else(|| ParseError::abrupt_end("DurationStart"))?
|
||||
{
|
||||
let sign = if cursor.check(is_ascii_sign)?.ok_or(ParseError::AbruptEnd {
|
||||
location: "DurationStart",
|
||||
})? {
|
||||
cursor.next_or(ParseError::ImplAssert)? == b'+'
|
||||
} else {
|
||||
true
|
||||
};
|
||||
|
||||
assert_syntax!(
|
||||
is_duration_designator(cursor.next_or(ParseError::abrupt_end("DurationDesignator"))?),
|
||||
is_duration_designator(cursor.next_or(ParseError::AbruptEnd {
|
||||
location: "DurationDesignator"
|
||||
})?),
|
||||
DurationDisgnator,
|
||||
);
|
||||
|
||||
let date = if cursor
|
||||
.check(is_time_designator)?
|
||||
.ok_or(ParseError::abrupt_end("Duration"))?
|
||||
{
|
||||
.ok_or(ParseError::AbruptEnd {
|
||||
location: "Duration",
|
||||
})? {
|
||||
None
|
||||
} else {
|
||||
Some(parse_date_duration(cursor)?)
|
||||
@@ -75,9 +77,9 @@ pub(crate) fn parse_date_duration<T: EncodingType>(
|
||||
while cursor.check_or(false, |ch| ch.is_ascii_digit())? {
|
||||
let mut value: u64 = 0;
|
||||
while cursor.check_or(false, |ch| ch.is_ascii_digit())? {
|
||||
let digit = cursor
|
||||
.next_digit()?
|
||||
.ok_or_else(|| ParseError::abrupt_end("DateDuration"))?;
|
||||
let digit = cursor.next_digit()?.ok_or(ParseError::AbruptEnd {
|
||||
location: "DateDuration",
|
||||
})?;
|
||||
value = value
|
||||
.checked_mul(10)
|
||||
.and_then(|v| v.checked_add(u64::from(digit)))
|
||||
@@ -116,7 +118,11 @@ pub(crate) fn parse_date_duration<T: EncodingType>(
|
||||
date.days = value;
|
||||
previous_unit = DateUnit::Day;
|
||||
}
|
||||
Some(_) | None => return Err(ParseError::abrupt_end("DateDurationDesignator")),
|
||||
Some(_) | None => {
|
||||
return Err(ParseError::AbruptEnd {
|
||||
location: "DateDurationDesignator",
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,9 +155,9 @@ pub(crate) fn parse_time_duration<T: EncodingType>(
|
||||
while cursor.check_or(false, |c| c.is_ascii_digit())? {
|
||||
let mut value: u64 = 0;
|
||||
while cursor.check_or(false, |c| c.is_ascii_digit())? {
|
||||
let digit = cursor
|
||||
.next_digit()?
|
||||
.ok_or_else(|| ParseError::abrupt_end("TimeDurationDigit"))?;
|
||||
let digit = cursor.next_digit()?.ok_or(ParseError::AbruptEnd {
|
||||
location: "TimeDurationDigit",
|
||||
})?;
|
||||
value = value
|
||||
.checked_mul(10)
|
||||
.and_then(|v| v.checked_add(u64::from(digit)))
|
||||
@@ -191,7 +197,11 @@ pub(crate) fn parse_time_duration<T: EncodingType>(
|
||||
}
|
||||
previous_unit = TimeUnit::Second;
|
||||
}
|
||||
Some(_) | None => return Err(ParseError::abrupt_end("TimeDurationDesignator")),
|
||||
Some(_) | None => {
|
||||
return Err(ParseError::AbruptEnd {
|
||||
location: "TimeDurationDesignator",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if fraction.is_some() {
|
||||
@@ -221,6 +231,8 @@ pub(crate) fn parse_time_duration<T: EncodingType>(
|
||||
seconds: time.2,
|
||||
fraction: time.3,
|
||||
})),
|
||||
TimeUnit::None => Err(ParseError::abrupt_end("TimeDurationDesignator")),
|
||||
TimeUnit::None => Err(ParseError::AbruptEnd {
|
||||
location: "TimeDurationDesignator",
|
||||
}),
|
||||
}
|
||||
}
|
||||
+7
-5
@@ -4,8 +4,9 @@
|
||||
|
||||
//! The parser module contains the implementation details for `IxdtfParser` and `IsoDurationParser`
|
||||
|
||||
use crate::core::{EncodingType, Utf16, Utf8};
|
||||
use crate::{core::Cursor, ParserResult};
|
||||
use crate::core::Cursor;
|
||||
use crate::encoding::{EncodingType, Utf16, Utf8};
|
||||
use crate::ParserResult;
|
||||
|
||||
#[cfg(feature = "duration")]
|
||||
use crate::records::DurationParseRecord;
|
||||
@@ -116,7 +117,8 @@ impl<'a, T: EncodingType> IxdtfParser<'a, T> {
|
||||
/// Parses the source as an [extended Date/Time string][rfc9557].
|
||||
///
|
||||
/// This is the baseline parse method for `ixdtf`. For this method, the
|
||||
/// TimeRecord, UTCOffsetRecord, and all annotations are optional.
|
||||
/// [`TimeRecord`](crate::records::TimeRecord), [`UtcOffsetRecord`],
|
||||
/// and all annotations are optional.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
@@ -159,7 +161,7 @@ impl<'a, T: EncodingType> IxdtfParser<'a, T> {
|
||||
self.parse_year_month_with_annotation_handler(Some)
|
||||
}
|
||||
|
||||
/// Parses the source as an extended YearMonth string with an Annotation handler.
|
||||
/// Parses the source as an extended `YearMonth` string with an Annotation handler.
|
||||
///
|
||||
/// For more, see [Implementing Annotation Handlers](crate#implementing-annotation-handlers)
|
||||
pub fn parse_year_month_with_annotation_handler(
|
||||
@@ -192,7 +194,7 @@ impl<'a, T: EncodingType> IxdtfParser<'a, T> {
|
||||
self.parse_month_day_with_annotation_handler(Some)
|
||||
}
|
||||
|
||||
/// Parses the source as an extended MonthDay string with an Annotation handler.
|
||||
/// Parses the source as an extended `MonthDay` string with an Annotation handler.
|
||||
///
|
||||
/// For more, see [Implementing Annotation Handlers](crate#implementing-annotation-handlers)
|
||||
pub fn parse_month_day_with_annotation_handler(
|
||||
|
||||
+2
-2
@@ -9,7 +9,7 @@ use alloc::string::String;
|
||||
use alloc::vec::Vec;
|
||||
|
||||
use crate::{
|
||||
core::Utf16,
|
||||
encoding::Utf16,
|
||||
parsers::IxdtfParser,
|
||||
records::{
|
||||
Annotation, DateRecord, Fraction, IxdtfParseRecord, TimeRecord, TimeZoneAnnotation,
|
||||
@@ -1103,7 +1103,7 @@ fn test_zulu_offset() {
|
||||
second: 0,
|
||||
fraction: None,
|
||||
}),
|
||||
offset: Some(crate::records::UtcOffsetRecordOrZ::Z),
|
||||
offset: Some(UtcOffsetRecordOrZ::Z),
|
||||
tz: Some(TimeZoneAnnotation {
|
||||
critical: false,
|
||||
tz: TimeZoneRecord::Name("America/Chicago".as_bytes())
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ use core::num::NonZeroU8;
|
||||
|
||||
use crate::{
|
||||
assert_syntax,
|
||||
core::EncodingType,
|
||||
encoding::EncodingType,
|
||||
parsers::{
|
||||
datetime::{parse_month_day, parse_year_month},
|
||||
grammar::{
|
||||
|
||||
+20
-11
@@ -15,7 +15,7 @@ use super::{
|
||||
};
|
||||
use crate::{
|
||||
assert_syntax,
|
||||
core::EncodingType,
|
||||
encoding::EncodingType,
|
||||
records::{
|
||||
FullPrecisionOffset, MinutePrecisionOffset, Sign, TimeZoneAnnotation, TimeZoneRecord,
|
||||
UtcOffsetRecord, UtcOffsetRecordOrZ,
|
||||
@@ -39,19 +39,22 @@ pub(crate) fn parse_ambiguous_tz_annotation<'a, T: EncodingType>(
|
||||
) -> ParserResult<Option<TimeZoneAnnotation<'a, T>>> {
|
||||
// Peek position + 1 to check for critical flag.
|
||||
let mut current_peek = 1;
|
||||
let critical = cursor
|
||||
.peek_n(current_peek)?
|
||||
.map(is_critical_flag)
|
||||
.ok_or(ParseError::abrupt_end("AmbiguousAnnotation"))?;
|
||||
let critical =
|
||||
cursor
|
||||
.peek_n(current_peek)?
|
||||
.map(is_critical_flag)
|
||||
.ok_or(ParseError::AbruptEnd {
|
||||
location: "AmbiguousAnnotation",
|
||||
})?;
|
||||
|
||||
// Advance cursor if critical flag present.
|
||||
if critical {
|
||||
current_peek += 1;
|
||||
}
|
||||
|
||||
let leading_char = cursor
|
||||
.peek_n(current_peek)?
|
||||
.ok_or(ParseError::abrupt_end("AmbiguousAnnotation"))?;
|
||||
let leading_char = cursor.peek_n(current_peek)?.ok_or(ParseError::AbruptEnd {
|
||||
location: "AmbiguousAnnotation",
|
||||
})?;
|
||||
|
||||
// Ambigious start values when lowercase alpha that is shared between `TzLeadingChar` and `KeyLeadingChar`.
|
||||
if is_a_key_leading_char(leading_char) {
|
||||
@@ -69,7 +72,9 @@ pub(crate) fn parse_ambiguous_tz_annotation<'a, T: EncodingType>(
|
||||
|
||||
peek_pos += 1;
|
||||
}
|
||||
Err(ParseError::abrupt_end("AmbiguousAnnotation"))
|
||||
Err(ParseError::AbruptEnd {
|
||||
location: "AmbiguousAnnotation",
|
||||
})
|
||||
} else {
|
||||
// Unambiguously not a non-tz annotation, try parsing a tz annotation
|
||||
let tz = parse_tz_annotation(cursor)?;
|
||||
@@ -106,7 +111,9 @@ pub(crate) fn parse_time_zone<'a, T: EncodingType>(
|
||||
) -> ParserResult<TimeZoneRecord<'a, T>> {
|
||||
let is_iana = cursor
|
||||
.check(is_tz_leading_char)?
|
||||
.ok_or(ParseError::abrupt_end("TimeZoneAnnotation"))?;
|
||||
.ok_or(ParseError::AbruptEnd {
|
||||
location: "TimeZoneAnnotation",
|
||||
})?;
|
||||
let is_offset = cursor.check_or(false, is_ascii_sign)?;
|
||||
|
||||
if is_iana {
|
||||
@@ -203,7 +210,9 @@ pub(crate) fn parse_utc_offset_minute_precision<T: EncodingType>(
|
||||
cursor: &mut Cursor<T>,
|
||||
) -> ParserResult<(MinutePrecisionOffset, bool)> {
|
||||
// https://www.rfc-editor.org/rfc/rfc3339#section-5.6
|
||||
let sign = cursor.next_or(ParseError::abrupt_end("time-numoffset"))?;
|
||||
let sign = cursor.next_or(ParseError::AbruptEnd {
|
||||
location: "time-numoffset",
|
||||
})?;
|
||||
if !is_ascii_sign(sign) {
|
||||
return Err(ParseError::OffsetNeedsSign);
|
||||
}
|
||||
|
||||
+6
-6
@@ -6,7 +6,7 @@
|
||||
|
||||
use core::num::NonZeroU8;
|
||||
|
||||
use crate::core::EncodingType;
|
||||
use crate::encoding::EncodingType;
|
||||
|
||||
/// An `IxdtfParseRecord` is an intermediary record returned by `IxdtfParser`.
|
||||
#[non_exhaustive]
|
||||
@@ -16,9 +16,9 @@ pub struct IxdtfParseRecord<'a, T: EncodingType> {
|
||||
pub date: Option<DateRecord>,
|
||||
/// Parsed `TimeRecord`
|
||||
pub time: Option<TimeRecord>,
|
||||
/// Parsed UtcOffset
|
||||
/// Parsed `UtcOffset`
|
||||
pub offset: Option<UtcOffsetRecordOrZ>,
|
||||
/// Parsed `TimeZone` annotation with critical flag and data (UTCOffset | IANA name)
|
||||
/// Parsed `TimeZone` annotation with critical flag and data (`UTCOffset` | IANA name)
|
||||
pub tz: Option<TimeZoneAnnotation<'a, T>>,
|
||||
/// The parsed calendar value.
|
||||
pub calendar: Option<&'a [T::CodeUnit]>,
|
||||
@@ -76,9 +76,9 @@ pub struct TimeZoneAnnotation<'a, T: EncodingType> {
|
||||
#[non_exhaustive]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum TimeZoneRecord<'a, T: EncodingType> {
|
||||
/// TimeZoneIANAName
|
||||
/// `TimeZoneIANAName`
|
||||
Name(&'a [T::CodeUnit]),
|
||||
/// TimeZoneOffset
|
||||
/// `TimeZoneOffset`
|
||||
Offset(MinutePrecisionOffset),
|
||||
}
|
||||
|
||||
@@ -356,6 +356,6 @@ impl Fraction {
|
||||
/// ```
|
||||
pub fn to_truncated_nanoseconds(&self) -> u32 {
|
||||
self.to_nanoseconds()
|
||||
.unwrap_or((self.value / 10u64.pow(u32::from(self.digits.get() - 9))) as u32)
|
||||
.unwrap_or_else(|| (self.value / 10u64.pow(u32::from(self.digits.get() - 9))) as u32)
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"git": {
|
||||
"sha1": "29dfe2790b6cfdab94ca6a6b69f58ce54802dbf7"
|
||||
"sha1": "c9fac4e625ccb2c6a7aa35079fff9709db4385ac"
|
||||
},
|
||||
"path_in_vcs": "utils/litemap"
|
||||
}
|
||||
+91
-111
@@ -8,16 +8,16 @@ version = "0.7.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9"
|
||||
dependencies = [
|
||||
"getrandom 0.2.16",
|
||||
"getrandom 0.2.17",
|
||||
"once_cell",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
version = "1.1.3"
|
||||
version = "1.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
|
||||
checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
@@ -30,9 +30,9 @@ checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299"
|
||||
|
||||
[[package]]
|
||||
name = "anstyle"
|
||||
version = "1.0.13"
|
||||
version = "1.0.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78"
|
||||
checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000"
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
@@ -63,9 +63,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "bumpalo"
|
||||
version = "3.19.0"
|
||||
version = "3.20.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43"
|
||||
checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb"
|
||||
|
||||
[[package]]
|
||||
name = "bytecheck"
|
||||
@@ -91,9 +91,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "bytes"
|
||||
version = "1.10.1"
|
||||
version = "1.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a"
|
||||
checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33"
|
||||
|
||||
[[package]]
|
||||
name = "cast"
|
||||
@@ -237,9 +237,9 @@ checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5"
|
||||
|
||||
[[package]]
|
||||
name = "databake"
|
||||
version = "0.2.0"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ff6ee9e2d2afb173bcdeee45934c89ec341ab26f91c9933774fc15c2b58f83ef"
|
||||
checksum = "74d4b1db5ca40636726f1f73daff0d626accbd49bcd8136fcade87d7cf1e6bbb"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -271,9 +271,9 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c"
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.2.16"
|
||||
version = "0.2.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592"
|
||||
checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
@@ -339,15 +339,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "1.0.15"
|
||||
version = "1.0.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
|
||||
checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
|
||||
|
||||
[[package]]
|
||||
name = "js-sys"
|
||||
version = "0.3.81"
|
||||
version = "0.3.91"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec48937a97411dcb524a265206ccd4c90bb711fca92b2792c407f268825b9305"
|
||||
checksum = "b49715b7073f385ba4bc528e5747d02e66cb39c6146efb66b781f131f0fb399c"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
"wasm-bindgen",
|
||||
@@ -355,13 +355,13 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.177"
|
||||
version = "0.2.183"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2874a2af47a2325c2001a6e6fad9b16a53b802102b528163885171cf92b15976"
|
||||
checksum = "b5b646652bf6661599e1da8901b3b9522896f01e736bad5f723fe7a3a27f899d"
|
||||
|
||||
[[package]]
|
||||
name = "litemap"
|
||||
version = "0.8.1"
|
||||
version = "0.8.2"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"criterion",
|
||||
@@ -374,17 +374,11 @@ dependencies = [
|
||||
"yoke",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.28"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432"
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.7.6"
|
||||
version = "2.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273"
|
||||
checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79"
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
@@ -397,9 +391,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.21.3"
|
||||
version = "1.21.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
|
||||
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
|
||||
|
||||
[[package]]
|
||||
name = "oorandom"
|
||||
@@ -458,9 +452,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.103"
|
||||
version = "1.0.106"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5ee95bc4ef87b8d5ba32e8b7714ccc834865276eab0aed5c9958d00ec45f49e8"
|
||||
checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
@@ -487,9 +481,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.41"
|
||||
version = "1.0.45"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ce25767e7b499d1b604768e7cde645d14cc8584231ea6b295e9c9eb22c02e1d1"
|
||||
checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
@@ -528,9 +522,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.9.3"
|
||||
version = "0.9.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38"
|
||||
checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c"
|
||||
dependencies = [
|
||||
"getrandom 0.3.4",
|
||||
]
|
||||
@@ -557,9 +551,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.12.2"
|
||||
version = "1.12.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "843bc0191f75f3e22651ae5f1e72939ab2f72a4bc30fa80a066bd66edefc24d4"
|
||||
checksum = "e10754a14b9137dd7b1e3e5b0493cc9171fdd105e0ab477f51b72e7f3ac0e276"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
@@ -569,9 +563,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "regex-automata"
|
||||
version = "0.4.13"
|
||||
version = "0.4.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5276caf25ac86c8d810222b3dbb938e512c55c6831a10f3e6ed1c93b84041f1c"
|
||||
checksum = "6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8f"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
@@ -580,9 +574,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.8.8"
|
||||
version = "0.8.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58"
|
||||
checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a"
|
||||
|
||||
[[package]]
|
||||
name = "rend"
|
||||
@@ -595,9 +589,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rkyv"
|
||||
version = "0.7.45"
|
||||
version = "0.7.46"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9008cd6385b9e161d8229e1f6549dd23c3d022f132a2ea37ac3a10ac4935779b"
|
||||
checksum = "2297bf9c81a3f0dc96bc9521370b88f054168c29826a75e89c55ff196e7ed6a1"
|
||||
dependencies = [
|
||||
"bitvec",
|
||||
"bytecheck",
|
||||
@@ -613,9 +607,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rkyv_derive"
|
||||
version = "0.7.45"
|
||||
version = "0.7.46"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "503d1d27590a2b0a3a4ca4c94755aa2875657196ecbf401a42eff41d7de532c0"
|
||||
checksum = "84d7b42d4b8d06048d3ac8db0eb31bcb942cbeb709f0b5f2b2ebde398d3038f5"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -628,12 +622,6 @@ version = "1.0.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
|
||||
|
||||
[[package]]
|
||||
name = "ryu"
|
||||
version = "1.0.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f"
|
||||
|
||||
[[package]]
|
||||
name = "same-file"
|
||||
version = "1.0.6"
|
||||
@@ -676,20 +664,20 @@ checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.108",
|
||||
"syn 2.0.117",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.145"
|
||||
version = "1.0.149"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "402a6f66d8c709116cf22f558eab210f5a50187f702eb4d7e5ef38d9a7f1c79c"
|
||||
checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"memchr",
|
||||
"ryu",
|
||||
"serde",
|
||||
"serde_core",
|
||||
"zmij",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -717,9 +705,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.108"
|
||||
version = "2.0.117"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "da58917d35242480a05c2897064da0a80589a2a0476c9a3f2fdc83b53502e917"
|
||||
checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -734,7 +722,7 @@ checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.108",
|
||||
"syn 2.0.117",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -745,22 +733,22 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369"
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "2.0.17"
|
||||
version = "2.0.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f63587ca0f12b72a0600bcba1d40081f830876000bb46dd2337a3051618f4fc8"
|
||||
checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4"
|
||||
dependencies = [
|
||||
"thiserror-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror-impl"
|
||||
version = "2.0.17"
|
||||
version = "2.0.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913"
|
||||
checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.108",
|
||||
"syn 2.0.117",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -775,9 +763,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "tinyvec"
|
||||
version = "1.10.0"
|
||||
version = "1.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bfa5fdc3bce6191a1dbc8c02d5c8bffcf557bafa17c124c5264a458f1b0613fa"
|
||||
checksum = "3e61e67053d25a4e82c844e8424039d9745781b3fc4f32b8d55ed50f5f667ef3"
|
||||
dependencies = [
|
||||
"tinyvec_macros",
|
||||
]
|
||||
@@ -790,15 +778,15 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.20"
|
||||
version = "1.0.24"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "462eeb75aeb73aea900253ce739c8e18a67423fadf006037cd3ff27e82748a06"
|
||||
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
|
||||
|
||||
[[package]]
|
||||
name = "uuid"
|
||||
version = "1.18.1"
|
||||
version = "1.20.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2f87b8aa10b915a06587d0dec516c282ff295b475d94abf425d62b57710070a2"
|
||||
checksum = "ee48d38b119b0cd71fe4141b30f5ba9c7c5d9f4e7a3a8b4a674e4b6ef789976f"
|
||||
dependencies = [
|
||||
"js-sys",
|
||||
"wasm-bindgen",
|
||||
@@ -837,9 +825,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen"
|
||||
version = "0.2.104"
|
||||
version = "0.2.114"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c1da10c01ae9f1ae40cbfac0bac3b1e724b320abfcf52229f80b547c0d250e2d"
|
||||
checksum = "6532f9a5c1ece3798cb1c2cfdba640b9b3ba884f5db45973a6f442510a87d38e"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"once_cell",
|
||||
@@ -848,25 +836,11 @@ dependencies = [
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-backend"
|
||||
version = "0.2.104"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "671c9a5a66f49d8a47345ab942e2cb93c7d1d0339065d4f8139c486121b43b19"
|
||||
dependencies = [
|
||||
"bumpalo",
|
||||
"log",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.108",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro"
|
||||
version = "0.2.104"
|
||||
version = "0.2.114"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7ca60477e4c59f5f2986c50191cd972e3a50d8a95603bc9434501cf156a9a119"
|
||||
checksum = "18a2d50fcf105fb33bb15f00e7a77b772945a2ee45dcf454961fd843e74c18e6"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"wasm-bindgen-macro-support",
|
||||
@@ -874,31 +848,31 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro-support"
|
||||
version = "0.2.104"
|
||||
version = "0.2.114"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9f07d2f20d4da7b26400c9f4a0511e6e0345b040694e8a75bd41d578fa4421d7"
|
||||
checksum = "03ce4caeaac547cdf713d280eda22a730824dd11e6b8c3ca9e42247b25c631e3"
|
||||
dependencies = [
|
||||
"bumpalo",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.108",
|
||||
"wasm-bindgen-backend",
|
||||
"syn 2.0.117",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-shared"
|
||||
version = "0.2.104"
|
||||
version = "0.2.114"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bad67dc8b2a1a6e5448428adec4c3e84c43e561d8c9ee8a9e5aabeb193ec41d1"
|
||||
checksum = "75a326b8c223ee17883a4251907455a2431acc2791c98c26279376490c378c16"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "web-sys"
|
||||
version = "0.3.81"
|
||||
version = "0.3.91"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9367c417a924a74cae129e6a2ae3b47fabb1f8995595ab474029da749a8be120"
|
||||
checksum = "854ba17bb104abfb26ba36da9729addc7ce7f06f5c0f90f3c391f8461cca21f9"
|
||||
dependencies = [
|
||||
"js-sys",
|
||||
"wasm-bindgen",
|
||||
@@ -945,9 +919,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "yoke"
|
||||
version = "0.8.1"
|
||||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "72d6e5c6afb84d73944e5cedb052c4680d5657337201555f9f2a16b7406d4954"
|
||||
checksum = "abe8c5fda708d9ca3df187cae8bfb9ceda00dd96231bed36e445a1a48e66f9ca"
|
||||
dependencies = [
|
||||
"stable_deref_trait",
|
||||
"yoke-derive",
|
||||
@@ -956,53 +930,59 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "yoke-derive"
|
||||
version = "0.8.1"
|
||||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b659052874eb698efe5b9e8cf382204678a0086ebf46982b79d6ca3182927e5d"
|
||||
checksum = "de844c262c8848816172cef550288e7dc6c7b7814b4ee56b3e1553f275f1858e"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.108",
|
||||
"syn 2.0.117",
|
||||
"synstructure",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zerocopy"
|
||||
version = "0.8.27"
|
||||
version = "0.8.47"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0894878a5fa3edfd6da3f88c4805f4c8558e2b996227a3d864f47fe11e38282c"
|
||||
checksum = "efbb2a062be311f2ba113ce66f697a4dc589f85e78a4aea276200804cea0ed87"
|
||||
dependencies = [
|
||||
"zerocopy-derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zerocopy-derive"
|
||||
version = "0.8.27"
|
||||
version = "0.8.47"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "88d2b8d9c68ad2b9e4340d7832716a4d21a22a1154777ad56ea55c51a9cf3831"
|
||||
checksum = "0e8bc7269b54418e7aeeef514aa68f8690b8c0489a06b0136e5f57c4c5ccab89"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.108",
|
||||
"syn 2.0.117",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zerofrom"
|
||||
version = "0.1.6"
|
||||
version = "0.1.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5"
|
||||
checksum = "69faa1f2a1ea75661980b013019ed6687ed0e83d069bc1114e2cc74c6c04c4df"
|
||||
dependencies = [
|
||||
"zerofrom-derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zerofrom-derive"
|
||||
version = "0.1.6"
|
||||
version = "0.1.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502"
|
||||
checksum = "11532158c46691caf0f2593ea8358fed6bbf68a0315e80aae9bd41fbade684a1"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.108",
|
||||
"syn 2.0.117",
|
||||
"synstructure",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zmij"
|
||||
version = "1.0.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa"
|
||||
+56
-4
@@ -13,7 +13,7 @@
|
||||
edition = "2021"
|
||||
rust-version = "1.82"
|
||||
name = "litemap"
|
||||
version = "0.8.1"
|
||||
version = "0.8.2"
|
||||
authors = ["The ICU4X Project Developers"]
|
||||
build = false
|
||||
include = [
|
||||
@@ -36,11 +36,11 @@ description = "A key-value Map implementation based on a flat, sorted Vec."
|
||||
documentation = "https://docs.rs/litemap"
|
||||
readme = "README.md"
|
||||
keywords = [
|
||||
"data-structures",
|
||||
"memory-efficiency",
|
||||
"sorted",
|
||||
"vec",
|
||||
"map",
|
||||
"hashmap",
|
||||
"btreemap",
|
||||
]
|
||||
license = "Unicode-3.0"
|
||||
repository = "https://github.com/unicode-org/icu4x"
|
||||
@@ -51,6 +51,9 @@ independent = true
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
|
||||
[package.metadata.cargo-all-features]
|
||||
max_combination_size = 3
|
||||
|
||||
[features]
|
||||
alloc = []
|
||||
databake = ["dep:databake"]
|
||||
@@ -117,7 +120,7 @@ optional = true
|
||||
default-features = false
|
||||
|
||||
[dependencies.yoke]
|
||||
version = "0.8.0"
|
||||
version = "0.8.2"
|
||||
features = ["derive"]
|
||||
optional = true
|
||||
default-features = false
|
||||
@@ -146,3 +149,52 @@ version = "1.0.45"
|
||||
|
||||
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies.criterion]
|
||||
version = "0.5.0"
|
||||
|
||||
[lints.clippy]
|
||||
alloc-instead-of-core = "warn"
|
||||
branches-sharing-code = "warn"
|
||||
collection_is_never_read = "warn"
|
||||
crosspointer_transmute = "warn"
|
||||
dbg_macro = "warn"
|
||||
debug_assert_with_mut_call = "warn"
|
||||
doc_markdown = "warn"
|
||||
exhaustive_enums = "deny"
|
||||
exhaustive_structs = "deny"
|
||||
fn_to_numeric_cast_any = "warn"
|
||||
infinite_loop = "warn"
|
||||
large_stack_arrays = "warn"
|
||||
mismatching_type_param_order = "warn"
|
||||
missing_fields_in_debug = "warn"
|
||||
missing_transmute_annotations = "warn"
|
||||
negative_feature_names = "warn"
|
||||
or-fun-call = "warn"
|
||||
same_functions_in_if_condition = "warn"
|
||||
todo = "warn"
|
||||
transmute_bytes_to_str = "warn"
|
||||
transmute_int_to_bool = "warn"
|
||||
transmute_int_to_non_zero = "warn"
|
||||
transmute_ptr_to_ptr = "warn"
|
||||
transmute_ptr_to_ref = "warn"
|
||||
transmute_undefined_repr = "warn"
|
||||
transmutes_expressible_as_ptr_casts = "warn"
|
||||
trivially_copy_pass_by_ref = "deny"
|
||||
unnecessary-wraps = "warn"
|
||||
useless_transmute = "warn"
|
||||
wildcard_dependencies = "warn"
|
||||
|
||||
[lints.rust]
|
||||
missing_debug_implementations = "deny"
|
||||
trivial_numeric_casts = "deny"
|
||||
unused_lifetimes = "warn"
|
||||
unused_macro_rules = "warn"
|
||||
unused_qualifications = "warn"
|
||||
|
||||
[lints.rust.unexpected_cfgs]
|
||||
level = "warn"
|
||||
priority = 0
|
||||
check-cfg = [
|
||||
"cfg(icu4c_enable_renaming)",
|
||||
"cfg(needs_alloc_error_handler)",
|
||||
"cfg(icu4x_run_size_tests)",
|
||||
"cfg(icu4x_unstable_fast_trie_only)",
|
||||
]
|
||||
+8
-2
@@ -4,8 +4,8 @@
|
||||
|
||||
[package]
|
||||
name = "litemap"
|
||||
version = "0.8.1"
|
||||
keywords = ["sorted", "vec", "map", "hashmap", "btreemap"]
|
||||
version = "0.8.2"
|
||||
keywords = ["data-structures", "memory-efficiency", "sorted", "vec", "map"]
|
||||
description = "A key-value Map implementation based on a flat, sorted Vec."
|
||||
documentation = "https://docs.rs/litemap"
|
||||
|
||||
@@ -75,3 +75,9 @@ required-features = ["serde"]
|
||||
name = "litemap"
|
||||
harness = false
|
||||
required-features = ["serde"]
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[package.metadata.cargo-all-features]
|
||||
max_combination_size = 3
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
use crate::LiteMap;
|
||||
use databake::*;
|
||||
|
||||
/// Bakes a LiteMap into Rust code for fast runtime construction from data. Use this impl during
|
||||
/// Bakes a [`LiteMap`] into Rust code for fast runtime construction from data. Use this impl during
|
||||
/// code generation, such as in a `build.rs` script.
|
||||
///
|
||||
/// For the most efficient bake, bake the [`LiteMap`] with a slice store. Use functions such as
|
||||
|
||||
+13
-16
@@ -2,6 +2,19 @@
|
||||
// called LICENSE at the top level of the ICU4X source tree
|
||||
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
|
||||
|
||||
// https://github.com/unicode-org/icu4x/blob/main/documents/process/boilerplate.md#library-annotations
|
||||
#![cfg_attr(not(any(test, doc)), no_std)]
|
||||
#![cfg_attr(
|
||||
not(test),
|
||||
deny(
|
||||
clippy::indexing_slicing,
|
||||
clippy::unwrap_used,
|
||||
clippy::expect_used,
|
||||
clippy::panic,
|
||||
)
|
||||
)]
|
||||
// #![warn(missing_docs)]
|
||||
|
||||
//! # `litemap`
|
||||
//!
|
||||
//! `litemap` is a crate providing [`LiteMap`], a highly simplistic "flat" key-value map
|
||||
@@ -44,22 +57,6 @@
|
||||
//! [`impl Bake for LiteMap`]: ./struct.LiteMap.html#impl-Bake-for-LiteMap<K,+V,+S>
|
||||
//! [`Vec`]: alloc::vec::Vec
|
||||
|
||||
// https://github.com/unicode-org/icu4x/blob/main/documents/process/boilerplate.md#library-annotations
|
||||
#![cfg_attr(not(any(test, doc)), no_std)]
|
||||
#![cfg_attr(
|
||||
not(test),
|
||||
deny(
|
||||
clippy::indexing_slicing,
|
||||
clippy::unwrap_used,
|
||||
clippy::expect_used,
|
||||
clippy::panic,
|
||||
clippy::exhaustive_structs,
|
||||
clippy::exhaustive_enums,
|
||||
clippy::trivially_copy_pass_by_ref,
|
||||
missing_debug_implementations,
|
||||
)
|
||||
)]
|
||||
|
||||
// for intra doc links
|
||||
#[cfg(doc)]
|
||||
extern crate std;
|
||||
|
||||
+2
-2
@@ -35,7 +35,7 @@ macro_rules! litemap_impl(
|
||||
);
|
||||
// You can't `cfg()` a default generic parameter, and we don't want to write this type twice
|
||||
// and keep them in sync so we use a small macro
|
||||
litemap_impl!(feature = "alloc", S = alloc::vec::Vec<(K, V)>);
|
||||
litemap_impl!(feature = "alloc", S = Vec<(K, V)>);
|
||||
litemap_impl!(not(feature = "alloc"), S);
|
||||
|
||||
#[cfg(feature = "alloc")]
|
||||
@@ -45,7 +45,7 @@ impl<K, V> LiteMap<K, V> {
|
||||
/// ✨ *Enabled with the `alloc` Cargo feature.*
|
||||
pub const fn new_vec() -> Self {
|
||||
Self {
|
||||
values: alloc::vec::Vec::new(),
|
||||
values: Vec::new(),
|
||||
_key_type: PhantomData,
|
||||
_value_type: PhantomData,
|
||||
}
|
||||
|
||||
+2
-2
@@ -59,7 +59,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
/// Modified example from https://serde.rs/deserialize-map.html
|
||||
/// Modified example from <https://serde.rs/deserialize-map.html>
|
||||
#[expect(clippy::type_complexity)]
|
||||
struct LiteMapVisitor<K, V, R> {
|
||||
marker: PhantomData<fn() -> LiteMap<K, V, R>>,
|
||||
@@ -224,7 +224,7 @@ mod test {
|
||||
assert_eq!(map, deserialized);
|
||||
}
|
||||
|
||||
/// Test that a LiteMap<_, _, Vec> is deserialized with an exact capacity
|
||||
/// Test that a [`LiteMap<_, _, Vec>`] is deserialized with an exact capacity
|
||||
/// if the deserializer provides a size hint information, like postcard here.
|
||||
#[test]
|
||||
fn test_deserialize_capacity() {
|
||||
|
||||
+9
-7
@@ -2,21 +2,21 @@
|
||||
// called LICENSE at the top level of the ICU4X source tree
|
||||
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
|
||||
|
||||
//! Traits for pluggable LiteMap backends.
|
||||
//! Traits for pluggable [`LiteMap`] backends.
|
||||
//!
|
||||
//! By default, LiteMap is backed by a `Vec`. However, in some environments, it may be desirable
|
||||
//! to use a different data store while still using LiteMap to manage proper ordering of items.
|
||||
//! By default, [`LiteMap`] is backed by a `Vec`. However, in some environments, it may be desirable
|
||||
//! to use a different data store while still using [`LiteMap`] to manage proper ordering of items.
|
||||
//!
|
||||
//! The general guidelines for a performant data store are:
|
||||
//!
|
||||
//! 1. Must support efficient random access for binary search
|
||||
//! 2. Should support efficient append operations for deserialization
|
||||
//!
|
||||
//! To plug a custom data store into LiteMap, implement:
|
||||
//! To plug a custom data store into [`LiteMap`], implement:
|
||||
//!
|
||||
//! - [`Store`] for most of the methods
|
||||
//! - [`StoreIterable`] for methods that return iterators
|
||||
//! - [`StoreFromIterator`] to enable `FromIterator` for LiteMap
|
||||
//! - [`StoreFromIterator`] to enable `FromIterator` for [`LiteMap`]
|
||||
//!
|
||||
//! To test your implementation, enable the `"testing"` Cargo feature and use [`check_store()`].
|
||||
//!
|
||||
@@ -26,6 +26,8 @@ mod slice_impl;
|
||||
#[cfg(feature = "alloc")]
|
||||
mod vec_impl;
|
||||
|
||||
#[cfg(doc)]
|
||||
use crate::LiteMap;
|
||||
use core::cmp::Ordering;
|
||||
use core::iter::DoubleEndedIterator;
|
||||
use core::iter::FromIterator;
|
||||
@@ -38,7 +40,7 @@ pub trait StoreConstEmpty<K: ?Sized, V: ?Sized> {
|
||||
const EMPTY: Self;
|
||||
}
|
||||
|
||||
/// Trait to enable pluggable backends for LiteMap.
|
||||
/// Trait to enable pluggable backends for [`LiteMap`].
|
||||
///
|
||||
/// Some methods have default implementations provided for convenience; however, it is generally
|
||||
/// better to implement all methods that your data store supports.
|
||||
@@ -130,7 +132,7 @@ pub trait StoreBulkMut<K, V>: StoreMut<K, V> {
|
||||
I: IntoIterator<Item = (K, V)>;
|
||||
}
|
||||
|
||||
/// Iterator methods for the LiteMap store.
|
||||
/// Iterator methods for the [`LiteMap`] store.
|
||||
pub trait StoreIterable<'a, K: 'a + ?Sized, V: 'a + ?Sized>: Store<K, V> {
|
||||
type KeyValueIter: Iterator<Item = (&'a K, &'a V)> + DoubleEndedIterator + 'a;
|
||||
|
||||
|
||||
+1
-1
@@ -163,7 +163,7 @@ impl<K: Ord, V> StoreBulkMut<K, V> for Vec<(K, V)> {
|
||||
/// Returns two slices. The first contains no consecutive repeated elements.
|
||||
/// The second contains all the duplicates in no specified order.
|
||||
///
|
||||
/// This is based on std::slice::partition_dedup_by (currently unstable) but retains the
|
||||
/// This is based on `std::slice::partition_dedup_by` (currently unstable) but retains the
|
||||
/// _last_ element of the duplicate run in the first slice (instead of first).
|
||||
#[inline]
|
||||
#[expect(clippy::type_complexity)]
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@
|
||||
// called LICENSE at the top level of the ICU4X source tree
|
||||
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
|
||||
|
||||
//! Test utilities, primarily targeted to custom LiteMap stores.
|
||||
//! Test utilities, primarily targeted to custom [`LiteMap`] stores.
|
||||
|
||||
use crate::store::*;
|
||||
use crate::LiteMap;
|
||||
@@ -115,7 +115,7 @@ where
|
||||
/// Tests that a litemap that uses the given store as backend has behavior consistent with the
|
||||
/// reference impl.
|
||||
///
|
||||
/// Call this function in a test with the store impl to test as a valid backend for LiteMap.
|
||||
/// Call this function in a test with the store impl to test as a valid backend for [`LiteMap`].
|
||||
// Test code
|
||||
#[expect(clippy::expect_used)]
|
||||
pub fn check_store<'a, S>()
|
||||
|
||||
+1
-1
@@ -128,7 +128,7 @@ impl<K, V> StoreIntoIterator<K, V> for VecWithDefaults<(K, V)> {
|
||||
// leave lm_extend_start as default
|
||||
}
|
||||
|
||||
impl<A> std::iter::FromIterator<A> for VecWithDefaults<A> {
|
||||
impl<A> FromIterator<A> for VecWithDefaults<A> {
|
||||
fn from_iter<I: IntoIterator<Item = A>>(iter: I) -> Self {
|
||||
Self(Vec::from_iter(iter))
|
||||
}
|
||||
|
||||
Loaded 100 of 183 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user