diff --git a/README.md b/README.md index 96533b4..04074e0 100644 --- a/README.md +++ b/README.md @@ -154,7 +154,7 @@ struct A { Load a field with the given name instead of its Rust's field name. This is helpful if the environment variable name and Rust's field name don't match: -``` +```rust #[derive(LoadEnv)] struct A { x: bool, @@ -163,4 +163,5 @@ struct A { } ``` + License: MIT diff --git a/econf/src/lib.rs b/econf/src/lib.rs index 0508da3..18d7512 100644 --- a/econf/src/lib.rs +++ b/econf/src/lib.rs @@ -151,6 +151,20 @@ //! } //! ``` //! +//! # Renaming fields +//! +//! Load a field with the given name instead of its Rust's field name. This is helpful if the environment variable name and Rust's field name don't match: +//! +//! ``` +//! # use econf::LoadEnv; +//! #[derive(LoadEnv)] +//! struct A { +//! x: bool, +//! #[econf(rename = "ANOTHER_Y")] +//! y: u64, // will be loaded from an environment variable `ANOTHER_Y` +//! } +//! ``` +//! use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque}; use std::hash::Hash; use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6};