🐠 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
struct Struct (&'static str, u32);
fn main(){
let s: String = Struct("Bob", 10).strung("{0} is {1}th");
}
🦊 works for **named** fields:
rust
struct Struct { name: &'static str, pos: u32, } fn main(){ let s: String = Struct{name:"Bob", pos:10}.strung("{name} is {pos}th."); } ```
🐎 prefabs are most performant - equal to strung()
:
```rust
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."); } ```
🐎 per struct - performance equal to prefabs: ```rust
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
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
struct Struct (&'static str, u32); fn main(){ let s: String = Struct("Bob", 10).strung_dynamic("<",">","<0> is <1>th."); } ```
🦞 currently only for dollar
and hashtag
prefab!
🐳 use #[cscd]
, #[cascade]
, #[strung(cscd)]
or #[strung(cascade)]
on a field:
```rust
struct Struct (&'static str, u32);
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!"); } ```
🦞 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;
struct Struct (&'static str, u32, #[igno] NoDisplay); fn main(){ let s: String = Struct("Bob", 10, NoDisplay) .strung_dollar("$0 is $1th, he won $2!"); } ```
🦕 Documentation
🦎 Changelog
🐱 GitHub
👾 Discord Server
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.