UniversalModel

Struct UniversalModel 

Source
pub struct UniversalModel { /* private fields */ }
Expand description

Use UniversalModel::auto() to let TreeBoost analyze your data and pick the best mode. The analysis result is stored and can be retrieved with UniversalModel::analysis().

Implementations§

Source§

impl UniversalModel

Source

pub fn with_feature_extractor(self, extractor: FeatureExtractor) -> Self

Set feature extractor for LinearThenTree inference

This is called after training to store the feature extraction configuration (which columns to exclude, auto-exclusion settings). This ensures consistent feature extraction during inference for the linear component.

Source

pub fn feature_extractor(&self) -> Option<&FeatureExtractor>

Get the feature extractor (if set)

Source

pub fn train( dataset: &BinnedDataset, config: UniversalConfig, loss_fn: &dyn LossFunction, ) -> Result<Self>

Train a UniversalModel on binned data

§Arguments
  • dataset - Binned training data
  • config - Training configuration (fully serializable and persisted)
  • loss_fn - Loss function for computing gradients during training
§Important Notes
  • The loss function is NOT persisted in the saved model. It is used only during training to compute gradients. The trained model is loss-function-agnostic and will work correctly with any data processed with the same preprocessing.
  • The config is fully persisted and can be exported via [config()] or saved to JSON for inspection and reuse.
  • For reproducibility, store your loss function choice separately if needed.
§Example
// Train with MSE loss
let model = UniversalModel::train(&dataset, config, &MseLoss)?;

// Save config and model
let config_json = serde_json::to_string_pretty(model.config())?;
std::fs::write("config.json", config_json)?;
model.save("model.rkyv")?;

// Later: Load and use (loss function is already baked into the model)
let loaded = UniversalModel::load("model.rkyv")?;
let preds = loaded.predict(&test_dataset)?;  // No need to specify loss again
Source

pub fn train_with_raw_features( dataset: &BinnedDataset, raw_features: &[f32], config: UniversalConfig, loss_fn: &dyn LossFunction, ) -> Result<Self>

Train LinearThenTree with raw features (recommended for best accuracy)

For LinearThenTree mode, passing raw (unbinned) features significantly improves the linear model’s accuracy. Without raw features, LTT uses bin-center approximations which lose precision that linear models need.

§Arguments
  • dataset - Binned dataset (for tree training)
  • raw_features - Original features, row-major f32 array (num_rows * num_features)
  • config - Training configuration
  • loss_fn - Loss function
§Example
let model = UniversalModel::train_with_raw_features(
    &binned_dataset,
    &scaled_features,  // Original StandardScaler'd features
    config,
    &MseLoss,
)?;
Source

pub fn train_with_linear_feature_selection( dataset: &BinnedDataset, raw_features: &[f32], linear_feature_indices: &[usize], config: UniversalConfig, loss_fn: &dyn LossFunction, ) -> Result<Self>

Train LinearThenTree with feature selection for linear model

This allows using a curated subset of features for the linear model while trees use all features. This can improve linear generalization by excluding meaningless features (like row IDs) from linear.

§Arguments
  • dataset - Binned dataset (for tree training with all features)
  • raw_features - All features, row-major f32 array
  • linear_feature_indices - Which feature indices to use for linear model
  • config - Training configuration
  • loss_fn - Loss function
Source

pub fn auto(dataset: &BinnedDataset, loss_fn: &dyn LossFunction) -> Result<Self>

Train with automatic mode selection

This is TreeBoost’s “smart” entry point. It:

  1. Analyzes your dataset (lightweight probes on subsamples)
  2. Picks the best boosting mode with confidence score
  3. Trains the model with optimal settings
  4. Stores the analysis for inspection
§Example
use treeboost::{UniversalModel, MseLoss};

let model = UniversalModel::auto(&dataset, &MseLoss)?;

// See what mode was selected and why
println!("Mode: {:?}", model.mode());
println!("Confidence: {:?}", model.selection_confidence());
println!("{}", model.analysis_report().unwrap());
§When to Use

Use auto() when:

  • You’re not sure which mode is best for your data
  • You want TreeBoost to explain its decision
  • You want a simple one-liner that “just works”

