Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
to-values
to-values flattens Rust values into ordered f32 feature vectors. It is a
small building block for preparing inputs to neural networks,
reinforcement-learning environments, and other numeric models.
Quick start
The default derive feature converts a struct in declaration order. Exclude
identifiers or any other non-feature data with #[input(skip)].
use ToInputVector;
let observation = Observation ;
assert_eq!;
Included implementations
ToInputVector is implemented for:
f32,f64, all signed and unsigned integer primitives, and pointer-sized integers;bool, encoded as0.0or1.0;- slices, arrays,
Vec<T>,Box<T>, shared and mutable references, the unit type, and tuples up to twelve elements when their contents implement the trait.
Values are flattened in iteration or declaration order. f64 and integer
implementations use Rust's as f32 conversion; this can lose precision. Model
code that needs normalization, one-hot encoding, a missing-value indicator, or
any other domain-specific representation should implement the trait itself.
Strings, characters, pointers, Option, and Result deliberately do not have
blanket implementations. Their correct encoding is model-specific, and an
implicit encoding could silently change a model's input shape.
Custom implementations
Implement append_input_vector to specify the representation and ordering of
a domain type. Overriding input_vector_len is optional, but lets
to_input_vector allocate its output once when the length is cheap to know.
use ToInputVector;
Features and platforms
| Feature | Default | Purpose |
|---|---|---|
derive |
Yes | Re-exports #[derive(ToInputVector)] and supports #[input(skip)]. |
std |
Yes | Enables the standard-library build. |
The conversion API itself supports no_std environments with alloc:
[]
= { = "0.1", = false }
Add features = ["derive"] when a no_std crate also wants the derive macro.
The macro is a compile-time dependency only.
Versioning
This crate follows Semantic Versioning. The supported minimum Rust version is 1.85.
License
Licensed under either of: