pub struct DiscreteRangeMap<I, K, V> { /* private fields */ }
Expand description

An ordered map of non-overlapping ranges based on BTreeMap.

I is the generic type parameter for the Ord type the K type is a range over.

K is the generic type parameter for the range type stored as the keys in the map.

V is the generic type parameter for the values associated with the keys in the map.

Phrasing it another way: I is the point type, K is the range type, and V is the value type.

Examples

use discrete_range_map::test_ranges::ie;
use discrete_range_map::DiscreteRangeMap;

// Make a map of ranges to booleans
let mut map = DiscreteRangeMap::from_slice_strict([
	(ie(4, 8), false),
	(ie(8, 18), true),
	(ie(20, 100), false),
])
.unwrap();

// Change a value in the map
*map.get_at_point_mut(7).unwrap() = true;

if map.contains_point(99) {
	println!("Map contains value at 99 :)");
}

// Iterate over the entries in the map
for (range, value) in map.iter() {
	println!("{range:?}, {value:?}");
}

Implementations§

source§

impl<I, K, V> DiscreteRangeMap<I, K, V>
where I: PointType, K: RangeType<I>,

source

pub fn overlaps<Q>(&self, range: Q) -> bool
where Q: RangeType<I>,

Returns true if the given range overlaps any of the other ranges in the map, and false if not.

Panics

Panics if the given range is an invalid range. See Invalid Ranges for more details.

Examples
use discrete_range_map::test_ranges::{ie, ii};
use discrete_range_map::DiscreteRangeMap;

let mut map = DiscreteRangeMap::new();

map.insert_strict(ie(5, 10), false);

assert_eq!(map.overlaps(ii(1, 3)), false);
assert_eq!(map.overlaps(ie(4, 5)), false);

assert_eq!(map.overlaps(ii(4, 5)), true);
assert_eq!(map.overlaps(ie(4, 6)), true);
source

pub fn overlapping<Q>( &self, range: Q ) -> impl DoubleEndedIterator<Item = (&K, &V)>
where Q: RangeType<I>,

Returns an iterator over every entry in the map that overlaps the given range in ascending order.

Panics

Panics if the given range is an invalid range. See Invalid Ranges for more details.

Examples
use discrete_range_map::test_ranges::ie;
use discrete_range_map::DiscreteRangeMap;

let map = DiscreteRangeMap::from_slice_strict([
	(ie(1, 4), false),
	(ie(4, 8), true),
	(ie(8, 100), false),
])
.unwrap();

let mut overlapping = map.overlapping(ie(2, 8));

assert_eq!(
	overlapping.collect::<Vec<_>>(),
	[(&ie(1, 4), &false), (&ie(4, 8), &true)]
);
source

pub fn overlapping_mut<Q>( &mut self, range: Q ) -> impl DoubleEndedIterator<Item = (&K, &mut V)>
where Q: RangeType<I>,

Returns an mutable iterator over every entry in the map that overlaps the given range in ascending order.

Panics

Panics if the given range is an invalid range. See Invalid Ranges for more details.

Examples
use discrete_range_map::test_ranges::ie;
use discrete_range_map::DiscreteRangeMap;

let mut map = DiscreteRangeMap::from_slice_strict([
	(ie(1, 4), false),
	(ie(4, 8), true),
	(ie(8, 100), false),
])
.unwrap();

for (range, value) in map.overlapping_mut(ie(3, 7)) {
	if *range == ie(4, 8) {
		*value = false
	} else {
		*value = true
	}
}
source

pub fn get_at_point(&self, point: I) -> Option<&V>

Returns a reference to the value corresponding to the range in the map that overlaps the given point, if any.

Examples
use discrete_range_map::test_ranges::ie;
use discrete_range_map::DiscreteRangeMap;

let map = DiscreteRangeMap::from_slice_strict([
	(ie(1, 4), false),
	(ie(4, 8), true),
	(ie(8, 100), false),
])
.unwrap();

