test(lib): fix lib example

This commit is contained in:
Kristofers Solo 2025-07-14 21:44:28 +03:00
parent 748db052ff
commit 45efc67894
Signed by: kristoferssolo
GPG Key ID: 8687F2D3EEE6F0ED
3 changed files with 17 additions and 59 deletions

50
Cargo.lock generated
View File

@ -48,12 +48,12 @@ version = "0.1.0"
dependencies = [
"claims",
"merge",
"proc-macro-error",
"proc-macro-error2",
"proc-macro2",
"quote",
"serde",
"serde_json",
"syn 2.0.104",
"syn",
"tempfile",
]
@ -112,7 +112,7 @@ dependencies = [
"proc-macro-error2",
"proc-macro2",
"quote",
"syn 2.0.104",
"syn",
]
[[package]]
@ -130,30 +130,6 @@ version = "1.21.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
[[package]]
name = "proc-macro-error"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"
dependencies = [
"proc-macro-error-attr",
"proc-macro2",
"quote",
"syn 1.0.109",
"version_check",
]
[[package]]
name = "proc-macro-error-attr"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"
dependencies = [
"proc-macro2",
"quote",
"version_check",
]
[[package]]
name = "proc-macro-error-attr2"
version = "2.0.0"
@ -173,7 +149,7 @@ dependencies = [
"proc-macro-error-attr2",
"proc-macro2",
"quote",
"syn 2.0.104",
"syn",
]
[[package]]
@ -236,7 +212,7 @@ checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.104",
"syn",
]
[[package]]
@ -251,16 +227,6 @@ dependencies = [
"serde",
]
[[package]]
name = "syn"
version = "1.0.109"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
dependencies = [
"proc-macro2",
"unicode-ident",
]
[[package]]
name = "syn"
version = "2.0.104"
@ -291,12 +257,6 @@ version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
[[package]]
name = "version_check"
version = "0.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
[[package]]
name = "wasi"
version = "0.14.2+wasi-0.2.4"

View File

@ -8,14 +8,7 @@ repository = "https://github.com/kristoferssolo/filecaster"
documentation = "https://docs.rs/filecaster"
homepage = "https://github.com/kristoferssolo/filecaster"
license = "MIT OR Apache-2.0"
keywords = [
"proc-macro",
"derive",
"configuration",
"file-parsing",
"defaults",
"merge",
]
keywords = ["proc-macro", "derive", "configuration", "file-parsing"]
categories = ["development-tools::procedural-macro", "parsing", "config"]
exclude = ["/.github", "/.gitignore", "/tests", "*.png", "*.md"]
readme = "README.md"
@ -27,7 +20,7 @@ merge = ["dep:merge"]
[dependencies]
proc-macro2 = "1.0"
quote = "1.0"
proc-macro-error = "1.0"
proc-macro-error2 = "2.0"
syn = { version = "2.0", features = ["extra-traits", "parsing"] }
serde = { version = "1.0", features = ["derive"] }
merge = { version = "0.2", optional = true }

View File

@ -31,10 +31,9 @@
//! Example:
//!
//! ```rust
//! use from_file::FromFile;
//! use filecaster::FromFile;
//!
//! #[derive(Debug, Clone, FromFile)]
//! #[serde(default)]
//! struct AppConfig {
//! /// If the user does not specify a host, use `"127.0.0.1"`.
//! #[from_file(default = "127.0.0.1")]
@ -48,9 +47,15 @@
//! auto_reload: bool, // requires `bool: Default`
//! }
//!
//! let file_content = r#"
//! {
//! "host": "localhost"
//! }
//! "#;
//!
//! let config_from_file = serde_json::from_str::<AppConfigFile>(file_content).unwrap();
//! // After deserializing the partial config from disk (e.g. with Serde):
//! let file: Option<AppConfigFile> = serde_yaml::from_str(yaml_text).ok();
//! let cfg: AppConfig = AppConfig::from_file(file);
//! let cfg = AppConfig::from_file(Some(config_from_file));
//! println!("{cfg:#?}");
//! ```
//!
@ -75,7 +80,7 @@ mod from_file;
pub(crate) use from_file::impl_from_file;
use proc_macro::TokenStream;
use proc_macro_error::proc_macro_error;
use proc_macro_error2::proc_macro_error;
use syn::{DeriveInput, parse_macro_input};
/// Implements the `FromFile` derive macro.