Move interaction constructors back to individual types

finchie
Aug 8, 2025, 7:11 AM
BC22FLOQBQ6EOUSCN6THUXQDZYZPWSF6QJX5Z6WA4GYFR6BK4DZAC

Dependencies

  • [2] IZ67IMRI Move prompt message to initial constructor
  • [3] BAH2JCJP Add progress bar to `fluent_embed_interaction`
  • [4] IXBE5Q6T Implement `InteractionEnvironment::print_message`
  • [5] KFFAQIZU Rename `InteractionEnvironment::print_message` to `emit_message`
  • [6] EKXWNEPK Rename `Localize::message_for_locale` to `Localize::localize_for`
  • [7] NEBSVXIA Apply Clippy fixes
  • [8] JUV7C6ET Create initial prototype of `fluent_embed_interaction`
  • [9] 7YOM2QEF Move interaction constructors from individual types to implementations on `InteractionEnvironment`

Change contents

  • replacement in l10n_embed_interaction/src/prompt/select.rs at line 15
    [3.207][2.70:217]()
    pub(crate) fn new_from_environment<L: Localize>(
    environment: &'environment InteractionEnvironment,
    prompt: L,
    ) -> Self {
    [3.207]
    [2.217]
    pub fn new<L: Localize>(environment: &'environment InteractionEnvironment, prompt: L) -> Self {
  • replacement in l10n_embed_interaction/src/prompt/password.rs at line 20
    [3.829][2.558:611]()
    pub(crate) fn new_from_environment<L: Localize>(
    [3.829]
    [2.611]
    pub fn new<L: Localize>(
  • replacement in l10n_embed_interaction/src/prompt/input.rs at line 15
    [3.2129][2.1314:1367]()
    pub(crate) fn new_from_environment<L: Localize>(
    [3.2129]
    [2.1367]
    pub fn new<L: Localize>(
  • replacement in l10n_embed_interaction/src/prompt/confirm.rs at line 15
    [3.2760][2.1800:1947]()
    pub(crate) fn new_from_environment<L: Localize>(
    environment: &'environment InteractionEnvironment,
    prompt: L,
    ) -> Self {
    [3.2760]
    [2.1947]
    pub fn new<L: Localize>(environment: &'environment InteractionEnvironment, prompt: L) -> Self {
  • replacement in l10n_embed_interaction/src/progress.rs at line 18
    [3.3142][3.3142:3195]()
    pub(crate) fn new_from_environment<L: Localize>(
    [3.3142]
    [3.3195]
    pub fn new<L: Localize>(
  • edit in l10n_embed_interaction/src/lib.rs at line 55
    [3.602][3.3796:3949](),[3.3796][3.3796:3949](),[3.3949][2.2296:2530](),[2.2530][3.4104:4138](),[3.4104][3.4104:4138](),[3.4138][2.2531:2607](),[2.2607][3.4219:4260](),[3.4219][3.4219:4260](),[3.4299][3.4299:4418](),[3.4418][2.2608:2864]()
    }
    }
    macro_rules! impl_constructor {
    ($prompt_name:ident, $prompt_type:ident) => {
    impl InteractionEnvironment {
    #[must_use]
    pub fn $prompt_name<'environment, L: Localize>(
    &'environment self,
    prompt: L,
    ) -> $prompt_type<'environment> {
    $prompt_type::new_from_environment(self, prompt)
    }
    }
    };
    }
    // Create constructors on InteractionEnvironment for different prompt types
    impl_constructor!(new_confirm, Confirm);
    impl_constructor!(new_input, Input);
    impl_constructor!(new_password, Password);
    impl_constructor!(new_select, Select);
    // Special implementation for text editor as the signature is different
    impl InteractionEnvironment {
    pub fn new_editor<'environment>(&'environment self, extension: &str) -> Editor<'environment> {
    Editor::new_from_environment(self, extension)
  • edit in l10n_embed_interaction/src/lib.rs at line 57
    [2.2872][3.4418:4732](),[3.4418][3.4418:4732](),[3.151][3.10328:10336](),[3.4732][3.10328:10336](),[3.10328][3.10328:10336]()
    // Special implementation for progress bars as the signature is different
    impl InteractionEnvironment {
    pub fn new_progress<'environment, L: Localize>(
    &'environment self,
    message: L,
    length: u64,
    ) -> ProgressBar {
    ProgressBar::new_from_environment(self, message, length)
    }
    }
  • replacement in l10n_embed_interaction/src/editor.rs at line 10
    [3.4865][2.2929:3069]()
    pub(crate) fn new_from_environment(
    environment: &'environment InteractionEnvironment,
    extension: &str,
    ) -> Self {
    [3.4865]
    [3.4965]
    pub fn new(environment: &'environment InteractionEnvironment, extension: &str) -> Self {