MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / lifetime_for

Method lifetime_for

crates/wit-bindgen/src/rust.rs:379–401  ·  view source on GitHub ↗
(&self, info: &TypeInfo, mode: TypeMode)

Source from the content-addressed store, hash-verified

377 }
378
379 fn lifetime_for(&self, info: &TypeInfo, mode: TypeMode) -> Option<&'static str> {
380 if matches!(self.ownership(), Ownership::Owning) {
381 return None;
382 }
383 let lt = match mode {
384 TypeMode::AllBorrowed(s) => s,
385 _ => return None,
386 };
387 // No lifetimes needed unless this has a list.
388 if !info.has_list {
389 return None;
390 }
391 // If two names are used then this type will have an owned and a
392 // borrowed copy and the borrowed copy is being used, so it needs a
393 // lifetime. Otherwise if it's only borrowed and not owned then this can
394 // also use a lifetime since it's not needed in two contexts and only
395 // the borrowed version of the structure was generated.
396 if self.uses_two_names(info) || (info.borrowed && !info.owned) {
397 Some(lt)
398 } else {
399 None
400 }
401 }
402
403 fn typedfunc_sig(&self, func: &Function, param_mode: TypeMode) -> String {
404 let mut out = "(".to_string();

Callers 10

tyidMethod · 0.80
type_recordMethod · 0.80
type_tupleMethod · 0.80
type_optionMethod · 0.80
print_rust_enumMethod · 0.80
print_rust_enum_debugMethod · 0.80
type_resultMethod · 0.80
type_aliasMethod · 0.80
type_listMethod · 0.80
type_mapMethod · 0.80

Implementers 1

lib.rscrates/wit-bindgen/src/lib.rs

Calls 1

uses_two_namesMethod · 0.80

Tested by

no test coverage detected