#[cfg(feature = "alloc")]
use alloc::{format, string::String, vec::Vec};
#[macro_export]
macro_rules! iformat {
($indent:expr, $($args:tt)*) => {
$crate::fmt::indent($indent, &format![$($args)*])
};
}
pub use iformat;
#[cfg(feature = "alloc")]
#[cfg_attr(feature = "nightly", doc(cfg(feature = "alloc")))]
pub fn indent(spaces: usize, string: &str) -> String {
let indentation = " ".repeat(spaces);
let lines: Vec<&str> = string.lines().collect();
let mut indented_lines: Vec<String> = Vec::new();
for line in lines {
indented_lines.push(format!("{}{}", indentation, line));
}
indented_lines.join("\n")
}