depends_core/
common.rs

1use proc_macro2::Span;
2
3pub const HASH: &str = "hash";
4pub const CUSTOM_CLEAN: &str = "custom_clean";
5pub const UNHASHABLE: &str = "unhashable";
6
7pub fn unexpected_attribute(attr: &str, span: Span) -> syn::Error {
8    syn::Error::new(span, format!("Unexpected attribute \"{:?}\"", attr))
9}
10
11pub fn duplicate_attribute(span: Span) -> syn::Error {
12    syn::Error::new(span, "Attribute specified more than once")
13}
14
15#[cfg(feature = "graphviz")]
16pub fn snake_case(string: &str) -> String {
17    let mut result = String::new();
18    for (i, c) in string.chars().enumerate() {
19        if i > 0 && c.is_uppercase() {
20            result.push('_');
21        }
22        result.push(c.to_ascii_lowercase());
23    }
24    result
25}