From 7b594354cf0f7919be6975ac73f0ada9ed54aeee Mon Sep 17 00:00:00 2001 From: Nathaniel Cook Date: Mon, 30 Oct 2023 10:17:54 -0600 Subject: [PATCH] subcriber: update docs for EnvFilter Builder (#2782) The `from_env` and `try_from_env` methods on the builder had the same documentation. This change updates their docs to correctly describe their difference in behavior. ## Motivation Make the docs more clear, so that users need not look at the source to understand the difference between these two functions. ## Solution Updated the docs Co-authored-by: Eliza Weisman --- tracing-subscriber/src/filter/env/builder.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tracing-subscriber/src/filter/env/builder.rs b/tracing-subscriber/src/filter/env/builder.rs index 8572647412..8afe117c51 100644 --- a/tracing-subscriber/src/filter/env/builder.rs +++ b/tracing-subscriber/src/filter/env/builder.rs @@ -170,15 +170,16 @@ impl Builder { self.parse_lossy(var) } - /// Returns a new [`EnvFilter`] from the directives in the in the configured - /// environment variable, or an error if the environment variable is not set - /// or contains invalid directives. + /// Returns a new [`EnvFilter`] from the directives in the configured + /// environment variable. If the environment variable is unset, no directive is added. + /// + /// An error is returned if the environment contains invalid directives. pub fn from_env(&self) -> Result { let var = env::var(self.env_var_name()).unwrap_or_default(); self.parse(var).map_err(Into::into) } - /// Returns a new [`EnvFilter`] from the directives in the in the configured + /// Returns a new [`EnvFilter`] from the directives in the configured /// environment variable, or an error if the environment variable is not set /// or contains invalid directives. pub fn try_from_env(&self) -> Result {