[−][src]Macro vtkio::call_numeric_buffer_fn
Applies $fn
to an DataBuffer
mapping valid numeric data types by corresponding generic
parameters. For example, passing an DataBuffer
containing data of type u8
will cause this
macro to call $fn
with type parameter u8
like $fn::<u8>(buffer)
.
Examples
// Implement pretty printing of a `DataBuffer` derivative for numeric buffers. struct MyBuffer(DataBuffer); impl fmt::Display for MyBuffer { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { unsafe fn display_buf<T: Any + fmt::Display>(buf: &DataBuffer, f: &mut fmt::Formatter) { for item in buf.iter::<T>().unwrap() { write!(f, "{} ", item) .expect("Error occurred while writing MyBuffer."); } } call_numeric_buffer_fn!( display_buf::<_>(&self.0, f) or {}); write!(f, "") } }