Struct TemplateResolver

Source
pub struct TemplateResolver(pub TemplateAST);
Expand description

Main template resolution engine

§Implementation Notes

  • cfg(feature = "std")
    • Uses HashMap with std for O(1) lookups
  • no_std:
    • Falls back to BTreeMap in no_std (O(log n) lookups)

Tuple Fields§

§0: TemplateAST

Implementations§

Source§

impl TemplateResolver

Source

pub fn encode_bin<P: AsRef<Path>>(&self, dst_file: P) -> ResolverResult<usize>

Available on crate features bincode and std only.

Serializes the resolver to bincode format and writes to a file

§Design Notes
  • Uses buffered writer for optimal large-file performance
  • Leverages bincode’s compact binary representation
  • Preserves structure ordering through deterministic serialization
§Example
use tmpl_resolver::TemplateResolver;

let resolver: TemplateResolver = [
    ("h", "Hello"),
    ("greeting", "{h} { $name }!")
  ]
  .try_into()
  .expect("Invalid slice");

let file = "tmp.bincode";

resolver.encode_bin(file).expect("Failed to encode TemplateResolver to bincode file");
Source

pub fn decode_bin<P: AsRef<Path>>(src_file: P) -> ResolverResult<Self>

Available on crate features bincode and std only.

Deserializes a resolver from bincode-formatted file

It Uses buffered reading for I/O efficiency.

§Example
use tmpl_resolver::TemplateResolver;

let file = "tmp.bincode";

TemplateResolver::decode_bin(file).expect("Failed to decode bincode file to TemplateResolver");
Source§

impl TemplateResolver

Source

pub fn decode_bin_from_slice(slice: &[u8]) -> ResolverResult<(Self, usize)>

Available on crate feature bincode only.

Decodes binary data into TemplateResolver using bincode’s optimized deserialization.

§Input
  • slice - Binary input slice containing serialized TemplateResolver data
§Output
  • A tuple of (deserialized TemplateResolver, amount of bytes read) on success
  • Error details if deserialization fails

See also: bincode::serde::decode_from_slice

Source

pub fn encode_bin_to_vec(&self) -> ResolverResult<Vec<u8>>

Available on crate feature bincode only.

Encodes the Self(TemplateResolver) into a binary format stored in a Vec<u8>.

§Example
use tmpl_resolver::TemplateResolver;

let res: TemplateResolver =
  [("🐱", "喵 ฅ(°ω°ฅ)"), ("hello", "{🐱}")].try_into()?;

let _data = res.encode_bin_to_vec()?;

See also: bincode::serde::encode_to_vec

Source§

impl TemplateResolver

Source

pub fn try_from_slice(raw: &[(&str, &str)]) -> ResolverResult<Self>

Construct from slice (no_std compatible)

use tap::Pipe;
use tmpl_resolver::TemplateResolver;

let res = [
  ("🐱", "喵 ฅ(°ω°ฅ)"),
  ("hello", "Hello {🐱}"),
]
 .as_ref()
 .pipe(TemplateResolver::try_from_slice)?;

let text = res.get_with_context("hello", &[])?;
assert_eq!(text, "Hello 喵 ฅ(°ω°ฅ)");
Source

pub fn try_from_str_entries<K, V, I>(iter: I) -> ResolverResult<Self>
where K: AsRef<str>, V: AsRef<str>, I: Iterator<Item = (K, V)>,

Attempts to build a TemplateResolver from raw unprocessed key-value entries.

§Process Flow
  1. Accepts an iterator of raw (key, value) pairs
  2. Parses each value into template AST (Abstract Syntax Tree)
  3. Converts keys to normalized format
  4. Collects results into a TemplateAST
  5. Constructs the final resolver
§Parameters
  • iter: Iterator over raw unvalidated entries.
    • e.g., [(k1, v1), (k2, v2)].into_iter()
§Type Constraints
  • K: Key type with string-like representation
  • V: Raw value type containing template text
  • I: Iterator providing raw configuration entries
§Example
use tap::Pipe;
use tmpl_resolver::{TemplateResolver, resolver::MiniStr, resolver::BTreeRawMap};


let res = r##"
  "🐱" = "喵 ฅ(°ω°ฅ)"

  "问候" = """
$period ->
  [morning] 早安{🐱}
  [night] 晚安{🐱}
  *[other] {$period}好
  """

  "称谓" = """
  $gender ->
[male] 先生
[female] 女士
*[test] { $🧑‍🏫 }
  """

  greeting = "{ 问候 }!{ $name }{ 称谓 }。"
