MCPcopy Create free account
hub / github.com/hashintel/hash / sample

Method sample

tests/graph/test-data/rust/src/seeding/distributions/value/mod.rs:157–172  ·  view source on GitHub ↗
(&self, rng: &mut R)

Source from the content-addressed store, hash-verified

155
156impl Distribution<PropertyValueWithMetadata> for ValueDistribution<'_> {
157 fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> PropertyValueWithMetadata {
158 let value = match &self.value {
159 InnerValueDistribution::Null => PropertyValue::Null,
160 InnerValueDistribution::Boolean(boolean) => PropertyValue::Bool(boolean.sample(rng)),
161 InnerValueDistribution::Number(number) => PropertyValue::Number(number.sample(rng)),
162 InnerValueDistribution::String(string) => PropertyValue::String(string.sample(rng)),
163 };
164
165 PropertyValueWithMetadata {
166 value,
167 metadata: ValueMetadata {
168 data_type_id: Some(self.data_type_url.clone().into_owned()),
169 ..ValueMetadata::default()
170 },
171 }
172 }
173}
174
175pub trait ValueDistributionRegistry {

Callers

nothing calls this directly

Calls 6

BoolClass · 0.85
StringClass · 0.85
NumberClass · 0.50
defaultFunction · 0.50
into_ownedMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected