bevy_macro_utils 0.19.0-rc.2

A collection of utils for Bevy Engine
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use syn::Path;

/// This formats the given `path` in standard Rust format.
///
/// ## Why does this exist?
///
/// [`Path`] does not include a `to_string()` function or a [`Debug`] impl. Hacks like
/// `path.to_token_stream().to_string()` exist, but they produce ugly spaces between the `::` separators.
pub fn path_to_string(path: &Path) -> String {
    path.segments
        .iter()
        .map(|seg| seg.ident.to_string())
        .collect::<Vec<String>>()
        .join("::")
}