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

Method set

cranelift/codegen/src/settings.rs:258–277  ·  view source on GitHub ↗
(&mut self, name: &str, value: &str)

Source from the content-addressed store, hash-verified

256 }
257
258 fn set(&mut self, name: &str, value: &str) -> SetResult<()> {
259 use self::detail::Detail;
260 let (offset, detail) = self.lookup(name)?;
261 match detail {
262 Detail::Bool { bit } => {
263 self.set_bit(offset, bit, parse_bool_value(value)?);
264 }
265 Detail::Num => {
266 self.bytes[offset] = value
267 .parse()
268 .map_err(|_| SetError::BadValue("number".to_string()))?;
269 }
270 Detail::Enum { last, enumerators } => {
271 self.bytes[offset] =
272 parse_enum_value(value, self.template.enums(last, enumerators))?;
273 }
274 Detail::Preset => return Err(SetError::BadName(name.to_string())),
275 }
276 Ok(())
277 }
278}
279
280/// An error produced when changing a setting.

Callers

nothing calls this directly

Calls 8

parse_bool_valueFunction · 0.85
parse_enum_valueFunction · 0.85
OkFunction · 0.85
set_bitMethod · 0.80
lookupMethod · 0.45
parseMethod · 0.45
to_stringMethod · 0.45
enumsMethod · 0.45

Tested by

no test coverage detected