assert_eq!(map.get_at_point(3), Some(&false));
assert_eq!(map.get_at_point(4), Some(&true));
assert_eq!(map.get_at_point(101), None);
source

pub fn get_at_point_mut(&mut self, point: I) -> Option<&mut V>

Returns a mutable reference to the value corresponding to the range that overlaps the given point, if any.

Examples
use discrete_range_map::test_ranges::ie;
use discrete_range_map::DiscreteRangeMap;
let mut map =
	DiscreteRangeMap::from_slice_strict([(ie(1, 4), false)])
		.unwrap();

if let Some(x) = map.get_at_point_mut(2) {
	*x = true;
}

assert_eq!(map.get_at_point(1), Some(&true));
source

pub fn contains_point(&self, point: I) -> bool

Returns true if the map contains a range that overlaps the given point, and false if not.

Examples
use discrete_range_map::test_ranges::ie;
use discrete_range_map::DiscreteRangeMap;

let map = DiscreteRangeMap::from_slice_strict([
	(ie(1, 4), false),
	(ie(4, 8), true),
	(ie(8, 100), false),
])
.unwrap();

assert_eq!(map.contains_point(3), true);
assert_eq!(map.contains_point(4), true);
assert_eq!(map.contains_point(101), false);
source

pub fn get_entry_at_point(&self, point: I) -> Result<(&K, &V), K>

Returns the entry corresponding to the range that overlaps the given point, if any.

If there is no range that overlaps the given point the maximally-sized gap at the given point is returned.

Examples
use discrete_range_map::test_ranges::{ie, iu};
use discrete_range_map::DiscreteRangeMap;

let map = DiscreteRangeMap::from_slice_strict([
	(ie(1, 4), false),
	(ie(4, 6), true),
	(ie(8, 100), false),
])
.unwrap();

assert_eq!(map.get_entry_at_point(3), Ok((&ie(1, 4), &false)));
assert_eq!(map.get_entry_at_point(5), Ok((&ie(4, 6), &true)));
assert_eq!(map.get_entry_at_point(7), Err(ie(6, 8)));
assert_eq!(map.get_entry_at_point(101), Err(iu(100)));
source

pub fn remove_overlapping<'a, Q>( &'a mut self, range: Q ) -> impl Iterator<Item = (K, V)> + '_
where Q: RangeType<I> + 'a,

Removes every entry in the map which overlaps the given range and returns them in an iterator.

Panics

Panics if the given range is an invalid range. See Invalid Ranges for more details.

Examples
use discrete_range_map::test_ranges::ie;
use discrete_range_map::DiscreteRangeMap;

let mut map = DiscreteRangeMap::from_slice_strict([
	(ie(1, 4), false),
	(ie(4, 8), true),
	(ie(8, 100), false),
])
.unwrap();

let mut removed = map.remove_overlapping(ie(2, 8));

assert_eq!(
	removed.collect::<Vec<_>>(),
	[(ie(1, 4), false), (ie(4, 8), true)]
);

assert_eq!(
	map.into_iter().collect::<Vec<_>>(),
	[(ie(8, 100), false)]
);
source

pub fn cut<'a, Q>(&'a mut self, range: Q) -> impl Iterator<Item = (K, V)> + '_
where Q: RangeType<I> + 'a, V: Clone,

Cuts a given range out of the map and returns an iterator of the full or partial ranges that were cut.

V must implement Clone as if you try to cut out the center of a range in the map it will split into two different entries using Clone. Or if you partially cut a range then V must be cloned to be returned in the iterator.

Panics

Panics if the given range is an invalid range. See Invalid Ranges for more details.

Examples
use discrete_range_map::test_ranges::{ie, ii};
use discrete_range_map::DiscreteRangeMap;

let mut base = DiscreteRangeMap::from_slice_strict([
	(ie(1, 4), false),
	(ie(4, 8), true),
	(ie(8, 100), false),
])
.unwrap();

