pub struct FuncCodeLen(/* private fields */);Expand description
A newtype containing a function pointer dispatching the length method for a code.
This is a more efficient way to pass a CodeLen to a method, as
a FuncCodeLen does not need to do a runtime test to dispatch the correct
method.
Instances can be obtained by calling the new method
with a variant of the Codes enum, or by calling the
new_with_func method with a function pointer.
Note that since selection of the code happens in the new
method, it is more efficient to clone a FuncCodeLen than to create a new one.
Implementations§
Source§impl FuncCodeLen
impl FuncCodeLen
Sourcepub const fn new(code: Codes) -> Result<Self, DispatchError>
pub const fn new(code: Codes) -> Result<Self, DispatchError>
Returns a new FuncCodeLen for the given code.
The code is canonicalized before the lookup, so equivalent codes yield the same length function.
§Errors
The method will return an error if there is no constant
for the given code in FuncCodeLen.
Sourcepub const fn new_with_func(len_func: fn(u64) -> usize) -> Self
pub const fn new_with_func(len_func: fn(u64) -> usize) -> Self
Returns a new FuncCodeLen for the given function.
Trait Implementations§
Source§impl Clone for FuncCodeLen
impl Clone for FuncCodeLen
Source§fn clone(&self) -> FuncCodeLen
fn clone(&self) -> FuncCodeLen
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl CodeLen for FuncCodeLen
Here we do not depend on the bitstream, so there is no need for a “static”
version of the trait.
impl CodeLen for FuncCodeLen
Here we do not depend on the bitstream, so there is no need for a “static” version of the trait.
Source§impl Debug for FuncCodeLen
impl Debug for FuncCodeLen
Source§impl FlatType for FuncCodeLen
impl FlatType for FuncCodeLen
Source§impl MemDbgImpl for FuncCodeLen
impl MemDbgImpl for FuncCodeLen
fn _mem_dbg_rec_on( &self, _memdbg_writer: &mut impl Write, _memdbg_total_size: usize, _memdbg_max_depth: usize, _memdbg_prefix: &mut String, _memdbg_is_last: bool, _memdbg_flags: DbgFlags, _memdbg_refs: &mut HashSet<usize>, ) -> Result
fn _mem_dbg_depth_on( &self, writer: &mut impl Write, total_size: usize, max_depth: usize, prefix: &mut String, field_name: Option<&str>, is_last: bool, padded_size: usize, flags: DbgFlags, dbg_refs: &mut HashSet<usize>, ) -> Result<(), Error>
Source§fn _mem_dbg_depth_on_impl(
&self,
writer: &mut impl Write,
total_size: usize,
max_depth: usize,
prefix: &mut String,
field_name: Option<&str>,
is_last: bool,
padded_size: usize,
flags: DbgFlags,
dbg_refs: &mut HashSet<usize>,
ref_display: RefDisplay,
) -> Result<(), Error>
fn _mem_dbg_depth_on_impl( &self, writer: &mut impl Write, total_size: usize, max_depth: usize, prefix: &mut String, field_name: Option<&str>, is_last: bool, padded_size: usize, flags: DbgFlags, dbg_refs: &mut HashSet<usize>, ref_display: RefDisplay, ) -> Result<(), Error>
Source§impl MemSize for FuncCodeLen
impl MemSize for FuncCodeLen
impl Copy for FuncCodeLen
Auto Trait Implementations§
impl Freeze for FuncCodeLen
impl RefUnwindSafe for FuncCodeLen
impl Send for FuncCodeLen
impl Sync for FuncCodeLen
impl Unpin for FuncCodeLen
impl UnsafeUnpin for FuncCodeLen
impl UnwindSafe for FuncCodeLen
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> MemDbg for Twhere
T: MemDbgImpl,
impl<T> MemDbg for Twhere
T: MemDbgImpl,
Source§fn mem_dbg(&self, flags: DbgFlags) -> Result<(), Error>
fn mem_dbg(&self, flags: DbgFlags) -> Result<(), Error>
Source§fn mem_dbg_on(
&self,
writer: &mut impl Write,
flags: DbgFlags,
) -> Result<(), Error>
fn mem_dbg_on( &self, writer: &mut impl Write, flags: DbgFlags, ) -> Result<(), Error>
core::fmt::Write debug info about the structure memory
usage, expanding all levels of nested structures.Source§fn mem_dbg_depth(&self, max_depth: usize, flags: DbgFlags) -> Result<(), Error>
fn mem_dbg_depth(&self, max_depth: usize, flags: DbgFlags) -> Result<(), Error>
mem_dbg, but expanding only up to max_depth
levels of nested structures.Source§fn mem_dbg_depth_on(
&self,
writer: &mut impl Write,
max_depth: usize,
flags: DbgFlags,
) -> Result<(), Error>
fn mem_dbg_depth_on( &self, writer: &mut impl Write, max_depth: usize, flags: DbgFlags, ) -> Result<(), Error>
core::fmt::Write debug info about the structure memory
usage as mem_dbg_on, but expanding only up to
max_depth levels of nested structures.