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

Method insert_if

ctutils/src/ct_option.rs:176–182  ·  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

174
175 /// Conditionally inserts `value` into the [`CtOption`] if the given condition holds.
176 pub fn insert_if(&mut self, value: &T, condition: Choice)
177 where
178 T: CtAssign,
179 {
180 self.value.ct_assign(value, condition);
181 self.is_some.ct_assign(&Choice::TRUE, condition);
182 }
183
184 /// Convert the [`CtOption`] wrapper into an [`Option`], depending on whether
185 /// [`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