MCPcopy Create free account
hub / github.com/RustCrypto/utils / insert_if

Method insert_if

ctutils/src/ct_option.rs:175–181  ·  view source on GitHub ↗

Conditionally inserts `value` into the [`CtOption`] if the given condition holds.

(&mut self, value: &T, condition: Choice)

Source from the content-addressed store, hash-verified

173
174 /// Conditionally inserts `value` into the [`CtOption`] if the given condition holds.
175 pub fn insert_if(&mut self, value: &T, condition: Choice)
176 where
177 T: CtAssign,
178 {
179 self.value.ct_assign(value, condition);
180 self.is_some.ct_assign(&Choice::TRUE, condition);
181 }
182
183 /// Convert the [`CtOption`] wrapper into an [`Option`], depending on whether
184 /// [`CtOption::is_some`] is a truthy or falsy [`Choice`].

Callers 3

insert_ifFunction · 0.80
ct_lookupMethod · 0.80
ct_findMethod · 0.80

Calls 1

ct_assignMethod · 0.45

Tested by 1

insert_ifFunction · 0.64