Reverting earlier change, interactions still carry a reference to the environment but are constructed by calling Self::new()
directly.
BC22FLOQBQ6EOUSCN6THUXQDZYZPWSF6QJX5Z6WA4GYFR6BK4DZAC
IZ67IMRIPBOYLOAR5WE5NYA7MHOT7TXXEE7WM63MU4JSH6OM7YQQC
7YOM2QEFZ5HWVEISP3VIR2GKF2NNH4KKTLTWEMYMMWNYKICXWTZAC
JUV7C6ET4ZQJNLO7B4JB7XMLV2YUBZB4ARJHN4JEPHDGGBWGLEVAC
BAH2JCJPTDXAE6XGSLIPBQZU4GQY65HI66Q4XTFNL65MV6VSNF2QC
EKXWNEPK4FTYKT2RJL2L7HTM64VQGDD3DYD6NZIDGMMV6ITHUVZAC
IXBE5Q6TIJTOYDJMGBQKIT6B45567KFV3CYW6PJII2ZLW7CXNEJAC
}
}
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)
// 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)
}
}