Use train() when:

  • You know the best mode for your data
  • You need fine-grained control over configuration
  • You’re running benchmarks and want deterministic mode
Source

pub fn auto_with_config( dataset: &BinnedDataset, config: UniversalConfig, loss_fn: &dyn LossFunction, ) -> Result<Self>

Train with automatic mode selection and custom configuration

Like auto(), but lets you customize other settings (num_rounds, tree config, etc.). The mode will be overridden by the analysis recommendation.

§Example
let config = UniversalConfig::new()
    .with_num_rounds(200)
    .with_learning_rate(0.05);

let model = UniversalModel::auto_with_config(&dataset, config, &MseLoss)?;
Source

pub fn auto_with_analysis_config( dataset: &BinnedDataset, config: UniversalConfig, analysis_config: AnalysisConfig, loss_fn: &dyn LossFunction, ) -> Result<Self>

Train with automatic mode selection and custom analysis configuration

Full control over both model config and analysis settings.

§Example
let config = UniversalConfig::new().with_num_rounds(200);
let analysis_config = AnalysisConfig::fast(); // Quick analysis

let model = UniversalModel::auto_with_analysis_config(
    &dataset, config, analysis_config, &MseLoss
)?;
Source

pub fn train_with_selection( dataset: &BinnedDataset, config: UniversalConfig, selection: ModeSelection, loss_fn: &dyn LossFunction, ) -> Result<Self>

Train using a ModeSelection strategy

This is the most flexible entry point, supporting:

  • ModeSelection::Auto - Automatic analysis and selection
  • ModeSelection::AutoWithConfig(config) - Auto with custom analysis
  • ModeSelection::Fixed(mode) - Explicit mode specification
§Example
// Auto mode
let model = UniversalModel::train_with_selection(
    &dataset, config, ModeSelection::Auto, &MseLoss
)?;

// Fixed mode
let model = UniversalModel::train_with_selection(
    &dataset, config, ModeSelection::Fixed(BoostingMode::LinearThenTree), &MseLoss
)?;
Source

pub fn extract_raw_features(dataset: &BinnedDataset) -> Vec<f32>

Extract raw feature values from BinnedDataset using bin-center approximation

⚠️ Note: This is a fallback method with accuracy limitations. For best results, use FeatureExtractor with the original DataFrame instead. See the feature_extractor module documentation for a detailed comparison.

This method approximates raw values by using the midpoint of bin boundaries. While functional, this loses precision compared to extracting from the original DataFrame with FeatureExtractor.

Returns row-major f32 array for linear model training.

§When to Use
  • Only when you have a BinnedDataset but not the original DataFrame
  • When using UniversalModel directly (advanced usage)
  • When slight accuracy loss is acceptable
use treeboost::dataset::feature_extractor::FeatureExtractor;

let extractor = FeatureExtractor::new();
let (raw_features, num_features) = extractor.extract(&df, "target")?;
// Use raw_features with train_with_raw_features()

Extract raw features from bins (lossy approximation)

Deprecated approach: This method is kept for compatibility but delegates to BinnedDataset::extract_raw_features_from_bins() for consistency across the codebase. For best accuracy in LinearThenTree mode, pass actual raw features to training instead of relying on bin-center approximation.

§Historical Note

Previous implementation used bin-center approximation (midpoint between boundaries) for improved accuracy. Current implementation uses bin split values for consistency. The difference is negligible in practice, and users needing high accuracy should pass raw features directly rather than relying on either approximation.

Source

pub fn predict(&self, dataset: &BinnedDataset) -> Vec<f32>

Predict for all rows in dataset

Source

pub fn predict_with_raw_features( &self, dataset: &BinnedDataset, raw_features: &[f32], ) -> Vec<f32>

Predict for all rows using raw features (recommended for LinearThenTree)

For LinearThenTree mode, using raw (unbinned) features for the linear model gives significantly better accuracy than the bin-center approximation.

§Arguments
  • dataset - Binned dataset (used for tree predictions)
  • raw_features - Original features, row-major f32 array (num_rows * num_features)
