Skip to main content

TypedTensorView

Struct TypedTensorView 

Source
pub struct TypedTensorView<'a, T, R: TensorRank = DynRank, D: Representation = Dynamic> { /* private fields */ }
Expand description

Read-only borrowed view of typed tensor storage with arbitrary strides.

TypedTensorView is the typed representation for layout-only tensor transformations. It borrows an existing host or backend allocation and carries a logical shape, strides, and an offset. Slicing, reshaping when stride-compatible, and transpose_view update only metadata and do not copy storage.

Materialize through TensorStructural::to_contiguous_read on the active backend session when a compact owned TypedTensor is required. Use TypedTensorView::as_slice only when the current view is contiguous in the requested layout.

§Examples

use tenferro_tensor::{Rank, TypedTensorView};

let data = [1_i32, 2, 3, 4];
let view = TypedTensorView::<_, Rank<2>>::from_slice_ranked([2, 2], [1, 2], 0, &data)?;
assert_eq!(view.get(&[1, 1]), Some(&4));

Borrowed typed view of one tensor representation.

The buffer stays concrete on purpose: a generic-associated buffer would make the projection invariant in 'a, and the borrowed-read surface relies on TensorRead<'long> shortening to TensorRead<'short>. D therefore marks which representation produced the view - Host is only ever built from host slices, with no retained region.

Implementations§

Source§

impl<'a, T: 'static, const N: usize, D: Representation> TypedTensorView<'a, T, Rank<N>, D>

Source

pub fn host_col_major_view(&self) -> Result<ColMajorView<'a, T, N>>

Validate and borrow this tensor view as a compact column-major host view.

Nonzero compact offsets are represented by the returned logical slice without copying.

§Examples
use tenferro_tensor::{Rank, TypedTensorView};
let data = [0_i32, 1, 2, 3, 4];
let view = TypedTensorView::<_, Rank<2>>::from_slice_ranked([2, 2], [1, 2], 1, &data)?;
assert_eq!(view.host_col_major_view()?.as_slice(), &[1, 2, 3, 4]);
§Errors

Returns crate::Error::RuntimeState when storage is backend-owned, or crate::Error::Validation when compact layout, shape arithmetic, or the logical host range is invalid.

Source§

impl<'a, T: 'static> TypedTensorView<'a, T, DynRank>

Source

