Struct Generator

Source
pub struct Generator<'h> { /* private fields */ }

Implementations§

Source§

impl Generator<'_>

Source

pub fn get_or_init_dsl_maps( &self, ) -> &BTreeMap<LangID, BTreeMap<KString, OrderedAST>>

Initializes and retrieves DSL-based localization maps

§Behavior
  • Performs lazy initialization of DSL maps on first access
  • Subsequent calls return cached reference
Source

pub fn get_or_init_maps( &self, ) -> &BTreeMap<LangID, BTreeMap<(KString, KString), MiniStr>>

Initializes and retrieves primary localization maps

§Behavior
  • Lazily loads core localization data on first access
  • Caches results for subsequent requests
Source§

impl<'h> Generator<'h>

Source

pub fn get_or_init_highlight_maps( &'h self, ) -> Option<&'h BTreeMap<LangID, BTreeMap<(KString, KString), MiniStr>>>

Initializes and retrieves highlighted localization maps

§Behavior
  • Lazy initialization of special highlight entries
  • Only initializes if highlight configuration exists
Source

pub fn get_or_init_merged_maps( &'h self, ) -> &'h BTreeMap<LangID, BTreeMap<(KString, KString), MiniStr>>

Provides merged view of localization data

Merges Self::get_or_init_maps() & Self::get_or_init_highlight_maps()

Source§

impl Generator<'_>

Source

pub fn output_locales_fn( &self, map_type: MapType, const_lang_id: bool, ) -> AnyResult<String>

Generates a function listing all available locales

§Parameters
  • map_type
    • Mapping type to process
  • const_lang_id
    • Whether to generate lang_id constants
§Example
let function_data = new_generator()
  .with_visibility(crate::Visibility::Pub)
  .output_locales_fn(
    MapType::Regular,
    false,
)?;

function_data:

pub const fn all_locales() -> [lang_id::LangID; 107] {
use lang_id::consts::*;
[
  lang_id_af(),
  lang_id_am(),
  lang_id_ar(),
  lang_id_az(),
  lang_id_be(),
  lang_id_bg(),
  lang_id_bn(),
  lang_id_bs(),
  lang_id_ca(),
  lang_id_ceb(),
  lang_id_co(),
  ...
]}
Source

pub fn collect_raw_locales(&self, map_type: MapType) -> Result<Vec<MiniStr>>

-> e.g., ["en", "en-GB", "zh-Hant", "zh-Latn-CN"]

Source

pub fn output_mod_rs(&self, map_type: MapType) -> Result<String>

Generates cfg features for different languages and mod file names.

Output Sample:

#[cfg(feature = "l10n-en-GB")]
mod l10n_en_gb;

#[cfg(feature = "l10n-es")]
mod l10n_es;

You can use this in mod.rs.

Note: If you use output_*_all_in_one, you do not need to call this method.

Source

pub fn collect_cargo_feature_names( &self, map_type: MapType, ) -> Result<Vec<MiniStr>>

-> e.g., ["l10n-en", "l10n-en-GB", "l10n-zh", "l10n-zh-Hant"]

Source

pub fn collect_rs_mod_names(&self, map_type: MapType) -> Result<Vec<MiniStr>>

-> e.g., ["l10n_en", "l10n_en_gb", "l10n_zh"]

Source

pub fn output_cargo_features(&self, map_type: MapType) -> Result<String>

Generates Cargo features for different locales.

Output Sample:

l10n-en = []
l10n-zh = []
l10n-all = ["l10n-en","l10n-zh"]
Source§

impl Generator<'_>

Source

pub fn output_router_for_match_fns( &self, map_type: MapType, contains_map_name: bool, ) -> Result<String>

Generates a function that routes to the appropriate module and extracts the corresponding value.

Example: self.output_router_for_match_fns(MapType::Regular, false)?

Output String Sample:

pub const fn map(language: &[u8], key: &[u8]) -> &'static str {
  use super::*;
  match language {
    #[cfg(feature = "l10n-de")]
    b"de" => l10n_de::map(key),
    #[cfg(feature = "l10n-en-GB")]
    b"en-GB" => l10n_en_gb::map(key),
    _ => "",
  }
}
Source

pub fn output_router_for_phf_maps( &self, map_type: MapType, contains_map_name: bool, ) -> Result<String>

Generates a function that routes to the appropriate phf map.

Example: self.output_router_for_phf_maps(MapType::Regular, true)?

Output String Sample:

// super: use glossa_shared::PhfL10nOrderedMap;
pub(crate) const fn map(language: &[u8]) -> super::PhfL10nOrderedMap {
  use super::*;
  match language {
    #[cfg(feature = "l10n-ar")]
    b"ar" => l10n_ar::map(),
    #[cfg(feature = "l10n-as")]
    b"as" => l10n_as::map(),
    _ => "",
  }
}
Source§

impl<'h> Generator<'h>

Source

pub fn output_bincode_all_in_one(&'h self, map_type: MapType) -> AnyResult<()>

Generates consolidated binary file containing all localization data

> “outdir()/all{bincode_suffix}”

§Behavior
  • For DSL maps: Creates “all{bincode_suffix}” containing DSL data
  • For regular maps: Creates “all{bincode_suffix}” containing all language data
§Errors

Returns AnyResult with error details for:

  • File I/O failures
  • Serialization errors
Source

pub fn output_bincode(&'h self, map_type: MapType) -> AnyResult<()>

Generates individual binary files per language

> “outdir()/{language}{bincode_suffix}”

§Behavior
  • For DSL maps: Creates separate files for each glossa-DSL content
  • For regular maps: Creates separate files for each language
  • Skips empty datasets
§Example

“../../locales/en/unread.dsl.toml”:

num-to-en = """
$num ->
  [0] zero
  [1] one
  [2] two
  [3] three
  *[other] {$num}
"""

unread = "unread message"

unread-count = """
$num ->
  [0] No {unread}s.
  [1] You have { num-to-en } {unread}.
  *[other] You have { num-to-en } {unread}s.
"""

show-unread-messages-count = "{unread-count}"

rs_code:

use glossa_codegen::{L10nResources, Generator, generator::MapType};
use std::path::Path;

let resources = L10nResources::new("../../locales/");

// Output to tmp/{language}.tmpl.bincode
Generator::default()
  .with_resources(resources)
  .with_outdir("tmp")
  .with_bincode_suffix(".tmpl.bincode".into())
  .output_bincode(MapType::DSL)?;

let file = Path::new("tmp").join("en.tmpl.bincode");
let tmpl_maps = glossa_shared::decode::file::decode_single_file_to_dsl_map(file)?;
let unread_tmpl = tmpl_maps
  .get("unread")
  .expect("Failed to get DSL-AST (map_name: unread)");

let get_text = |num_str| {
  unread_tmpl.get_with_context("show-unread-messages-count", &[("num", num_str)])
};

let one = get_text("1")?;
assert_eq!(one, "You have one unread message.");

let zero = get_text("0")?;
assert_eq!(zero, "No unread messages.");
Source§

impl<'h> Generator<'h>

Source

pub fn output_match_fn(&self, non_dsl: MapType) -> Result<()>

Generates individual match functions per locale => const fn map(map_name: &[u8], key: &[u8]) -> &'static str

Source

pub fn output_match_fn_all_in_one(&'h self, non_dsl: MapType) -> Result<String>

Generates a consolidated match function containing all localization mappings

Generates:

const fn map(lang: &[u8], map_name: &[u8], key: &[u8])
  -> &'static str {
  match (lang, map_name, key) {...}
}
§Parameter
  • non_dsl
    • Specifies the type of mapping to process.
    • Note: Does not support DSL MapType
§Example
use glossa_codegen::{L10nResources, Generator, generator::MapType};

const L10N_DIR: &str = "../../locales/";

let data = L10nResources::new(L10N_DIR)
  .with_include_languages(["en-GB", "de", "es", "pt",
"zh-pinyin"]);

let function_data = Generator::default()
  .with_resources(data)
  .output_match_fn_all_in_one(MapType::Regular)?;

assert_eq!(function_data.trim(), r#######"
  pub(crate) const fn map(lang: &[u8], map_name: &[u8], key: &[u8]) ->
  &'static str {
    match (lang, map_name, key) {
    (b"de", b"error", b"text-not-found") => r#####"Kein lokalisierter Text
gefunden"#####,
    (b"en-GB", b"error", b"text-not-found") => r#####"No
localised text found"#####,
    (b"es", b"error", b"text-not-found") =>
r#####"No se encontró texto localizado"#####,
    (b"pt", b"error",
b"text-not-found") => r#####"Nenhum texto localizado encontrado"#####,
    (b"zh-Latn-CN", b"error", b"text-not-found") => r#####"MeiYou ZhaoDao
BenDiHua WenBen"#####,
    _ => "",
}}
    "#######.trim());
Source

pub fn output_match_fn_all_in_one_by_language( &'h self, non_dsl: MapType, ) -> Result<String>

Generates a function: const fn map(language: &[u8]) -> &'static str { match language {...} }

Note: This function is for performance optimization. Only invoke it to generate a new function when both map_name and key are guaranteed to be unique. Otherwise, use Self::output_match_fn_all_in_one.

Source

pub fn output_match_fn_all_in_one_without_map_name( &'h self, non_dsl: MapType, ) -> Result<String>

Generates a function: const fn map(language: &[u8], key: &[u8]) -> &'static str { match (language, key) {...} }

§Note

You can invoke this function to generate a new function only when map_name is unique.

Example:

  • en/yes-no { yes: "Yes", no: "No"}
  • de/yes-no { yes: "Ja", no: "Nein" }

Here, map_name is unique (per language), so it can be omitted:

match (language, key) {
  (b"en", b"yes") => r#####"Yes"#####,
  (b"en", b"no") => r#####"No"#####,
  (b"de", b"yes") => r#####"Ja"#####,
  (b"de", b"no") => r#####"Nein"#####,
}

If map_names are not unique, use Self::output_match_fn_all_in_one instead.

For example, adding a new map: en/yes-no2 { yes: "YES", no: "NO"} would create conflicting keys (“yes”, “no”) if map_name is omitted.

Source

pub fn new_fn_header(&self, header: &str) -> String

Creates header for generated functions

Source

pub fn output_match_fn_without_map_name( &'h self, non_dsl: MapType, ) -> Result<()>

Generates individual match functions per locale => const fn map(key: &[u8]) -> &'static str

Compared to output_match_fn, omits map_name. If you’re unsure which one to use, then use output_match_fn()

Source§

impl<'h> Generator<'h>

Source

pub fn output_phf_all_in_one(&'h self, non_dsl: MapType) -> Result<String>

Collect all localized resources into a const phf::OrderedMap function, i.e., a single table can accommodate different language, map_name, and map_key.

§Example
use glossa_codegen::{L10nResources, Generator, generator::MapType};
use glossa_shared::tap::Pipe;

let data = L10nResources::new("../../locales/")
  .with_include_map_names(["error"])
  .with_include_languages([
    "de",
    "zh-pinyin",
    "zh",
    "pt",
    "es",
    "en",
    "en-GB",
]);

let function_data = Generator::default()
  .with_resources(data)
  .output_phf_all_in_one(MapType::Regular)?;
§function data:
// glossa_shared::{phf, PhfL10nAllInOneMap, PhfTripleKey};

pub(crate) const fn map() -> super::PhfL10nAllInOneMap {
    use super::PhfTripleKey as Key;
    super::phf::OrderedMap {
      key: 12913932095322966823,
      disps: &[(2, 3), (2, 0)],
      idxs: &[5, 4, 0, 6, 3, 2, 1],
      entries: &[
        (
          Key(r#"de"#, r##"error"##, r###"text-not-found"###),
          r#####"Kein lokalisierter Text gefunden"#####,
        ),
        (
          Key(r#"en"#, r##"error"##, r###"text-not-found"###),
          r#####"No localized text found"#####,
        ),
        (
          Key(r#"en-GB"#, r##"error"##, r###"text-not-found"###),
          r#####"No localised text found"#####,
        ),
        (
          Key(r#"es"#, r##"error"##, r###"text-not-found"###),
          r#####"No se encontró texto localizado"#####,
        ),
        (
          Key(r#"pt"#, r##"error"##, r###"text-not-found"###),
          r#####"Nenhum texto localizado encontrado"#####,
        ),
        (
          Key(r#"zh"#, r##"error"##, r###"text-not-found"###),
          r#####"未找到本地化文本"#####,
        ),
        (
          Key(r#"zh-Latn-CN"#, r##"error"##, r###"text-not-found"###),
          r#####"MeiYou ZhaoDao BenDiHua WenBen"#####,
        ),
      ],
    }
}
§Get Text
use glossa_shared::PhfTripleKey;

fn test_get_text() {
    let map = map();
    let get_text =
      |language| map.get(&PhfTripleKey(language, "error", "text-not-found"));

    let zh_text = get_text("zh");
    assert_eq!(zh_text, Some(&"未找到本地化文本"));

    let language_chain = ["gsw", "de-CH", "de", "en"];

    let text = language_chain
      .into_iter()
      .find_map(get_text);
    assert_eq!(text, Some(&"Kein lokalisierter Text gefunden"));
}
Source

pub fn output_phf(&'h self, non_dsl: MapType) -> Result<()>

Generates Perfect Hash Function (PHF) maps for localization data. => const fn map() -> super::PhfL10nOrderedMap

§Behavior
  • Processes non-DSL maps in parallel
  • Filters out empty localization datasets
  • Generates PHF maps preserving insertion order
  • Creates individual Rust module files per language
§Errors

Returns io::Result for file I/O operations failures

Source

pub fn output_phf_without_map_name(&'h self, non_dsl: MapType) -> Result<()>

Generates Perfect Hash Function (PHF) maps for localization data. => const fn map() -> super::PhfStrMap

Note: The generated PHF map is only for localization data where map_name can be ignored. If map_name cannot be ignored, please use output_phf.

Source§

impl<'h> Generator<'h>

Source

pub fn get_resources(&self) -> &Box<L10nResources>

Source

pub fn get_visibility(&self) -> &Visibility

function visibility

Source

pub fn get_mod_visibility(&self) -> &Visibility

Source

pub fn get_outdir(&self) -> &Option<PathBuf>

Source

pub fn get_bincode_suffix(&self) -> &MiniStr

Source

pub fn get_mod_prefix(&self) -> &MiniStr

Source

pub fn get_feature_prefix(&self) -> &MiniStr

Source

pub fn get_highlight(&self) -> &Option<Box<HighlightCfgMap<'h>>>

Source§

impl<'h> Generator<'h>

Source

pub fn with_visibility(self, val: Visibility) -> Self

function visibility

Source

pub fn with_mod_visibility(self, val: Visibility) -> Self

Source

pub fn with_bincode_suffix(self, val: MiniStr) -> Self

Source

pub fn with_mod_prefix(self, val: MiniStr) -> Self

Source

pub fn with_feature_prefix(self, val: MiniStr) -> Self

Source§

impl<'h> Generator<'h>

Source

pub fn get_mod_visibility_mut(&mut self) -> &mut Visibility

Source

pub fn get_outdir_mut(&mut self) -> &mut Option<PathBuf>

Source

pub fn get_bincode_suffix_mut(&mut self) -> &mut MiniStr

Source

pub fn get_mod_prefix_mut(&mut self) -> &mut MiniStr

Source

pub fn get_feature_prefix_mut(&mut self) -> &mut MiniStr

Source§

impl<'h> Generator<'h>

Source

pub fn with_highlight(self, highlight: HighlightCfgMap<'h>) -> Self

Source

pub fn set_highlight(&mut self, highlight: Option<HighlightCfgMap<'h>>)

Source§

impl Generator<'_>

Source

pub fn with_outdir<P: Into<PathBuf>>(self, outdir: P) -> Self

Source§

impl Generator<'_>

Source

pub fn with_resources(self, resources: L10nResources) -> Self

Configures the generator with localization resources, resetting cached mappings.

This method performs two primary actions:

  1. Replaces the current L10nResources with the provided instance
  2. Resets the internal lazy_maps to their default empty state
§Side Effects

The cache clearance ensures any existing lazy-loaded mappings won’t conflict with new resources. Subsequent operations will rebuild mappings from the updated resources.

§Example
use glossa_codegen::{Generator, L10nResources};

// Initialize resources from a localization directory
let resources = L10nResources::new("../../locales/");

// Create generator with configured resources
let _generator = Generator::default()
  .with_resources(resources);

Trait Implementations§

Source§

impl<'h> Clone for Generator<'h>

Source§

fn clone(&self) -> Generator<'h>

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<'h> Debug for Generator<'h>

Source§

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

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

impl Default for Generator<'_>

Source§

fn default() -> Self

Default:

{
  bincode_suffix: ".bincode",
  mod_prefix: "l10n_",
  visibility: Visibility::PubCrate,
  mod_visibility: Visibility::Private,
  ..Default::default()
}

Auto Trait Implementations§

§

impl<'h> Freeze for Generator<'h>

§

impl<'h> RefUnwindSafe for Generator<'h>

§

impl<'h> Send for Generator<'h>

§

impl<'h> Sync for Generator<'h>

§

impl<'h> Unpin for Generator<'h>

§

impl<'h> UnwindSafe for Generator<'h>

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