error_generator 1.2.1

Transform structs and enums into fully qualified errors using attributes
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
use syn::{Attribute, Path};

use crate::parameters::ERROR_ATTRIBUTE;

/// Convert a syn::Path to a name (as String)
pub fn path_to_name(path: &Path) -> String {
    path.get_ident().map(|ident| ident.to_string()).expect("The given path was not an identifier.")
}

pub fn attribute_is_error(attribute: &Attribute) -> bool {
    path_to_name(&attribute.path) == ERROR_ATTRIBUTE
}