§Note

For PureTree and RandomForest, raw_features is ignored (trees use binned data).

Source

pub fn predict_linear_only( &self, dataset: &BinnedDataset, raw_features: &[f32], ) -> Result<Vec<f32>>

Predict using only linear component (LinearThenTree mode only)

Returns predictions from base + linear model, without tree contribution. Useful for comparing linear-only vs full LinearThenTree performance.

Source

pub fn predict_row(&self, dataset: &BinnedDataset, row_idx: usize) -> f32

Predict for a single row

Source

pub fn mode(&self) -> BoostingMode

Get the boosting mode

Source

pub fn config(&self) -> &UniversalConfig

Get training configuration

Source

pub fn save(&self, path: impl AsRef<Path>) -> Result<()>

Save the model to a file using zero-copy rkyv serialization

§Example
model.save("model.rkyv")?;
let loaded = UniversalModel::load("model.rkyv")?;
Source

pub fn load(path: impl AsRef<Path>) -> Result<Self>

Load a model from a file using zero-copy rkyv deserialization

§Example
let model = UniversalModel::load("model.rkyv")?;
let predictions = model.predict(&dataset);
Source

pub fn num_trees(&self) -> usize

Get number of trees

Source

pub fn base_prediction(&self) -> f32

Get base prediction

For PureTree, this delegates to GBDTModel. For LinearThenTree, returns the original base prediction (GBDTModel was trained on residuals). For RandomForest, returns the stored base prediction.

Source

pub fn has_linear(&self) -> bool

Check if model has linear component

Source

pub fn linear_booster(&self) -> Option<&LinearBooster>

Get linear booster reference (if present)

Source

pub fn gbdt_model(&self) -> Option<&GBDTModel>

Get underlying GBDTModel (for PureTree and LinearThenTree modes)

Source

pub fn trees(&self) -> &[Tree]

Get trees (only for RandomForest mode; PureTree/LinearThenTree use GBDTModel)

Source

pub fn num_features(&self) -> usize

Get number of features

Source

pub fn analysis(&self) -> Option<&DatasetAnalysis>

Get the dataset analysis that led to mode selection (if auto mode was used)

Returns Some(analysis) if the model was trained with auto() or train_with_selection(Auto). Returns None if a fixed mode was specified.

§Example
let model = UniversalModel::auto(&dataset, &MseLoss)?;

if let Some(analysis) = model.analysis() {
    println!("Linear R²: {:.2}", analysis.linear_r2);
    println!("Tree gain: {:.2}", analysis.tree_gain);
    println!("Noise floor: {:.2}", analysis.noise_floor);
}
Source

pub fn selection_confidence(&self) -> Option<Confidence>

Get the confidence in the mode selection (if auto mode was used)

Returns the confidence level from the analysis:

  • High: Very clear signal, strongly recommend this mode
  • Medium: Reasonable signal, this mode is likely best
  • Low: Weak signal, consider validating with cross-validation

Returns None if a fixed mode was specified.

Source

pub fn was_auto_selected(&self) -> bool

Check if the mode was automatically selected

Source

pub fn analysis_report(&self) -> Option<AnalysisReport<'_>>

Get a formatted analysis report (if auto mode was used)

Returns a human-readable report explaining:

  • Dataset characteristics (linear signal, tree gain, noise floor)
  • Mode scores for each option
  • Why the selected mode was chosen
  • Alternative modes to consider
§Example
let model = UniversalModel::auto(&dataset, &MseLoss)?;

if let Some(report) = model.analysis_report() {
    println!("{}", report);
}
Source

pub fn analysis_summary(&self) -> Option<String>

Get a compact single-line summary of the analysis (if auto mode was used)

Useful for logging or progress output.

§Example
let model = UniversalModel::auto(&dataset, &MseLoss)?;

if let Some(summary) = model.analysis_summary() {
    log::info!("{}", summary);
}
Source

pub fn predict_with_intervals( &self, dataset: &BinnedDataset, ) -> Result<(Vec<f32>, Vec<f32>, Vec<f32>)>

Predict with conformal prediction intervals

