Crates.io | concat-in-place |
lib.rs | concat-in-place |
version | 1.1.0 |
source | src |
created_at | 2020-01-27 05:11:58.593218 |
updated_at | 2022-02-27 13:05:45.005384 |
description | Efficient macros for concatenation of strings and vectors |
homepage | |
repository | https://codeberg.org/mmstick/concat-in-place |
max_upload_size | |
id | 202329 |
size | 19,586 |
Provides efficient concatenation of strings and vectors
The goal of these macros are to reduce the amount of allocations that are required when concatenating string buffers and vectors; with a macro that makes it simple to achieve in practice.
Appends any number of string slices onto a string buffer
use concat_in_place::strcat;
let domain = "domain.com";
let endpoint = "inventory/parts";
let id = "10512";
let mut url = String::new();
let slice = strcat!(&mut url, domain "/" endpoint "/" id);
assert_eq!(slice, "domain.com/inventory/parts/10512");
Technically works with any string type that has the following methods:
capacity
len
push_str
Appends any number of slices onto a vector
use concat_in_place::veccat;
let domain = b"domain.com";
let endpoint = b"inventory/parts";
let id = b"10512";
let mut url = Vec::new();
let slice = veccat!(&mut url, domain b"/" endpoint b"/" id);
assert_eq!(slice, b"domain.com/inventory/parts/10512");
Technically works with any type that has the following methods:
capacity
len
reserve
extend_from_slice