pub trait AsDataType: 'static {
const DATA_TYPE: DataType;
// Provided methods
fn is_match(data_type: DataType) -> bool { ... }
fn describe(data_type: DataType) -> Describe { ... }
}Expand description
Associate a primitive type T with a DataType enum variant.
Required Associated Constants§
Provided Methods§
Sourcefn describe(data_type: DataType) -> Describe
fn describe(data_type: DataType) -> Describe
Return a std::fmt::Display compatible struct describing the match with data_type.
use diskann_benchmark_runner::utils::datatype::{DataType, AsDataType};
// Matched data type.
let desc = f32::describe(DataType::Float32);
assert!(desc.is_match());
assert_eq!(desc.to_string(), "successful match");
// Mismatched data type.
let desc = f32::describe(DataType::Float16);
assert!(!desc.is_match());
assert_eq!(desc.to_string(), "expected \"float32\" but found \"float16\"");Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".