let after_cut = DiscreteRangeMap::from_slice_strict([
	(ie(1, 2), false),
	(ie(40, 100), false),
])
.unwrap();

assert_eq!(
	base.cut(ie(2, 40)).collect::<Vec<_>>(),
	[(ie(2, 4), false), (ie(4, 8), true), (ie(8, 40), false),]
);
assert_eq!(base, after_cut);
source

pub fn gaps<'a, Q>(&'a self, outer_range: Q) -> impl Iterator<Item = K> + '_
where Q: RangeType<I> + 'a,

Returns an iterator of ranges over all the maximally-sized gaps in the map that are also within the given outer_range.

Panics

Panics if the given range is an invalid range. See Invalid Ranges for more details.

Examples
use discrete_range_map::test_ranges::{ie, iu};
use discrete_range_map::DiscreteRangeMap;

let map = DiscreteRangeMap::from_slice_strict([
	(ie(1, 3), false),
	(ie(5, 7), true),
	(ie(9, 100), false),
])
.unwrap();

let mut gaps = map.gaps(iu(2));

assert_eq!(
	gaps.collect::<Vec<_>>(),
	[ie(3, 5), ie(7, 9), iu(100)]
);
source

pub fn contains_range<Q>(&self, range: Q) -> bool
where Q: RangeType<I>,

Returns true if the map covers every point in the given range, and false if it does not.

Panics

Panics if the given range is an invalid range. See Invalid Ranges for more details.

Examples
use discrete_range_map::test_ranges::ie;
use discrete_range_map::DiscreteRangeMap;

let map = DiscreteRangeMap::from_slice_strict([
	(ie(1, 3), false),
	(ie(5, 8), true),
	(ie(8, 100), false),
])
.unwrap();

assert_eq!(map.contains_range(ie(1, 3)), true);
assert_eq!(map.contains_range(ie(2, 6)), false);
assert_eq!(map.contains_range(ie(6, 100)), true);
source

pub fn insert_strict( &mut self, range: K, value: V ) -> Result<(), OverlapError<V>>

Adds a new entry to the map without modifying other entries.

If the given range overlaps one or more ranges already in the map, then an OverlapError is returned and the map is not updated.

Panics

Panics if the given range is an invalid range. See Invalid Ranges for more details.

Examples
use discrete_range_map::test_ranges::ie;
use discrete_range_map::{DiscreteRangeMap, OverlapError};

let mut map = DiscreteRangeMap::new();

assert_eq!(map.insert_strict(ie(5, 10), 9), Ok(()));
assert_eq!(
	map.insert_strict(ie(5, 10), 2),
	Err(OverlapError { value: 2 })
);
assert_eq!(map.len(), 1);
source

pub fn insert_merge_touching( &mut self, range: K, value: V ) -> Result<K, OverlapError<V>>

Adds a new entry to the map and merges into other ranges in the map which touch it.

The value of the merged-together range is set to the value given for this insertion.

If successful then the newly inserted (possibly merged) range is returned.

If the given range overlaps one or more ranges already in the map, then an OverlapError is returned and the map is not updated.

Panics

Panics if the given range is an invalid range. See Invalid Ranges for more details.

Examples
use discrete_range_map::test_ranges::ie;
use discrete_range_map::{DiscreteRangeMap, OverlapError};

let mut map = DiscreteRangeMap::from_slice_strict([
	(ie(1, 4), false),
	(ie(6, 8), true),
])
.unwrap();

// Touching
assert_eq!(
	map.insert_merge_touching(ie(4, 6), true),
	Ok(ie(1, 8))
);

// Overlapping
assert_eq!(
	map.insert_merge_touching(ie(4, 8), false),
	Err(OverlapError { value: false }),
);

// Neither Touching or Overlapping
assert_eq!(
	map.insert_merge_touching(ie(10, 16), false),
	Ok(ie(10, 16))
);

assert_eq!(
	map.into_iter().collect::<Vec<_>>(),
	[(ie(1, 8), true), (ie(10, 16), false)]
);
source

