Skip to content

Commit

Permalink
fix: test in README
Browse files Browse the repository at this point in the history
  • Loading branch information
kingwingfly committed Dec 20, 2023
1 parent 955e408 commit 093b3d2
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ This crate also has some optional features:

<!-- USAGE EXAMPLES -->
## Usage
_(You may see many `#[cfg(feature = "...")]` in the example below, if you are not familar to Rust, you may not know this attribute is for `Conditinal Compile`, so that I can test it in `cargo test --all-features` automatically to ensure all go right.)_

You can implement the `Source`, `PersistSource` and `SecretSource` yourself.
```rust no_run
use encrypt_config::{Config, SecretSource};
Expand Down Expand Up @@ -146,11 +148,13 @@ struct Foo(String);
struct SourceFoo;

//To derive [`PersistSource`]
#[cfg(not(feature = "default_config_dir"))]
#[derive(PersistSource)]
#[source(value(Foo), path("tests/persist.conf"), default([("key".to_owned(), Foo("value".to_owned()))]))]
struct PersistSourceFoo;

// To derive [`SecretSource`]
#[cfg(not(feature = "default_config_dir"))]
#[derive(SecretSource)]
#[source(value(Foo), path("tests/secret.conf"), default([("key".to_owned(), Foo("value".to_owned()))]))]
struct SecretSourceFoo;
Expand Down

0 comments on commit 093b3d2

Please sign in to comment.