Why this builder pattern doesn't work? #2261
Answered
by
davidbarsky
frederikhors
asked this question in
Q&A
-
Hi guys, I'm learning Rust and I'm trying to setup use tracing_subscriber;
pub fn init(is_pretty: bool) {
let subscriber = tracing_subscriber::fmt();
if is_pretty {
&subscriber.pretty();
}
subscriber.init();
} But the compiler errors with:
I tried this too: use tracing_subscriber;
pub fn init(is_pretty: bool) {
let mut subscriber = tracing_subscriber::fmt();
if is_pretty {
subscriber = subscriber.pretty();
}
subscriber.init();
} But the compiler errors with:
I asked the same question on SO but apparently no one is able to correctly answer. Can you hep me? |
Beta Was this translation helpful? Give feedback.
Answered by
davidbarsky
Aug 3, 2022
Replies: 1 comment
-
I suggest looking at the documentation here: https://docs.rs/tracing-subscriber/latest/tracing_subscriber/layer/index.html#runtime-configuration-with-layers. This might help a bit. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
davidbarsky
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I suggest looking at the documentation here: https://docs.rs/tracing-subscriber/latest/tracing_subscriber/layer/index.html#runtime-configuration-with-layers. This might help a bit.