Returns (predictions, lower_bounds, upper_bounds) for uncertainty quantification.

§Note

Only supported in PureTree mode (delegates to GBDTModel). LinearThenTree and RandomForest modes return an error.

Source

pub fn conformal_quantile(&self) -> Option<f32>

Get the calibrated conformal quantile (if available)

Source

pub fn predict_proba(&self, dataset: &BinnedDataset) -> Result<Vec<f32>>

Binary classification: predict probabilities

Returns probabilities in [0, 1] for binary classification. Requires model trained with binary log loss.

Source

pub fn predict_class( &self, dataset: &BinnedDataset, threshold: f32, ) -> Result<Vec<u32>>

Binary classification: predict classes

Returns 0 or 1 based on threshold (default: 0.5).

Source

pub fn is_multiclass(&self) -> bool

Check if model is multi-class

Source

pub fn get_num_classes(&self) -> usize

Get number of classes (1 for regression, 2+ for classification)

Source

pub fn predict_proba_multiclass( &self, dataset: &BinnedDataset, ) -> Result<Vec<Vec<f32>>>

Multi-class classification: predict probabilities for each class

Returns Vec<Vec> where each inner vec contains probabilities for all classes.

Source

pub fn predict_class_multiclass( &self, dataset: &BinnedDataset, ) -> Result<Vec<u32>>

Multi-class classification: predict class labels

Source

pub fn predict_raw_multiclass( &self, dataset: &BinnedDataset, ) -> Result<Vec<Vec<f32>>>

Multi-class classification: predict raw logits

Source

pub fn feature_importance(&self) -> Vec<f32>

Get feature importance scores

Returns importance scores for each feature based on gain/split frequency. For PureTree/LinearThenTree, delegates to GBDTModel. For RandomForest, computes importance from split frequencies across all trees.

Source

pub fn predict_raw(&self, features: &[f64]) -> Result<Vec<f32>>

Predict from raw (unbinned) feature values

Useful when you have raw feature values and don’t want to create a BinnedDataset. Only supported in PureTree mode.

§Arguments
  • features - Raw feature values for one or more rows, flattened row-major
Source

pub fn predict_raw_with_intervals( &self, features: &[f64], ) -> Result<(Vec<f32>, Vec<f32>, Vec<f32>)>

Predict with intervals from raw (unbinned) feature values

Source

pub fn predict_proba_raw(&self, features: &[f64]) -> Result<Vec<f32>>

Binary classification probability from raw features

Source

pub fn predict_class_raw( &self, features: &[f64], threshold: f32, ) -> Result<Vec<u32>>

Binary classification class from raw features

Source

pub fn predict_proba_multiclass_raw( &self, features: &[f64], ) -> Result<Vec<Vec<f32>>>

Multi-class probabilities from raw features

Source

pub fn predict_class_multiclass_raw(&self, features: &[f64]) -> Result<Vec<u32>>

Multi-class class labels from raw features

Source

pub fn predict_raw_multiclass_raw( &self, features: &[f64], ) -> Result<Vec<Vec<f32>>>

Multi-class raw logits from raw features

Source

pub fn update( &mut self, dataset: &BinnedDataset, loss_fn: &dyn LossFunction, additional_rounds: usize, ) -> Result<IncrementalUpdateReport>

Update the model with new training data (incremental learning)

This method continues training from the current model state:

  • PureTree: Appends new trees trained on residuals
  • LinearThenTree: Updates linear weights (warm_fit) + appends new trees
  • RandomForest: Appends new bootstrap trees
§Arguments
  • dataset - New data to train on (must have same feature schema)
  • loss_fn - Loss function (should match original training)
  • additional_rounds - Number of new boosting rounds (trees) to add
§Example
// Train on January data
let model = UniversalModel::train(&jan_data, config, &MseLoss)?;

// Update with February data (10 more trees)
model.update(&feb_data, &MseLoss, 10)?;
Source

pub fn save_trb(&self, path: impl AsRef<Path>, description: &str) -> Result<()>

Save model to TRB (TreeBoost) incremental format

TRB format supports incremental updates without rewriting the entire file. Use this format when you plan to update the model with new data.