pub fn insert_merge_touching_if_values_equal( &mut self, range: K, value: V ) -> Result<K, OverlapError<V>>
where V: Eq,

Adds a new entry to the map and merges into other ranges in the map which touch it if the touching ranges’ values are equal to the value being inserted.

If successful then the newly inserted (possibly merged) range is returned.

If the given range overlaps one or more ranges already in the map, then an OverlapError is returned and the map is not updated.

Panics

Panics if the given range is an invalid range. See Invalid Ranges for more details.

Examples
use discrete_range_map::test_ranges::ie;
use discrete_range_map::{DiscreteRangeMap, OverlapError};

let mut map = DiscreteRangeMap::from_slice_strict([
	(ie(1, 4), false),
	(ie(6, 8), true),
])
.unwrap();

// Touching
assert_eq!(
	map.insert_merge_touching_if_values_equal(ie(4, 6), true),
	Ok(ie(4, 8))
);

// Overlapping
assert_eq!(
	map.insert_merge_touching_if_values_equal(ie(4, 8), false),
	Err(OverlapError { value: false }),
);

// Neither Touching or Overlapping
assert_eq!(
	map.insert_merge_touching_if_values_equal(ie(10, 16), false),
	Ok(ie(10, 16))
);

assert_eq!(
	map.into_iter().collect::<Vec<_>>(),
	[(ie(1, 4), false), (ie(4, 8), true), (ie(10, 16), false)]
);
source

pub fn insert_merge_overlapping(&mut self, range: K, value: V) -> K

Adds a new entry to the map and merges into other ranges in the map which overlap it.

The value of the merged-together range is set to the value given for this insertion.

The newly inserted (possibly merged) range is returned.

Panics

Panics if the given range is an invalid range. See Invalid Ranges for more details.

Examples
use discrete_range_map::test_ranges::ie;
use discrete_range_map::{DiscreteRangeMap, OverlapError};

let mut map = DiscreteRangeMap::from_slice_strict([
	(ie(1, 4), false),
	(ie(6, 8), true),
])
.unwrap();

// Touching
assert_eq!(
	map.insert_merge_overlapping(ie(4, 6), true),
	ie(4, 6)
);

// Overlapping
assert_eq!(
	map.insert_merge_overlapping(ie(4, 8), false),
	ie(4, 8)
);

// Neither Touching or Overlapping
assert_eq!(
	map.insert_merge_overlapping(ie(10, 16), false),
	ie(10, 16)
);

assert_eq!(
	map.into_iter().collect::<Vec<_>>(),
	[(ie(1, 4), false), (ie(4, 8), false), (ie(10, 16), false)]
);
source

pub fn insert_merge_touching_or_overlapping(&mut self, range: K, value: V) -> K

Adds a new entry to the map and merges into other ranges in the map which touch or overlap it.

The value of the merged-together range is set to the value given for this insertion.

The newly inserted (possibly merged) range is returned.

Panics

Panics if the given range is an invalid range. See Invalid Ranges for more details.

Examples
use discrete_range_map::test_ranges::ie;
use discrete_range_map::{DiscreteRangeMap, OverlapError};

let mut map = DiscreteRangeMap::from_slice_strict([
	(ie(1, 4), false),
	(ie(6, 8), true),
])
.unwrap();

// Touching
assert_eq!(
	map.insert_merge_touching_or_overlapping(ie(4, 6), true),
	ie(1, 8)
);

// Overlapping
assert_eq!(
	map.insert_merge_touching_or_overlapping(ie(4, 8), false),
	ie(1, 8)
);

// Neither Touching or Overlapping
assert_eq!(
	map.insert_merge_touching_or_overlapping(ie(10, 16), false),
	ie(10, 16)
);

assert_eq!(
	map.into_iter().collect::<Vec<_>>(),
	[(ie(1, 8), false), (ie(10, 16), false)]
);
source

pub fn insert_overwrite(&mut self, range: K, value: V)
where V: Clone,

