versatiles_derive 0.15.1

A toolbox for converting, checking and serving map tiles in various formats.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
mod decode_struct;

pub use decode_struct::decode_struct;
use syn::{Attribute, Meta};

pub fn extract_comment(attr: &Attribute) -> Option<String> {
	if attr.path().is_ident("doc") {
		if let Meta::NameValue(meta) = &attr.meta {
			if let syn::Expr::Lit(lit) = &meta.value {
				if let syn::Lit::Str(lit_str) = &lit.lit {
					let text = lit_str.value().trim().to_string();
					return if text.is_empty() { None } else { Some(text) };
				}
			}
		}
	}
	None
}