§Example
model.save_trb("model.trb", "Initial training on January data")?;

// Later, after updating:
model.save_trb_update("model.trb", 1000, "February update")?;
Source

pub fn save_trb_update( &self, path: impl AsRef<Path>, rows_trained: usize, description: &str, ) -> Result<()>

Append an update to an existing TRB file

This appends a new segment without rewriting the base model. The model must be loaded with load_trb() before calling this.

§Arguments
  • path - Path to existing .trb file
  • rows_trained - Number of rows used in this update
  • description - Description of this update
Source

pub fn load_trb(path: impl AsRef<Path>) -> Result<Self>

Load model from TRB format

Loads the base model and applies all update segments.

§Example
let model = UniversalModel::load_trb("model.trb")?;
Source

pub fn is_compatible_for_update(&self, dataset: &BinnedDataset) -> bool

Check if model is compatible with dataset for incremental update

Source

pub fn gbdt_model_mut(&mut self) -> Option<&mut GBDTModel>

Get mutable reference to underlying GBDTModel (for advanced manipulation)

Source

pub fn linear_booster_mut(&mut self) -> Option<&mut LinearBooster>

Get mutable reference to linear booster (for advanced manipulation)

Source

pub fn trees_mut(&mut self) -> &mut Vec<Tree>

Get mutable reference to trees (for RandomForest mode)

Trait Implementations§

Source§

impl Archive for UniversalModel

Source§

type Archived = ArchivedUniversalModel

The archived representation of this type. Read more
Source§

type Resolver = UniversalModelResolver

The resolver for this type. It must contain all the additional information from serializing needed to make the archived type from the normal type.
Source§

fn resolve(&self, resolver: Self::Resolver, out: Place<Self::Archived>)

Creates the archived version of this value at the given position and writes it to the given output. Read more
Source§

const COPY_OPTIMIZATION: CopyOptimization<Self> = _

An optimization flag that allows the bytes of this type to be copied directly to a writer instead of calling serialize. Read more
Source§

impl Clone for UniversalModel

Source§

fn clone(&self) -> UniversalModel

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for UniversalModel

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for UniversalModel

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<__D: Fallible + ?Sized> Deserialize<UniversalModel, __D> for Archived<UniversalModel>
where UniversalConfig: Archive, <UniversalConfig as Archive>::Archived: Deserialize<UniversalConfig, __D>, Option<GBDTModel>: Archive, <Option<GBDTModel> as Archive>::Archived: Deserialize<Option<GBDTModel>, __D>, Option<Vec<GBDTModel>>: Archive, <Option<Vec<GBDTModel>> as Archive>::Archived: Deserialize<Option<Vec<GBDTModel>>, __D>, Option<Vec<f32>>: Archive, <Option<Vec<f32>> as Archive>::Archived: Deserialize<Option<Vec<f32>>, __D>, Option<f32>: Archive, <Option<f32> as Archive>::Archived: Deserialize<Option<f32>, __D>, Option<LinearBooster>: Archive, <Option<LinearBooster> as Archive>::Archived: Deserialize<Option<LinearBooster>, __D>, Vec<Tree>: Archive, <Vec<Tree> as Archive>::Archived: Deserialize<Vec<Tree>, __D>, f32: Archive, <f32 as Archive>::Archived: Deserialize<f32, __D>, usize: Archive, <usize as Archive>::Archived: Deserialize<usize, __D>, Skip: ArchiveWith<Option<DatasetAnalysis>> + DeserializeWith<<Skip as ArchiveWith<Option<DatasetAnalysis>>>::Archived, Option<DatasetAnalysis>, __D> + ArchiveWith<Option<Vec<f32>>> + DeserializeWith<<Skip as ArchiveWith<Option<Vec<f32>>>>::Archived, Option<Vec<f32>>, __D> + ArchiveWith<Option<Vec<usize>>> + DeserializeWith<<Skip as ArchiveWith<Option<Vec<usize>>>>::Archived, Option<Vec<usize>>, __D> + ArchiveWith<Option<usize>> + DeserializeWith<<Skip as ArchiveWith<Option<usize>>>::Archived, Option<usize>, __D> + ArchiveWith<Option<FeatureExtractor>> + DeserializeWith<<Skip as ArchiveWith<Option<FeatureExtractor>>>::Archived, Option<FeatureExtractor>, __D>,

