Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
bevyengine
GitHub Repository: bevyengine/bevy
Path: blob/main/crates/bevy_macro_utils/src/path.rs
30635 views
1
use syn::Path;
2
3
/// This formats the given `path` in standard Rust format.
4
///
5
/// ## Why does this exist?
6
///
7
/// [`Path`] does not include a `to_string()` function or a [`Debug`] impl. Hacks like
8
/// `path.to_token_stream().to_string()` exist, but they produce ugly spaces between the `::` separators.
9
pub fn path_to_string(path: &Path) -> String {
10
path.segments
11
.iter()
12
.map(|seg| seg.ident.to_string())
13
.collect::<Vec<String>>()
14
.join("::")
15
}
16
17