Easy access to struct fields in strings

🐠 add strung to the dependencies in the Cargo.toml: toml [dependencies] strung = "0.1.3" 🦀 use/import everything of the prelude in rust: rust use strung::prelude::*; 🦊 works for unnamed fields: ```rust

[derive(Strung)]

struct Struct (&'static str, u32); fn main(){ let s: String = Struct("Bob", 10).strung("{0} is {1}th"); } 🦊 works for **named** fields: rust

[derive(Strung)]

struct Struct { name: &'static str, pos: u32, } fn main(){ let s: String = Struct{name:"Bob", pos:10}.strung("{name} is {pos}th."); } ```

Prefix and Postix Prefabs

🐎 prefabs are most performant - equal to strung(): ```rust

[derive(Strung)]

struct Struct (&'static str, u32); fn main(){ let t = Struct("Bob", 10); let s = t.strungcurly("{0} is {1}th."); let s = t.strungangle("<0> is <1>th."); let s = t.strungdollry("${0} is ${1}th."); let s = t.strungdollar("$0 is $1th."); let s = t.strung_hashtag("#0 is #1th."); } ```

Custom Prefix and Postix

🐎 per struct - performance equal to prefabs: ```rust

[derive(Strung)]

[strung("<",">")]

struct Struct (&'static str, u32); fn main(){ let s: String = Struct("Bob", 10).strung("<0> is <1>th."); } 🦅 **global** - easiest, a bit less performant: rust

[derive(Strung)]

struct Struct (&'static str, u32); fn main(){ strung::config::staticglobal("<",">"); let s: String = Struct("Bob", 10).strungstatic("<0> is <1>th."); } 🐍 **per call** - most flexible: rust

[derive(Strung)]

struct Struct (&'static str, u32); fn main(){ let s: String = Struct("Bob", 10).strung_dynamic("<",">","<0> is <1>th."); } ```

Cascade

🦞 currently only for dollar and hashtag prefab!
🐳 use #[cscd], #[cascade], #[strung(cscd)] or #[strung(cascade)] on a field: ```rust

[derive(Strung)]

struct Struct (&'static str, u32);

[derive(Strung)]

struct Cascade (u32, #[cscd] Struct); fn main(){ let s: String = Cascade(11,Struct("Bob", 10)) .strung_dollar("$1.0 is $1.1th for the $0th time!"); } ```

Ignore

🦞 if a field type doesn't implement Display, it has to be ignored!
🐎 can also be used to gain minimal amounts of performance!
🐳 use #[igno], #[strung(igno)] or #[strung(ignore)] on a field
🙉 this example wouldn't compile without #[igno]: ```rust struct NoDisplay;

[derive(Strung)]

struct Struct (&'static str, u32, #[igno] NoDisplay); fn main(){ let s: String = Struct("Bob", 10, NoDisplay) .strung_dollar("$0 is $1th, he won $2!"); } ```

More Information

🦕 Documentation
🦎 Changelog
🐱 GitHub
👾 Discord Server


License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.
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.