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

Function encode

src/derive/mod.rs:64–69  ·  view source on GitHub ↗

Encodes a `T:` [`Encode`] into a [`Vec `]. Warning:** The format is subject to change between major versions.

(t: &T)

Source from the content-addressed store, hash-verified

62///
63/// **Warning:** The format is subject to change between major versions.
64pub fn encode<T: Encode + ?Sized>(t: &T) -> Vec<u8> {
65 let mut encoder = T::Encoder::default();
66 encoder.reserve(NonZeroUsize::new(1).unwrap());
67 encode_inline_never(&mut encoder, t);
68 encoder.collect()
69}
70
71/// Decodes a [`&[u8]`][`prim@slice`] into an instance of `T:` [`Decode`].
72///

Callers 7

bitcode_encodeFunction · 0.85
comparison1Function · 0.85
array_stringFunction · 0.85
array_vecFunction · 0.85
bench_binary_heap_decodeFunction · 0.85
test_empty_arrayFunction · 0.85

Calls 3

encode_inline_neverFunction · 0.85
reserveMethod · 0.45
collectMethod · 0.45

Tested by 3

array_stringFunction · 0.68
array_vecFunction · 0.68
test_empty_arrayFunction · 0.68