join_str

Crates.iojoin_str
lib.rsjoin_str
version0.1.0
sourcesrc
created_at2022-05-19 20:55:01.643472
updated_at2022-05-19 20:55:01.643472
descriptionProc macro to do simple string interpolation as an array join
homepage
repositoryhttps://github.com/NiceneNerd/join_str
max_upload_size
id589924
size2,474
Caleb Smith (NiceneNerd)

documentation

README

join_str

Simple proc macro to do simple string interpolation as an array join, since it's one of the most efficient methods.

use join_str::jstr;

fn main () {
  let actor_name = "GameROMPlayer";
  assert_eq!(
    String::from("Actor/ActorLink/GameROMPlayer.bxml"),
    jstr!("Actor/ActorLink/{actor_name}.bxml")
  );
}

If your interpolated code contains quotation marks, pass a raw string to the macro:

use join_str::jstr;
use std::collections::HashMap;

fn main () {
  let mut actors: HashMap<String, String> = HashMap::new();
  actors.insert(String::from("GameROMPlayer"), String::from("Link"));
  assert_eq!(
    String::from("The GameROMPlayer actor is Link"),
    jstr!(r#"The GameROMPlayer actor is {actors["GameROMPlayer"]}"#)
  );
}
Commit count: 6

cargo fmt