MCPcopy Create free account
hub / github.com/SoftbearStudios/bitcode / serialize_enum

Method serialize_enum

src/serde/ser.rs:239–251  ·  view source on GitHub ↗
(self, variant_index: u32)

Source from the content-addressed store, hash-verified

237impl<'a> EncoderWrapper<'a> {
238 #[inline(always)]
239 fn serialize_enum(self, variant_index: u32) -> Result<EncoderWrapper<'a>> {
240 let variant_index = variant_index
241 .try_into()
242 .map_err(|_| error("enums with more than 256 variants are unsupported"))?;
243 let b = specify!(self, Enum);
244 b.0.encode(&variant_index);
245 let lazy = get_mut_or_resize(&mut b.1, variant_index as usize);
246 lazy.reserve_fast(1); // TODO use push instead.
247 Ok(Self {
248 lazy,
249 index_alloc: self.index_alloc,
250 })
251 }
252}
253
254macro_rules! impl_ser {

Callers 6

serialize_noneMethod · 0.80
serialize_someMethod · 0.80

Calls 4

get_mut_or_resizeFunction · 0.85
reserve_fastMethod · 0.80
errorFunction · 0.50
encodeMethod · 0.45

Tested by

no test coverage detected