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

Method modes_of

crates/wit-bindgen/src/rust.rs:311–337  ·  view source on GitHub ↗
(&self, ty: TypeId)

Source from the content-addressed store, hash-verified

309 }
310
311 fn modes_of(&self, ty: TypeId) -> Vec<(String, TypeMode)> {
312 let info = self.info(ty);
313 // Info only populated for types that are passed to and from functions. For
314 // types which are not, default to the ownership setting.
315 if !info.owned && !info.borrowed {
316 return vec![(
317 self.param_name(ty),
318 match self.ownership() {
319 Ownership::Owning => TypeMode::Owned,
320 Ownership::Borrowing { .. } => TypeMode::AllBorrowed("'a"),
321 },
322 )];
323 }
324 let mut result = Vec::new();
325 let first_mode =
326 if info.owned || !info.borrowed || matches!(self.ownership(), Ownership::Owning) {
327 TypeMode::Owned
328 } else {
329 assert!(!self.uses_two_names(&info));
330 TypeMode::AllBorrowed("'a")
331 };
332 result.push((self.result_name(ty), first_mode));
333 if self.uses_two_names(&info) {
334 result.push((self.param_name(ty), TypeMode::AllBorrowed("'a")));
335 }
336 result
337 }
338
339 fn param_name(&self, ty: TypeId) -> String {
340 let info = self.info(ty);

Callers 8

type_recordMethod · 0.80
type_tupleMethod · 0.80
type_optionMethod · 0.80
print_rust_enumMethod · 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 6

infoMethod · 0.80
result_nameMethod · 0.80
uses_two_namesMethod · 0.80
param_nameMethod · 0.80
newFunction · 0.50
pushMethod · 0.45

Tested by

no test coverage detected