Source§

fn deserialize( &self, deserializer: &mut __D, ) -> Result<UniversalModel, <__D as Fallible>::Error>

Deserializes using the given deserializer
Source§

impl<__S: Fallible + ?Sized> Serialize<__S> for UniversalModel

Source§

fn serialize( &self, serializer: &mut __S, ) -> Result<<Self as Archive>::Resolver, <__S as Fallible>::Error>

Writes the dependencies for the object and returns a resolver that can create the archived type.
Source§

impl Serialize for UniversalModel

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl TunableModel for UniversalModel

Source§

type Config = UniversalConfig

Configuration type for this model
Source§

fn train(dataset: &BinnedDataset, config: &Self::Config) -> Result<Self>

Train a model on the given dataset with the given configuration
Source§

fn predict(&self, dataset: &BinnedDataset) -> Vec<f32>

Predict on a dataset
Source§

fn num_trees(&self) -> usize

Get the number of trees/boosters in the trained model
Source§

fn apply_params(config: &mut Self::Config, params: &HashMap<String, ParamValue>)

Apply parameter values to a configuration Read more
Source§

fn valid_params() -> &'static [&'static str]

Get the list of valid parameter names for this model type
Source§

fn default_config() -> Self::Config

Create a default configuration
Source§

fn get_learning_rate(config: &Self::Config) -> f32

Get learning rate from configuration Read more
Source§

fn configure_validation( config: &mut Self::Config, validation_ratio: f32, early_stopping_rounds: usize, )

Configure validation settings for early stopping Read more
Source§

fn set_num_rounds(config: &mut Self::Config, num_rounds: usize)

Configure number of training rounds
Source§

fn train_with_validation( train_data: &BinnedDataset, val_data: &BinnedDataset, val_targets: &[f32], config: &Self::Config, ) -> Result<Self>

Train a model with explicit validation set for early stopping Read more
Source§

fn is_gpu_config(config: &Self::Config) -> bool

Check if the configuration uses GPU backend Read more
Source§

fn save_rkyv(&self, path: &Path) -> Result<()>

Save the model to a file in rkyv format Read more
Source§

fn save_bincode(&self, path: &Path) -> Result<()>

Save the model to a file in bincode format Read more
Source§

fn supports_conformal() -> bool

Check if this model type supports conformal prediction Read more
Source§

fn conformal_quantile(&self) -> Option<f32>

Get the conformal quantile from a trained model Read more
Source§

fn configure_conformal( config: &mut Self::Config, calibration_ratio: f32, quantile: f32, )

Configure conformal prediction settings in the model config Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
Source§

impl<T> ArchiveUnsized for T
where T: Archive,

Source§

type Archived = <T as Archive>::Archived

The archived counterpart of this type. Unlike Archive, it may be unsized. Read more
Source§

fn archived_metadata( &self, ) -> <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata

Creates the archived version of the metadata for this value.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Key for T
where T: Clone,

Source§

fn align() -> usize

The alignment necessary for the key. Must return a power of two.
Source§

fn size(&self) -> usize

The size of the key in bytes.
Source§

unsafe fn init(&self, ptr: *mut u8)

Initialize the key in the given memory location. Read more
Source§

unsafe fn get<'a>(ptr: *const u8) -> &'a T

Get a reference to the key from the given memory location. Read more
Source§

unsafe fn drop_in_place(ptr: *mut u8)

Drop the key in place. Read more
Source§

impl<T> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
Source§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

Source§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
Source§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The metadata type for pointers and references to this type.
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, S> SerializeUnsized<S> for T
where T: Serialize<S>, S: Fallible + Writer + ?Sized,

Source§

fn serialize_unsized( &self, serializer: &mut S, ) -> Result<usize, <S as Fallible>::Error>

Writes the object and returns the position of the archived type.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> PlanCallbackArgs for T

Source§

impl<T> PlanCallbackOut for T