Skip to content

Commit e611217

Browse files
authored
docs: add doc comments to default_value helpers (#10437) (#11200)
1 parent 2d95076 commit e611217

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

crates/wasmtime/src/runtime/types.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2677,7 +2677,10 @@ impl GlobalType {
26772677
};
26782678
GlobalType::new(ty, mutability)
26792679
}
2680+
/// Construct a new global import with this type’s default value.
26802681
///
2682+
/// This creates a host `Global` in the given store initialized to the
2683+
/// type’s zero/null default (e.g. `0` for numeric globals, `null_ref` for refs).
26812684
pub fn default_value(&self, store: impl AsContextMut) -> Result<RuntimeGlobal> {
26822685
let val = self
26832686
.content()
@@ -2819,7 +2822,10 @@ impl TableType {
28192822
pub(crate) fn wasmtime_table(&self) -> &Table {
28202823
&self.ty
28212824
}
2825+
/// Construct a new table import whose entries are filled with this type’s default.
28222826
///
2827+
/// Creates a host `Table` in the store with its initial size and element
2828+
/// type’s default (e.g. `null_ref` for nullable refs).
28232829
pub fn default_value(&self, store: impl AsContextMut) -> Result<RuntimeTable> {
28242830
let val: ValType = self.element().clone().into();
28252831
let init_val = val
@@ -3160,7 +3166,10 @@ impl MemoryType {
31603166
pub(crate) fn wasmtime_memory(&self) -> &Memory {
31613167
&self.ty
31623168
}
3169+
/// Construct a new memory import initialized to this memory type’s default state
31633170
///
3171+
/// Returns a host `Memory` in the given store with the configured initial
3172+
/// page size and zeroed contents.
31643173
pub fn default_value(&self, store: impl AsContextMut) -> Result<RuntimeMemory> {
31653174
RuntimeMemory::new(store, self.clone())
31663175
}

0 commit comments

Comments
 (0)