1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//! Provides the `concat_strs!` macro, which allows quickly building a `String`
//! from a number of components.
//!
//! Example usage:
//!
//! ```
//! use concat_strs::concat_strs;
//!
//! assert_eq!(
//! "foo_bar_3.0",
//! concat_strs!(
//! "foo",
//! '_',
//! "bar",
//! '_',
//! 3.0,
//! )
//! );
//! ```
use proc_macro_hack;
/// Concatenates a number of `&str` expressions, `&str` literals, and `char`
/// literals together.
///
/// Generated code for
/// ```
/// use concat_strs::concat_strs;
///
/// let bar = "some &str expression";
/// let s = concat_strs!(
/// "foo",
/// ' ',
/// bar,
/// 'c',
/// "baz",
/// );
/// assert_eq!(s, "foo some &str expressioncbaz");
/// ```
/// is roughly
/// ```
/// let bar = "some &str expression";
/// let s = {
/// let tmp1 = bar;
/// let tmp1_len = bar.len();
/// let mut ret = String::with_capacity(tmp1_len + 8);
/// ret.push_str("foo");
/// ret.push(' ');
/// ret.push_str(tmp1);
/// ret.push('c');
/// ret.push_str("baz");
/// ret
/// };
/// assert_eq!(s, "foo some &str expressioncbaz");
/// ```
///
/// This is [the fastest way to build a string from components][concat-benches].
///
/// [concat-benches]: https://github.com/hoodie/concatenation_benchmarks-rs
pub use concat_strs;