MCPcopy Create free account
hub / github.com/Wulf/tsync / get_attribute

Function get_attribute

src/utils.rs:248–270  ·  view source on GitHub ↗

Get the attribute matching needle name.

(
    needle: &'a str,
    attributes: &'a [syn::Attribute],
)

Source from the content-addressed store, hash-verified

246
247/// Get the attribute matching needle name.
248pub fn get_attribute<'a>(
249 needle: &'a str,
250 attributes: &'a [syn::Attribute],
251) -> Option<&'a syn::Attribute> {
252 // if multiple attributes pass the conditions
253 // we still want to return the last
254 attributes
255 .iter()
256 // Reverse the iterator to check the last attribute first.
257 .rev()
258 // From the `find` documentation:
259 // "find() is short-circuiting;
260 // in other words, it will stop processing as soon as the closure returns true."
261 .find(|attr| {
262 // Checks if any segments in the iterator equal `needle`. Returns
263 // true if a match is found, otherwise false.
264 attr.meta
265 .path()
266 .segments
267 .iter()
268 .any(|segment| segment.ident == needle)
269 })
270}
271
272pub(crate) fn parse_serde_case(
273 val: impl Into<Option<String>>,

Callers 1

get_attribute_argFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected