MCPcopy Create free account
hub / github.com/AI45Lab/Code / js_optional_usize

Function js_optional_usize

sdk/node/src/lib.rs:2226–2238  ·  view source on GitHub ↗
(
    value: Option<f64>,
    field_name: &str,
    default_value: usize,
)

Source from the content-addressed store, hash-verified

2224}
2225
2226fn js_optional_usize(
2227 value: Option<f64>,
2228 field_name: &str,
2229 default_value: usize,
2230) -> napi::Result<usize> {
2231 match value {
2232 Some(n) if n.is_finite() && n >= 0.0 && n.fract() == 0.0 => Ok(n as usize),
2233 Some(_) => Err(napi::Error::from_reason(format!(
2234 "{field_name} must be a non-negative integer"
2235 ))),
2236 None => Ok(default_value),
2237 }
2238}
2239
2240fn js_artifact_store_limits_to_rust(
2241 limits: ArtifactStoreLimits,

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected