Closed chris-laplante closed 2 years ago
I also added accessors to ProgressBar
to get the current message/prefix.
I think the accessors should return &str.
I think the accessors should return &str.
The value is behind a Mutex
so I don't think this is possible
So the downside here is that it's no longer possible to pass a &static str
without it allocating a String
for you? Not sure that's a good trade-off... You could just call to_string()
in the caller, right?
So the downside here is that it's no longer possible to pass a
&static str
without it allocating aString
for you? Not sure that's a good trade-off... You could just callto_string()
in the caller, right?
Yes, that is true :(. An alternative would be to introduce a trait that we impl
on both Cow<'static, str>
and console::StyledObject
. (I did initially try to go a similar route, where I attempted to impl
the trait for anything that is impl Into<Cow<'static, str>>
. but I'm not sure Rust lets you express that.)
Hmm, I feel like adding yet another trait isn't really worth it for this. I think impl Into<Cow<'static, str>>
is somewhat of a local optimum, as you can trivially call to_string()
on any impl Display
that you've got and pass that.
Hmm, I feel like adding yet another trait isn't really worth it for this. I think
impl Into<Cow<'static, str>>
is somewhat of a local optimum, as you can trivially callto_string()
on anyimpl Display
that you've got and pass that.
OK, that's fine by me then. I'll close this.
Among other things, by broadening the allowed types it lets you pass a
console::StyledObject
which is convenient.