Adds a new entry to the map and overwrites any other ranges that overlap the new range.

This is equivalent to using DiscreteRangeMap::cut() followed by DiscreteRangeMap::insert_strict(). Hence the same V: Clone trait bound applies.

Panics

Panics if the given range is an invalid range. See Invalid Ranges for more details.

Examples
use discrete_range_map::test_ranges::ie;
use discrete_range_map::DiscreteRangeMap;

let mut map =
	DiscreteRangeMap::from_slice_strict([(ie(2, 8), false)])
		.unwrap();

map.insert_overwrite(ie(4, 6), true);

assert_eq!(
	map.into_iter().collect::<Vec<_>>(),
	[(ie(2, 4), false), (ie(4, 6), true), (ie(6, 8), false)]
);
source

pub fn from_slice_strict<const N: usize>( slice: [(K, V); N] ) -> Result<DiscreteRangeMap<I, K, V>, OverlapError<V>>

Allocates a DiscreteRangeMap and moves the given entries from the given slice into the map using DiscreteRangeMap::insert_strict().

May return an Err while inserting. See DiscreteRangeMap::insert_strict() for details.

Panics

Panics if the given range is an invalid range. See Invalid Ranges for more details.

Examples
use discrete_range_map::test_ranges::ie;
use discrete_range_map::DiscreteRangeMap;

let map = DiscreteRangeMap::from_slice_strict([
	(ie(1, 4), false),
	(ie(4, 8), true),
	(ie(8, 100), false),
])
.unwrap();
source

pub fn from_iter_strict( iter: impl Iterator<Item = (K, V)> ) -> Result<DiscreteRangeMap<I, K, V>, OverlapError<V>>

Collects a DiscreteRangeMap from an iterator of (range, value) tuples using DiscreteRangeMap::insert_strict().

May return an Err while inserting. See DiscreteRangeMap::insert_strict() for details.

Panics

Panics if the given range is an invalid range. See Invalid Ranges for more details.

Examples
use discrete_range_map::test_ranges::ie;
use discrete_range_map::DiscreteRangeMap;

let slice =
	[(ie(1, 4), false), (ie(4, 8), true), (ie(8, 100), false)];

let map: DiscreteRangeMap<_, _, _> =
	DiscreteRangeMap::from_iter_strict(
		slice.into_iter().filter(|(range, _)| range.start > 2),
	)
	.unwrap();
source§

impl<I, K, V> DiscreteRangeMap<I, K, V>

source

pub fn new() -> Self

Makes a new, empty DiscreteRangeMap.

Examples
use discrete_range_map::{DiscreteRangeMap, InclusiveInterval};

let map: DiscreteRangeMap<i8, InclusiveInterval<i8>, bool> =
	DiscreteRangeMap::new();
source

pub fn len(&self) -> usize

Returns the number of ranges in the map.

Examples
use discrete_range_map::test_ranges::ie;
use discrete_range_map::DiscreteRangeMap;

let mut map = DiscreteRangeMap::new();

assert_eq!(map.len(), 0);
map.insert_strict(ie(0, 1), false).unwrap();
assert_eq!(map.len(), 1);
source

pub fn is_empty(&self) -> bool

Returns true if the map contains no ranges, and false if it does.

Examples
use discrete_range_map::test_ranges::ie;
use discrete_range_map::DiscreteRangeMap;

let mut map = DiscreteRangeMap::new();

assert_eq!(map.is_empty(), true);
map.insert_strict(ie(0, 1), false).unwrap();
assert_eq!(map.is_empty(), false);
source

pub fn iter(&self) -> impl DoubleEndedIterator<Item = (&K, &V)>

Returns an iterator over every entry in the map in ascending order.

Examples
use discrete_range_map::test_ranges::ie;
use discrete_range_map::DiscreteRangeMap;

let map = DiscreteRangeMap::from_slice_strict([
	(ie(1, 4), false),
	(ie(4, 8), true),
	(ie(8, 100), false),
])
.unwrap();

