ok/jj
1
0
Fork 0
forked from mirrors/jj

Remove superfluous lifetime from Ui

This commit is contained in:
Benjamin Saunders 2022-10-18 17:44:10 -07:00 committed by Yuya Nishihara
parent 0a3502453d
commit c046e1c845
2 changed files with 11 additions and 11 deletions

View file

@ -1175,7 +1175,7 @@ pub struct GlobalArgs {
pub color: Option<ColorChoice>,
}
pub fn create_ui() -> (Ui<'static>, Result<(), CommandError>) {
pub fn create_ui() -> (Ui, Result<(), CommandError>) {
// TODO: We need to do some argument parsing here, at least for things like
// --config, and for reading user configs from the repo pointed to by -R.
match read_config() {

View file

@ -24,10 +24,10 @@ use jujutsu_lib::settings::UserSettings;
use crate::formatter::{Formatter, FormatterFactory};
pub struct Ui<'a> {
pub struct Ui {
cwd: PathBuf,
formatter_factory: FormatterFactory,
output_pair: UiOutputPair<'a>,
output_pair: UiOutputPair,
settings: UserSettings,
}
@ -74,14 +74,14 @@ fn use_color(choice: ColorChoice, maybe_tty: bool) -> bool {
}
}
impl<'stdout> Ui<'stdout> {
impl Ui {
pub fn new(
cwd: PathBuf,
stdout: Box<dyn Write + 'stdout>,
stderr: Box<dyn Write + 'stdout>,
stdout: Box<dyn Write>,
stderr: Box<dyn Write>,
color: bool,
settings: UserSettings,
) -> Ui<'stdout> {
) -> Ui {
let formatter_factory = FormatterFactory::prepare(&settings, color);
Ui {
cwd,
@ -94,7 +94,7 @@ impl<'stdout> Ui<'stdout> {
}
}
pub fn for_terminal(settings: UserSettings) -> Ui<'static> {
pub fn for_terminal(settings: UserSettings) -> Ui {
let cwd = std::env::current_dir().unwrap();
let color = use_color(color_setting(&settings), true);
let formatter_factory = FormatterFactory::prepare(&settings, color);
@ -227,10 +227,10 @@ impl<'stdout> Ui<'stdout> {
}
}
enum UiOutputPair<'output> {
enum UiOutputPair {
Dyn {
stdout: Mutex<Box<dyn Write + 'output>>,
stderr: Mutex<Box<dyn Write + 'output>>,
stdout: Mutex<Box<dyn Write>>,
stderr: Mutex<Box<dyn Write>>,
},
Terminal {
stdout: Stdout,