pub fn from_col_major(shape: &[usize], data: &'a [T]) -> Result<Self>

Create a borrowed dynamic-rank view over compact column-major host data.

§Examples
use tenferro_tensor::TypedTensorView;

let data = [1_i32, 2, 3, 4];
let view = TypedTensorView::from_col_major(&[2, 2], &data)?;
assert_eq!(view.strides(), &[1, 2]);
§Errors

Returns crate::Error::Validation with tenferro_tensor_core::ValidationError::IntegerOverflow when compact strides or reachable bounds overflow, or tenferro_tensor_core::ValidationError::ViewOutOfBounds when the requested shape reaches beyond data.

Source

pub fn from_slice( shape: impl AsRef<[usize]>, strides: impl AsRef<[isize]>, offset: isize, data: &'a [T], ) -> Result<Self>

Create a borrowed host view from explicit layout metadata.

§Examples
use tenferro_tensor::TypedTensorView;

let data = [1_i32, 2, 3];
let view = TypedTensorView::from_slice(vec![3], vec![-1], 2, &data)?;
assert_eq!(view.get(&[2]), Some(&1));
§Errors

Returns crate::Error::Validation with tenferro_tensor_core::ValidationError::RankMismatch when shape and strides have different ranks, tenferro_tensor_core::ValidationError::ViewOutOfBounds when the reachable layout exceeds data, or tenferro_tensor_core::ValidationError::IntegerOverflow when layout arithmetic overflows.

Source§

impl<'a, T: 'static, R: TensorRank, D: Representation> TypedTensorView<'a, T, R, D>

Source

pub fn from_slice_ranked( shape: impl Into<R::Shape>, strides: impl Into<R::Strides>, offset: isize, data: &'a [T], ) -> Result<Self>

Create a rank-generic borrowed host view from explicit layout metadata.

§Examples
use tenferro_tensor::{Rank, TypedTensorView};

let data = [1_i32, 2, 3, 4];
let view = TypedTensorView::<_, Rank<2>>::from_slice_ranked([2, 2], [1, 2], 0, &data)?;
assert_eq!(view.get(&[1, 1]), Some(&4));
§Errors

Returns crate::Error::Validation with tenferro_tensor_core::ValidationError::RankMismatch when the typed rank does not match shape or strides, tenferro_tensor_core::ValidationError::ViewOutOfBounds when the reachable layout exceeds data, or tenferro_tensor_core::ValidationError::IntegerOverflow when layout arithmetic overflows.

Source§

impl<'a, T: 'static, R: TensorRank> TypedTensorView<'a, T, R, Host>

Source

pub fn from_host_slice( shape: impl Into<R::Shape>, strides: impl Into<R::Strides>, offset: isize, data: &'a [T], ) -> Result<Self>

Create a representation-marked view over an explicit host layout.

A Host-marked view is only ever built from a host slice, so it carries no retained region and its host slice needs no runtime check.

§Examples
use tenferro_tensor::{DynRank, Host, TypedTensorView};

let data = [1_i32, 2, 3, 4];
let view: TypedTensorView<'_, i32, DynRank, Host> =
    TypedTensorView::from_host_slice(vec![2, 2], vec![1, 2], 0, &data)?;
assert_eq!(view.as_host_slice(), &[1, 2, 3, 4]);
§Errors

Returns crate::Error::Validation with tenferro_tensor_core::ValidationError::RankMismatch when strides has a different rank, or tenferro_tensor_core::ValidationError::ViewOutOfBounds / tenferro_tensor_core::ValidationError::IntegerOverflow when the reachable layout leaves data or overflows.

Source

pub fn as_host_slice(&self) -> &'a [T]

Borrow the host elements without a runtime representation check.

§Examples
use tenferro_tensor::{DynRank, Host, TypedTensorView};

let data = [1_i32, 2];
let view: TypedTensorView<'_, i32, DynRank, Host> =
    TypedTensorView::from_host_slice(vec![2], vec![1], 0, &data)?;
assert_eq!(view.as_host_slice(), &[1, 2]);
§Panics

Panics only if a Host-marked view was built from non-host storage, which no constructor in this crate does.

Source§

impl<'a, T: 'static, R: TensorRank, D: Representation> TypedTensorView<'a, T, R, D>

Source

pub fn into_tensor_read(self) -> Result<TensorRead<'a>>
where T: TensorScalar,

Erase a borrowed view’s rank and dtype for session dispatch without allocating tensor storage or promoting it into an allocation group. Common ranks use the existing inline shape and stride metadata.

§Examples
use tenferro_tensor::{Rank, TypedTensorView};
let data = [1.0_f64, 2.0];
let view = TypedTensorView::<_, Rank<1>>::from_slice_ranked([2], [1], 0, &data)?;
let read = view.into_tensor_read()?;
assert_eq!(read.as_slice::<f64>()?, &[1.0, 2.0]);
§Errors

Returns crate::Error::Validation with ValidationError::IntegerOverflow for unrepresentable metadata or ValidationError::ViewOutOfBounds if the layout leaves its allocation.

Source

pub fn shape(&self) -> &[usize]

Return the logical shape.

§Examples
use tenferro_tensor::TypedTensorView;

let data = [0_i32; 2];
let view = TypedTensorView::from_slice(vec![2], vec![1], 0, &data)?;
assert_eq!(view.shape(), &[2]);
Source

pub fn rank(&self) -> usize

Return the logical rank carried by this view.

§Examples
use tenferro_tensor::TypedTensorView;

let data = [0_i32; 6];
let view = TypedTensorView::from_slice(vec![2, 3], vec![1, 2], 0, &data)?;
assert_eq!(view.rank(), 2);
Source

pub fn strides(&self) -> &[isize]

Return strides in element units.

§Examples
use tenferro_tensor::TypedTensorView;

let data = [0_i32; 2];
let view = TypedTensorView::from_slice(vec![2], vec![-1], 1, &data)?;
assert_eq!(view.strides(), &[-1]);
Source

pub fn offset(&self) -> isize

Return the physical element offset.

§Examples
use tenferro_tensor::TypedTensorView;

let data = [1_i32, 2];
let view = TypedTensorView::from_slice(vec![1], vec![1], 1, &data)?;
assert_eq!(view.offset(), 1);
Source

pub fn host_storage(&self) -> Result<&'a [T]>

Return the borrowed host storage backing this view.

This exposes the entire backing host allocation, not just the logical slice covered by this view. Use TypedTensorView::as_slice when the caller needs the contiguous logical region instead.

§Examples
use tenferro_tensor::TypedTensorView;

let data = [1_i32, 2];
let view = TypedTensorView::from_slice(vec![2], vec![1], 0, &data)?;
assert_eq!(view.host_storage()?, &[1, 2]);
§Errors

Returns crate::Error::RuntimeState when this view wraps a backend buffer; backend storage must be downloaded before host inspection.

Source

pub fn n_elements(&self) -> usize

Return the number of logical elements in this view.

§Examples
use tenferro_tensor::TypedTensorView;

let data = [0_i32; 6];
let view = TypedTensorView::from_slice(vec![2, 3], vec![1, 2], 0, &data)?;
assert_eq!(view.n_elements(), 6);
Source

pub fn layout(&self) -> &TensorLayout<R>

Return layout metadata for this view.

§Examples
use tenferro_tensor::TypedTensorView;

let data = [1_i32, 2];
let view = TypedTensorView::from_slice(vec![2], vec![1], 0, &data)?;
assert!(view.layout().is_compact_col_major().unwrap());
Source

pub fn placement(&self) -> &Placement

Return placement metadata for this view.

§Examples
use tenferro_tensor::{MemoryKind, TypedTensorView};

let data = [1_i32];
let view = TypedTensorView::from_slice(vec![1], vec![1], 0, &data)?;
assert_eq!(view.placement().memory_kind, MemoryKind::UnpinnedHost);
Source

pub fn linear_offset(&self, indices: &[usize]) -> Option<usize>

Compute the physical element offset for a logical index.

§Examples
use tenferro_tensor::TypedTensorView;

let data = [1_i32, 2, 3];
let view = TypedTensorView::from_slice(vec![3], vec![-1], 2, &data)?;
assert_eq!(view.linear_offset(&[2]), Some(0));
Source

pub fn layout_linear_offset(&self, indices: &[usize]) -> Result<usize>

Compute the physical element offset for a logical index, returning a typed error.

§Examples
use tenferro_tensor::TypedTensorView;

let data = [1_i32, 2, 3];
let view = TypedTensorView::from_slice([3], [-1], 2, &data)?;
assert_eq!(view.layout_linear_offset(&[2])?, 0);
§Errors

Returns crate::Error::Validation with tenferro_tensor_core::ValidationError::RankMismatch when indices has the wrong rank, tenferro_tensor_core::ValidationError::InvalidArgument when an index is outside its axis extent, or tenferro_tensor_core::ValidationError::IntegerOverflow when offset arithmetic overflows.

Source

pub fn is_col_major_contiguous(&self) -> Result<bool>

Return whether this view is compact column-major.

§Examples
use tenferro_tensor::TypedTensorView;

let data = [1_i32, 2];
let view = TypedTensorView::from_slice([2], [1], 0, &data)?;
assert!(view.is_col_major_contiguous()?);
§Errors

Returns crate::Error::Validation with tenferro_tensor_core::ValidationError::IntegerOverflow if compactness arithmetic overflows.

Source

pub fn layout_summary(&self) -> String

Return a compact string summary of this view’s layout metadata.

§Examples
use tenferro_tensor::TypedTensorView;

let data = [1_i32, 2];
let view = TypedTensorView::from_slice([2], [1], 0, &data)?;
assert!(view.layout_summary().contains("shape=[2]"));
Source

pub fn assert_col_major_contiguous(&self) -> Result<()>

Assert this view is compact column-major.

§Examples
use tenferro_tensor::TypedTensorView;

let data = [1_i32, 2];
let view = TypedTensorView::from_slice([2], [1], 0, &data)?;
view.assert_col_major_contiguous()?;
§Errors

Returns crate::Error::Validation with tenferro_tensor_core::ValidationError::IntegerOverflow when compactness arithmetic overflows, or tenferro_tensor_core::ValidationError::InvalidArgument when the view is not compact column-major.

Source

pub fn get(&self, indices: &[usize]) -> Option<&T>

Borrow one host element by logical index.

Returns None for out-of-bounds indices and backend buffers.

§Examples
use tenferro_tensor::TypedTensorView;

let data = [1_i32, 2];
let view = TypedTensorView::from_slice(vec![2], vec![1], 0, &data)?;
assert_eq!(view.get(&[1]), Some(&2));
Source

pub fn as_slice(&self) -> Result<&'a [T]>

Borrow the contiguous host slice covered by this view.

Returns an explicit error for backend buffers and for non-contiguous layouts. This method never downloads or materializes backend data.

§Examples
use tenferro_tensor::TypedTensorView;

let data = [1_i32, 2, 3];
let view = TypedTensorView::from_slice(vec![2], vec![1], 1, &data)?;
assert_eq!(view.as_slice()?, &[2, 3]);
§Errors

Returns crate::Error::RuntimeState when this view wraps a backend buffer, tenferro_tensor_core::ValidationError::NonContiguousViewAsSlice when the layout is not compact column-major, tenferro_tensor_core::ValidationError::InvalidArgument when the view offset is negative, or crate::Error::Validation with tenferro_tensor_core::ValidationError::ViewOutOfBounds or tenferro_tensor_core::ValidationError::IntegerOverflow when the requested host range is invalid.

Source

pub fn duplicate(&self) -> Result<TypedTensor<T, R>>
where T: Clone,

Explicitly duplicate a compact host view into a new owner.

Backend views require an explicit provider canonicalization or download boundary; this method never transfers or materializes them implicitly.

§Examples
use tenferro_tensor::TypedTensorView;

let data = [1_i32, 2];
let view = TypedTensorView::from_slice(vec![2], vec![1], 0, &data)?;
let copy = view.duplicate()?;
assert_eq!(copy.as_slice()?, &[1, 2]);
§Errors

Returns crate::Error::HostAccess or ValidationError::NonContiguousViewAsSlice when the view is backend owned or not contiguous, and ValidationError::InvalidArgument when the static-rank shape cannot be reconstructed.

Source

pub fn to_col_major(&self) -> Result<TypedTensor<T, R>>
where T: Clone,

Explicitly copy a host view, including strided/offset views, to a compact owner.

§Examples
use tenferro_tensor::{Rank, TypedTensorView};
let storage = [1, 4, 2, 5, 3, 6];
let view = TypedTensorView::<_, Rank<2>>::from_slice_ranked(
    [2, 3], [1, 2], 0, &storage,
)?;
let transposed = view.transpose_view([1, 0])?;
assert_eq!(transposed.to_col_major()?.as_slice()?, &[1, 2, 3, 4, 5, 6]);
§Errors

Backend-only storage returns crate::Error::RuntimeState; invalid layout or rank conversion returns crate::Error::Validation.

Source

pub fn transpose_view(&self, axes: impl AsRef<[usize]>) -> Result<Self>

Return a metadata-only axis permutation.

§Examples
use tenferro_tensor::{Rank, TypedTensorView};

let data = [1_i32, 2, 3, 4, 5, 6];
let view = TypedTensorView::<_, Rank<2>>::from_slice_ranked([2, 3], [1, 2], 0, &data)?;
let transposed = view.transpose_view([1, 0])?;
assert_eq!(transposed.shape(), &[3, 2]);
§Errors

Returns crate::Error::Validation with tenferro_tensor_core::ValidationError::InvalidPermutationLength, tenferro_tensor_core::ValidationError::AxisOutOfBounds, or tenferro_tensor_core::ValidationError::DuplicateAxis when axes is not a valid permutation of the view rank.

Source

pub fn slice_view(&self, slices: &[StridedSliceSpec]) -> Result<Self>

Return a metadata-only slice using one StridedSliceSpec per axis.

§Examples
use tenferro_tensor::{StridedSliceSpec, TypedTensorView};

let data = [1_i32, 2, 3];
let view = TypedTensorView::from_slice(vec![3], vec![1], 0, &data)?;
let reversed = view.slice_view(&[StridedSliceSpec::reverse()])?;
assert_eq!(reversed.get(&[0]), Some(&3));
§Errors

Returns crate::Error::Validation with tenferro_tensor_core::ValidationError::RankMismatch when the slice count differs from the view rank, tenferro_tensor_core::ValidationError::InvalidSliceStep or tenferro_tensor_core::ValidationError::InvalidSliceBounds for an invalid slice, tenferro_tensor_core::ValidationError::IntegerOverflow for slice arithmetic overflow, or tenferro_tensor_core::ValidationError::ViewOutOfBounds when the resulting layout exceeds the backing buffer.

Source

pub fn slice_axis_view( &self, axis: usize, slice: StridedSliceSpec, ) -> Result<Self>

Return a metadata-only slice along one axis.

§Examples
use tenferro_tensor::{StridedSliceSpec, TypedTensorView};

let data = [1_i32, 2, 3, 4];
let view = TypedTensorView::from_slice(vec![2, 2], vec![1, 2], 0, &data)?;
assert_eq!(view.slice_axis_view(1, StridedSliceSpec::reverse())?.get(&[0, 0]), Some(&3));
§Errors

Returns crate::Error::Validation with tenferro_tensor_core::ValidationError::AxisOutOfBounds when axis is outside the view rank, tenferro_tensor_core::ValidationError::InvalidSliceStep or tenferro_tensor_core::ValidationError::InvalidSliceBounds for an invalid slice, tenferro_tensor_core::ValidationError::IntegerOverflow for slice arithmetic overflow, or tenferro_tensor_core::ValidationError::ViewOutOfBounds when the resulting layout exceeds the backing buffer.

Source

pub fn reshape_view( &self, shape: &[usize], ) -> Result<TypedTensorView<'a, T, DynRank, D>>

Return a metadata-only dynamic-rank reshape for contiguous column-major views.

§Examples
use tenferro_tensor::TypedTensorView;

let data = [1_i32, 2, 3, 4];
let view = TypedTensorView::from_slice(vec![2, 2], vec![1, 2], 0, &data)?;
assert_eq!(view.reshape_view(&[4])?.shape(), &[4]);
§Errors

Returns crate::Error::Validation with tenferro_tensor_core::ValidationError::NonContiguousViewAsSlice when the source is not compact column-major, tenferro_tensor_core::ValidationError::ShapeMismatch (whose tenferro_tensor_core::ShapeMismatch::ReshapeElementCount source records the counts) when element counts differ, tenferro_tensor_core::ValidationError::IntegerOverflow for shape arithmetic overflow, or tenferro_tensor_core::ValidationError::ViewOutOfBounds when the reshaped view exceeds the backing buffer.

Source§

impl<'a, R: TensorRank> TypedTensorView<'a, Complex32, R>

Source

pub fn as_real_view(&self) -> Result<TypedTensorView<'a, f32, DynRank>>

Borrow this complex view as an interleaved real view without copying.

The result has dynamic rank because reinterpretation prepends the component axis [2, ...]. Only Complex32 <-> f32 is sealed in this API; this is representation reinterpretation, not numeric conversion.

§Examples
use tenferro_tensor::{Complex32, TypedTensorView};

let data = [Complex32::new(1.0, 2.0)];
let view = TypedTensorView::from_col_major(&[1], &data)?;
let real = view.as_real_view()?;
assert_eq!(real.shape(), &[2, 1]);
assert_eq!(real.as_slice()?, &[1.0_f32, 2.0]);
§Errors

Returns an error when the view layout is not a valid sealed representation or when backend reinterpretation is unsupported.

Source§

impl<'a, R: TensorRank> TypedTensorView<'a, Complex64, R>

Source

pub fn as_real_view(&self) -> Result<TypedTensorView<'a, f64, DynRank>>

Borrow this complex view as an interleaved real view without copying.

The result has dynamic rank because reinterpretation prepends the component axis [2, ...]. Only Complex64 <-> f64 is sealed in this API; this is representation reinterpretation, not numeric conversion.

§Examples
use tenferro_tensor::{Complex64, TypedTensorView};

let data = [Complex64::new(1.0, 2.0)];
let view = TypedTensorView::from_col_major(&[1], &data)?;
let real = view.as_real_view()?;
assert_eq!(real.shape(), &[2, 1]);
assert_eq!(real.as_slice()?, &[1.0_f64, 2.0]);
§Errors

Returns an error when the view layout is not a valid sealed representation or when backend reinterpretation is unsupported.

Source§

impl<'a, R: TensorRank> TypedTensorView<'a, f32, R>

Source

pub fn as_complex_view(&self) -> Result<TypedTensorView<'a, Complex32, DynRank>>

Borrow this interleaved real view as a complex view without copying.

The source must have a leading extent and stride of 2 and 1, and every remaining stride plus the offset must be divisible by 2.

§Examples
use tenferro_tensor::{Complex32, TypedTensorView};

let data = [1.0_f32, 2.0];
let view = TypedTensorView::from_col_major(&[2, 1], &data)?;
let complex = view.as_complex_view()?;
assert_eq!(complex.shape(), &[1]);
assert_eq!(complex.as_slice()?, &[Complex32::new(1.0, 2.0)]);
§Errors

Returns an error when the view layout is not a valid sealed representation or when backend reinterpretation is unsupported.

Source§

impl<'a, R: TensorRank> TypedTensorView<'a, f64, R>

Source

pub fn as_complex_view(&self) -> Result<TypedTensorView<'a, Complex64, DynRank>>

Borrow this interleaved real view as a complex view without copying.

The source must have a leading extent and stride of 2 and 1, and every remaining stride plus the offset must be divisible by 2.

§Examples
use tenferro_tensor::{Complex64, TypedTensorView};

let data = [1.0_f64, 2.0];
let view = TypedTensorView::from_col_major(&[2, 1], &data)?;
let complex = view.as_complex_view()?;
assert_eq!(complex.shape(), &[1]);
assert_eq!(complex.as_slice()?, &[Complex64::new(1.0, 2.0)]);
§Errors

Returns an error when the view layout is not a valid sealed representation or when backend reinterpretation is unsupported.

Trait Implementations§

Source§

impl<'a, T, R: TensorRank, D: Representation> Clone for TypedTensorView<'a, T, R, D>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<'a, T, R: TensorRank, D: Representation> Debug for TypedTensorView<'a, T, R, D>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, T, R = DynRank, D = Dynamic> !RefUnwindSafe for TypedTensorView<'a, T, R, D>

§

impl<'a, T, R = DynRank, D = Dynamic> !UnwindSafe for TypedTensorView<'a, T, R, D>

§

impl<'a, T, R, D> Freeze for TypedTensorView<'a, T, R, D>
where <R as TensorRank>::Shape: Freeze, <R as TensorRank>::Strides: Freeze,

§

impl<'a, T, R, D> Send for TypedTensorView<'a, T, R, D>
where <R as TensorRank>::Shape: Send, <R as TensorRank>::Strides: Send, D: Send, T: Send + Sync,

§

impl<'a, T, R, D> Sync for TypedTensorView<'a, T, R, D>
where <R as TensorRank>::Shape: Sync, <R as TensorRank>::Strides: Sync, D: Sync, T: Sync,

§

impl<'a, T, R, D> Unpin for TypedTensorView<'a, T, R, D>
where <R as TensorRank>::Shape: Unpin, <R as TensorRank>::Strides: Unpin, D: Unpin, T: Unpin, R: Unpin,

§

impl<'a, T, R, D> UnsafeUnpin for TypedTensorView<'a, T, R, D>

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> 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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.