"##
  .pipe(toml::from_str::<BTreeRawMap>)?
  .into_iter()
  .pipe(TemplateResolver::try_from_str_entries)?;

assert_eq!(res.try_get("🐱")?, "喵 ฅ(°ω°ฅ)");

See also:

Source§

impl TemplateResolver

Source

pub fn get_with_context( &self, var_name: &str, context: &[(&str, &str)], ) -> ResolverResult<MiniStr>

Core resolution method

If the context is empty, you can directly use Self::try_get.

§Algorithm
  1. Context sorting for O(log n) parameter lookups
  2. Recursive template evaluation
  3. Branch prediction for conditional blocks
§Example
use tmpl_resolver::{TemplateResolver, error::ResolverError};

let res: TemplateResolver = [
  ("h", "Hello"),
  ("greeting", "{h} {$🐱}"),
]
.try_into()?;

let ctx = [("🐱", "喵 ฅ(°ω°ฅ)")];

let text = res.get_with_context("greeting", &ctx)?;
assert_eq!(text, "Hello 喵 ฅ(°ω°ฅ)");

See also: Self::get_with_ctx_map

Source

pub fn get_with_ctx_btree_map( &self, var_name: &str, context_map: &BTreeRawMap, ) -> ResolverResult<MiniStr>

Similar to Self::get_with_context, but the context is BTreeMap<MiniStr, MiniStr> instead of &[(&str, &str)].

Source

pub fn try_get(&self, var_name: &str) -> ResolverResult<MiniStr>

Similar to Self::get_with_context, but no context.

§Example
use tmpl_resolver::{TemplateResolver, error::ResolverError};

let res: TemplateResolver = [
  ("🐱", "ฅ(°ω°ฅ)"),
  ("hi", "Hello"),
  ("greeting", "{ hi } { 🐱 }"),
]
.try_into()?;

let text = res.try_get("greeting")?;
assert_eq!(text, "Hello ฅ(°ω°ฅ)");
Source

