even_bigger_s

Crates.ioeven_bigger_s
lib.rseven_bigger_s
version1.0.0
sourcesrc
created_at2024-03-01 13:19:18.538175
updated_at2024-03-01 13:19:18.538175
descriptionBetter String Literal
homepagehttps://github.com/Adamska1008/even_bigger_s
repositoryhttps://github.com/Adamska1008/even_bigger_s
max_upload_size
id1158895
size6,306
Zijian Zang (Adamska1008)

documentation

README

Even Bigger S: Better String Literal

Everyone is tired of typing "foo"._string() and String::from("bar") stuff. Maybe you've tried Big S, a helpful crate with only one funcion in one line. With "Big S" you can do this:

assert_eq!(S("foo"), "foo".to_string())

Cool, but things can be better, with Even Bigger S and also only one macro S.

Usage

empty string:

  • Big S: S("")
  • Even Bigger S: S!()

string:

  • Big S: S("foo")
  • Even Bigger S: S!("foo")

concat string:

This one is new.

  • common: "foo".to_string() + "bar"
  • Big S: S("foo") + "bar"
  • Even Bigger S: S!("foo" "bar")

If you want to separate strings with spaces, you can do:

assert_eq!(S!("hello", "world"), "hello world".to_string());

This one is especially helpful with an extensive string literal:

assert_eq!(
    S!(
        "Imagine how stupid it will be to include a very long paragraph literal in rust code.",
        "With even bigger s, text has much more readability.",
        "Have you ever seen a very very long String literal in your code?"
        "Well, I have. I guess I won't see that any more.",
    ),
    "Imagine how stupid it will be to include a very long paragraph literal in rust code. With even bigger s, text has much more readability. Have you ever seen a very very long String literal in your code? Well, I have. I guess I won't see that any more.".to_string()
)
Commit count: 0

cargo fmt