MCPcopy Create free account
hub / github.com/dtolnay/thiserror / contains_non_static_lifetime

Function contains_non_static_lifetime

impl/src/valid.rs:224–248  ·  view source on GitHub ↗
(ty: &Type)

Source from the content-addressed store, hash-verified

222}
223
224fn contains_non_static_lifetime(ty: &Type) -> bool {
225 match ty {
226 Type::Path(ty) => {
227 let bracketed = match &ty.path.segments.last().unwrap().arguments {
228 PathArguments::AngleBracketed(bracketed) => bracketed,
229 _ => return false,
230 };
231 for arg in &bracketed.args {
232 match arg {
233 GenericArgument::Type(ty) if contains_non_static_lifetime(ty) => return true,
234 GenericArgument::Lifetime(lifetime) if lifetime.ident != "static" => {
235 return true
236 }
237 _ => {}
238 }
239 }
240 false
241 }
242 Type::Reference(ty) => ty
243 .lifetime
244 .as_ref()
245 .map_or(false, |lifetime| lifetime.ident != "static"),
246 _ => false, // maybe implement later if there are common other cases
247 }
248}

Callers 1

check_field_attrsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected