cow
Attribute:- Added
cow
configuration to thestatic_toml!
macro. - When enabled, it replaces static slices (e.g.,
&'static str
) and arrays withstd::borrow::Cow
. - This allows for dynamic modifications or ownership flexibility of the data.
- Example:
This generates
static_toml::static_toml! { #[static_toml(cow)] const CONFIG = include_toml!("config.toml"); }
Cow<'static, str>
instead of&'static str
.
- Added
- GitHub CI Improvements:
- Added a new Build Examples job to validate example builds.
- Updated CI to use modern GitHub Actions features and simplify workflows.
- Improved verbosity of cargo commands for better debugging.
- New Example - Config Handling:
- Added
examples/config.rs
to demonstrate cow usage and deserialization of TOML data. - Supports mixing static defaults and user-provided dynamic configurations at runtime.
- Added
- Improved Documentation:
- Expanded the README and crate documentation to explain the new
cow
attribute. - Updated macro invocation examples for clarity.
- Expanded the README and crate documentation to explain the new
- Refactored Code:
- Optimized internal handling of
static
andconst
attributes. - Improved parsing logic to validate standalone attributes like
cow
.
- Optimized internal handling of
const
Support:- The
static_toml!
macro now supports embedding TOML data asconst
values in addition tostatic
. - This is useful for const functions, const generics, or cases where a constant value is required.
- Example:
static_toml::static_toml! { const MESSAGES = include_toml!("messages.toml"); }
- The
- Mixed Storage Classes:
- You can now mix
static
andconst
definitions in a singlestatic_toml!
macro call, provided the identifiers are unique:static_toml::static_toml! { static SETTINGS = include_toml!("settings.toml"); const MESSAGES = include_toml!("messages.toml"); }
- You can now mix
auto_doc
Enhancements:- Documentation generation now reflects whether the TOML inclusion is
static
orconst
. - The generated comments will display "Static inclusion" or "Constant inclusion" accordingly.
- Documentation generation now reflects whether the TOML inclusion is
- Improved internal parsing and handling to support both
static
andconst
storage classes.
auto_doc
Attribute:- A new
auto_doc
attribute can be added tostatic_toml!
to generate automatic documentation comments. - When enabled (
auto_doc = true
), the macro appends the TOML file's path and contents as documentation, enhancing visibility in rustdoc. - Example:
static_toml::static_toml! { #[static_toml(auto_doc = true)] static EXAMPLE = include_toml!("example.toml"); }
- A new
- Documentation Generation:
auto_doc
generates inline TOML content documentation wrapped in code blocks for better display.
- Updated
toml
dependency from 0.7 to 0.8.
- Improved parsing of attributes to support
auto_doc
without breaking existing attribute handling.
- License: Added an MIT License to the repository.
- Documentation Improvements:
- Enhanced README with a clearer usage example for including TOML files.
- Added structured examples for handling nested TOML data with the
static_toml!
macro.
- Example Data: Introduced a sample messages.toml file for demonstration purposes.
- Updated
.gitignore
to excludeCargo.lock
for libraries as per Cargo FAQ.
- Deleted
Cargo.lock
from version control since it is unnecessary for library crates.