Sha256: 725e3015700ace4d7fd4d403300f8145129d1b6f23f0c95c69f89e7298c27160
Contents?: true
Size: 609 Bytes
Versions: 19
Compression:
Stored size: 609 Bytes
Contents
use syn::{spanned::Spanned, Attribute, Error}; pub fn get_magnus_attrubute(attrs: &[Attribute]) -> Result<Option<&Attribute>, Error> { let attrs = attrs .iter() .filter(|attr| attr.path().is_ident("magnus")) .collect::<Vec<_>>(); if attrs.is_empty() { return Ok(None); } else if attrs.len() > 1 { return Err(attrs .into_iter() .map(|a| Error::new(a.span(), "duplicate attribute")) .reduce(|mut a, b| { a.combine(b); a }) .unwrap()); } Ok(Some(attrs[0])) }
Version data entries
19 entries across 19 versions & 1 rubygems