let mut iter = map.iter();

assert_eq!(iter.next(), Some((&ie(1, 4), &false)));
assert_eq!(iter.next(), Some((&ie(4, 8), &true)));
assert_eq!(iter.next(), Some((&ie(8, 100), &false)));
assert_eq!(iter.next(), None);
source

pub fn iter_mut(&mut self) -> impl DoubleEndedIterator<Item = (&K, &mut V)>

Returns an mutable iterator over every entry in the map in ascending order.

Examples
use discrete_range_map::test_ranges::ie;
use discrete_range_map::DiscreteRangeMap;

let mut map = DiscreteRangeMap::from_slice_strict([
	(ie(1, 4), false),
	(ie(4, 8), true),
	(ie(8, 100), false),
])
.unwrap();

for (range, value) in map.iter_mut() {
	if *range == ie(4, 8) {
		*value = false
	} else {
		*value = true
	}
}
source

pub fn first_entry(&self) -> Option<(&K, &V)>

Returns the first entry in the map, if any.

Examples
use discrete_range_map::test_ranges::ie;
use discrete_range_map::DiscreteRangeMap;

let map = DiscreteRangeMap::from_slice_strict([
	(ie(1, 4), false),
	(ie(4, 8), true),
	(ie(8, 100), false),
])
.unwrap();

assert_eq!(map.first_entry(), Some((&ie(1, 4), &false)));
source

pub fn last_entry(&self) -> Option<(&K, &V)>

Returns the last entry in the map, if any.

Examples
use discrete_range_map::DiscreteRangeMap;
use discrete_range_map::test_ranges::ie;

let map = DiscreteRangeMap::from_slice_strict([
	(ie(1, 4), false),
	(ie(4, 8), true),
	(ie(8, 100), false),
])
.unwrap();

assert_eq!(
	map.last_entry(),
	Some((&ie(8, 100), &false))
);

Trait Implementations§

source§

impl<I: Clone, K: Clone, V: Clone> Clone for DiscreteRangeMap<I, K, V>

source§

fn clone(&self) -> DiscreteRangeMap<I, K, V>

Returns a copy 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<I: Debug, K: Debug, V: Debug> Debug for DiscreteRangeMap<I, K, V>

source§

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

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

impl<I, K, V> Default for DiscreteRangeMap<I, K, V>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<'de, I, K, V> Deserialize<'de> for DiscreteRangeMap<I, K, V>
where I: PointType, K: RangeType<I> + Deserialize<'de>, V: Deserialize<'de>,

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<I, K, V> IntoIterator for DiscreteRangeMap<I, K, V>

§

type Item = (K, V)

The type of the elements being iterated over.
§

type IntoIter = IntoIter<I, K, V>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<I: PartialEq, K: PartialEq, V: PartialEq> PartialEq for DiscreteRangeMap<I, K, V>

source§

fn eq(&self, other: &DiscreteRangeMap<I, K, V>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<I, K, V> Serialize for DiscreteRangeMap<I, K, V>
where K: Serialize, V: Serialize,

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<I: Eq, K: Eq, V: Eq> Eq for DiscreteRangeMap<I, K, V>

source§

impl<I, K, V> StructuralEq for DiscreteRangeMap<I, K, V>

source§

impl<I, K, V> StructuralPartialEq for DiscreteRangeMap<I, K, V>

Auto Trait Implementations§

§

impl<I, K, V> RefUnwindSafe for DiscreteRangeMap<I, K, V>

§

impl<I, K, V> Send for DiscreteRangeMap<I, K, V>
where I: Send, K: Send, V: Send,

§

impl<I, K, V> Sync for DiscreteRangeMap<I, K, V>
where I: Sync, K: Sync, V: Sync,

§

impl<I, K, V> Unpin for DiscreteRangeMap<I, K, V>
where I: Unpin,

§

impl<I, K, V> UnwindSafe for DiscreteRangeMap<I, K, V>

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

§

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

§

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

§

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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,