pub fn get_with_ctx_map( &self, var_name: &str, context_map: &ContextMap<'_>, ) -> ResolverResult<MiniStr>

Available on crate feature std only.

Similar to Self::get_with_context, but the context is &ContextMap instead of &[(&str, &str)].

If the parameter you need to pass is a Context HashMap that owns the data internally (e.g., HashMap<KString, CompactString>), instead of HashMap<&str, &str>, please use Self::get_with_ctx_map_buf.

§Example
use tmpl_resolver::TemplateResolver;

let res: TemplateResolver = [
  ("g", "Good"),
  ("greeting", "{g} { time-period }! { $name }"),
  (
    "time-period",
    "$period ->
      [morning] Morning
      *[other] {$period}",
  ),
]
.try_into()?;

let ctx_map = [("name", "Tom"), ("period", "night")]
  .into_iter()
  .collect();

let text = res.get_with_ctx_map("greeting", &ctx_map)?;
assert_eq!(text, "Good night! Tom");
Source

pub fn get_with_ctx_map_buf( &self, var_name: &str, context_map: &ContextMapBuf, ) -> ResolverResult<MiniStr>

Available on crate feature std only.

Similar to Self::get_with_ctx_map, but the context is &ContextMapBuf instead of &ContextMap.

§Example
use tmpl_resolver::TemplateResolver;

let res: TemplateResolver = [
  ("greeting", "{$hi} { $name }"),
]
.try_into()?;

let ctx_map = [("name", "Tom"), ("hi", "Hello!")]
  .into_iter()
  .map(|(k, v)| (k.into(), v.into()) )
  .collect();

let text = res.get_with_ctx_map("greeting", &ctx_map)?;
assert_eq!(text, "Hello! Tom");
Source§

impl TemplateResolver

Source

pub fn into_btree_map(self) -> OrderedAST

Converts the resolver into a BTreeMap.

An ordered BTreeMap is useful when you need to serialize the TemplateResolver to a configuration file or a binary file.

§Example
use tmpl_resolver::TemplateResolver;

let resolver = TemplateResolver::default();
let _map = resolver.into_btree_map();
Source

pub fn into_inner(self) -> TemplateAST

Takes ownership of the Self and returns the inner data (template AST)

§Example
use tmpl_resolver::TemplateResolver;

let resolver = TemplateResolver::default();
let _inner_data = resolver.into_inner();
Source§

impl TemplateResolver

Source

pub fn try_from_raw<K, V, I>(iter: I) -> ResolverResult<Self>
where K: Into<KString> + Display, V: AsRef<str>, I: IntoIterator<Item = (K, V)>,

Available on crate feature std only.

Construct from IntoIterator<(K, V)>, e.g., HashMap

§Example
use tmpl_resolver::TemplateResolver;
use tap::pipe::Pipe;

let resolver = [
   (
     "salutation",
     "
     $gender ->
       [male] Mr.
       *[female] Ms.",
   ),
   ("g", "Good"),
   (
     "time-greeting",
     "$period ->
       [morning] {g} Morning
       [evening] {g} Evening
       *[other] {g} {$period}
     ",
   ),
   ("greeting", "{ time-greeting }! { salutation }{ $name }"),
 ]
 // .into_iter()
 // .map(|(k, v)| (k.into(), v.into()))
 // .collect::<tmpl_resolver::resolver::AHashRawMap>()
 .pipe(TemplateResolver::try_from_raw)?;

let text = resolver
   .get_with_context(
     "greeting",
     &[
       ("period", "evening"),
       ("name", "Alice"),
       ("gender", "unknown"),
     ],
   )
   .expect("Failed to get text");

assert_eq!(text, "Good Evening! Ms.Alice");

Methods from Deref<Target = TemplateAST>§

1.0.0 · Source

pub fn capacity(&self) -> usize

Returns the number of elements the map can hold without reallocating.

This number is a lower bound; the HashMap<K, V> might be able to hold more, but is guaranteed to be able to hold at least this many.

§Examples
use std::collections::HashMap;
let map: HashMap<i32, i32> = HashMap::with_capacity(100);
assert!(map.capacity() >= 100);
1.0.0 · Source

pub fn keys(&self) -> Keys<'_, K, V>

An iterator visiting all keys in arbitrary order. The iterator element type is &'a K.

§Examples
use std::collections::HashMap;

let map = HashMap::from([
    ("a", 1),
    ("b", 2),
    ("c", 3),
]);

for key in map.keys() {
    println!("{key}");
}
§Performance

In the current implementation, iterating over keys takes O(capacity) time instead of O(len) because it internally visits empty buckets too.

1.0.0 · Source

pub fn values(&self) -> Values<'_, K, V>

An iterator visiting all values in arbitrary order. The iterator element type is &'a V.

§Examples
use std::collections::HashMap;

let map = HashMap::from([
    ("a", 1),
    ("b", 2),
    ("c", 3),
]);

for val in map.values() {
    println!("{val}");
}
§Performance

In the current implementation, iterating over values takes O(capacity) time instead of O(len) because it internally visits empty buckets too.

1.0.0 · Source

pub fn iter(&self) -> Iter<'_, K, V>

An iterator visiting all key-value pairs in arbitrary order. The iterator element type is (&'a K, &'a V).

§Examples
use std::collections::HashMap;

let map = HashMap::from([
    ("a", 1),
    ("b", 2),
    ("c", 3),
]);

for (key, val) in map.iter() {
    println!("key: {key} val: {val}");
}
§Performance

In the current implementation, iterating over map takes O(capacity) time instead of O(len) because it internally visits empty buckets too.

1.0.0 · Source

pub fn len(&self) -> usize

Returns the number of elements in the map.

§Examples
use std::collections::HashMap;

let mut a = HashMap::new();
assert_eq!(a.len(), 0);
a.insert(1, "a");
assert_eq!(a.len(), 1);
1.0.0 · Source

pub fn is_empty(&self) -> bool

Returns true if the map contains no elements.

§Examples
use std::collections::HashMap;

let mut a = HashMap::new();
assert!(a.is_empty());
a.insert(1, "a");
assert!(!a.is_empty());
1.9.0 · Source

pub fn hasher(&self) -> &S

Returns a reference to the map’s BuildHasher.

§Examples
use std::collections::HashMap;
use std::hash::RandomState;

let hasher = RandomState::new();
let map: HashMap<i32, i32> = HashMap::with_hasher(hasher);
let hasher: &RandomState = map.hasher();
1.0.0 · Source

pub fn get<Q>(&self, k: &Q) -> Option<&V>
where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

Returns a reference to the value corresponding to the key.

The key may be any borrowed form of the map’s key type, but Hash and Eq on the borrowed form must match those for the key type.

§Examples
use std::collections::HashMap;

let mut map = HashMap::new();
map.insert(1, "a");
assert_eq!(map.get(&1), Some(&"a"));
assert_eq!(map.get(&2), None);
1.40.0 · Source

pub fn get_key_value<Q>(&self, k: &Q) -> Option<(&K, &V)>
where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

Returns the key-value pair corresponding to the supplied key. This is potentially useful:

  • for key types where non-identical keys can be considered equal;
  • for getting the &K stored key value from a borrowed &Q lookup key; or
  • for getting a reference to a key with the same lifetime as the collection.

The supplied key may be any borrowed form of the map’s key type, but Hash and Eq on the borrowed form must match those for the key type.

§Examples
use std::collections::HashMap;
use std::hash::{Hash, Hasher};

#[derive(Clone, Copy, Debug)]
struct S {
    id: u32,
    name: &'static str, // ignored by equality and hashing operations
}

impl PartialEq for S {
    fn eq(&self, other: &S) -> bool {
        self.id == other.id
    }
}

impl Eq for S {}

impl Hash for S {
    fn hash<H: Hasher>(&self, state: &mut H) {
        self.id.hash(state);
    }
}

let j_a = S { id: 1, name: "Jessica" };
let j_b = S { id: 1, name: "Jess" };
let p = S { id: 2, name: "Paul" };
assert_eq!(j_a, j_b);

let mut map = HashMap::new();
map.insert(j_a, "Paris");
assert_eq!(map.get_key_value(&j_a), Some((&j_a, &"Paris")));
assert_eq!(map.get_key_value(&j_b), Some((&j_a, &"Paris"))); // the notable case
assert_eq!(map.get_key_value(&p), None);
1.0.0 · Source

pub fn contains_key<Q>(&self, k: &Q) -> bool
where K: Borrow<Q>, Q: Hash + Eq + ?Sized,

Returns true if the map contains a value for the specified key.

The key may be any borrowed form of the map’s key type, but Hash and Eq on the borrowed form must match those for the key type.

§Examples
use std::collections::HashMap;

let mut map = HashMap::new();
map.insert(1, "a");
assert_eq!(map.contains_key(&1), true);
assert_eq!(map.contains_key(&2), false);

Trait Implementations§

Source§

impl Clone for TemplateResolver

Source§

fn clone(&self) -> TemplateResolver

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 TemplateResolver

Source§

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

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

impl Default for TemplateResolver

Source§

fn default() -> TemplateResolver

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

impl Deref for TemplateResolver

Source§

type Target = HashMap<KStringBase<Box<str>>, Template, RandomState>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<'de> Deserialize<'de> for TemplateResolver

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 From<TemplateResolver> for OrderedAST

Converts the resolver into an ordered abstract syntax tree (AST) representation.

§Feature-dependent Behavior
  • With std feature: Converts internal storage to a alloc::collections::BTreeMap-backed ordered AST through iterative collection. This guarantees deterministic ordering.
  • Without std feature: Directly returns the pre-ordered AST structure without conversion, optimized for no_std environments.
Source§

fn from(value: TemplateResolver) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for TemplateResolver

Source§

fn eq(&self, other: &TemplateResolver) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for TemplateResolver

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 TryFrom<&[(&str, &str)]> for TemplateResolver

Source§

type Error = ResolverError

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

fn try_from(value: &[(&str, &str)]) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<const N: usize> TryFrom<[(&str, &str); N]> for TemplateResolver

Source§

type Error = ResolverError

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

fn try_from(value: [(&str, &str); N]) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<K, V, S> TryFrom<AHashMap<K, V, S>> for TemplateResolver
where K: Into<KString> + Display, V: AsRef<str>,

Available on crate feature std only.
Source§

type Error = ResolverError

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

fn try_from(value: AHashMap<K, V, S>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<K, V> TryFrom<BTreeMap<K, V>> for TemplateResolver
where K: AsRef<str>, V: AsRef<str>,

Source§

type Error = ResolverError

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

fn try_from(value: BTreeMap<K, V>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<K, V, S> TryFrom<HashMap<K, V, S>> for TemplateResolver
where K: Into<KString> + Display, V: AsRef<str>,

Available on crate feature std only.
Source§

type Error = ResolverError

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

fn try_from(value: StdHashMap<K, V, S>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<K, V> TryFrom<Vec<(K, V)>> for TemplateResolver
where K: Into<KString> + Display, V: AsRef<str>,

Available on crate feature std only.
Source§

type Error = ResolverError

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

fn try_from(value: Vec<(K, V)>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl StructuralPartialEq for TemplateResolver

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

Source§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. 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> Pipe for T
where T: ?Sized,

Source§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
Source§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
Source§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Source§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
Source§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
Source§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
Source§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Tap for T

Source§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
Source§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
Source§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
Source§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
Source§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
Source§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
Source§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
Source§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
Source§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
Source§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
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> TryConv for T

Source§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. 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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,