feat: Adding support for no_std environments for env_filter#378
Open
WolverinDEV wants to merge 2 commits intorust-cli:mainfrom
Open
feat: Adding support for no_std environments for env_filter#378WolverinDEV wants to merge 2 commits intorust-cli:mainfrom
no_std environments for env_filter#378WolverinDEV wants to merge 2 commits intorust-cli:mainfrom
Conversation
Signed-off-by: WolverinDEV <git@did.science>
epage
reviewed
Aug 22, 2025
Comment on lines
+61
to
+62
| #[cfg(not(feature = "std"))] | ||
| impl core::error::Error for ParseError {} |
Contributor
There was a problem hiding this comment.
This makes the lack of std require a higher MSRV
epage
reviewed
Aug 22, 2025
Comment on lines
+29
to
+35
| pub(crate) fn new(spec: &str) -> Result<Self, String> { | ||
| Ok(Self { | ||
| inner: spec.to_string(), | ||
| }) | ||
| } | ||
|
|
||
| pub fn is_match(&self, s: &str) -> bool { | ||
| pub(crate) fn is_match(&self, s: &str) -> bool { |
Contributor
There was a problem hiding this comment.
Can you split this out into a separate commit?
epage
reviewed
Aug 22, 2025
Comment on lines
+1
to
+3
| use alloc::string::{String, ToString}; | ||
|
|
||
| use core::fmt; |
epage
reviewed
Aug 22, 2025
Comment on lines
+1
to
10
| use alloc::borrow::ToOwned; | ||
| use alloc::format; | ||
| use alloc::string::String; | ||
| use alloc::vec::Vec; | ||
|
|
||
| use core::fmt::{Display, Formatter}; | ||
| use log::LevelFilter; | ||
| use std::error::Error; | ||
| use std::fmt::{Display, Formatter}; | ||
|
|
||
| use crate::Directive; | ||
| use crate::FilterOp; |
Contributor
There was a problem hiding this comment.
If we're changing grouping, could you do
use {core,alloc,std}
use third-party
use crate
epage
reviewed
Aug 22, 2025
Comment on lines
+1
to
10
| use alloc::borrow::ToOwned; | ||
| use alloc::string::ToString; | ||
| use alloc::vec::Vec; | ||
|
|
||
| use core::fmt; | ||
| use core::mem; | ||
|
|
||
| use log::{LevelFilter, Metadata, Record}; | ||
|
|
||
| use crate::enabled; |
epage
reviewed
Aug 22, 2025
Comment on lines
+34
to
+35
| log = { version = "0.4.8", default-features = false } | ||
| regex = { version = "1.0.3", optional = true, default-features = false, features = ["std", "perf"] } |
Contributor
There was a problem hiding this comment.
Seems like this belongs in the previous comit, could you move it there?
epage
reviewed
Aug 22, 2025
Contributor
There was a problem hiding this comment.
refactor(filter): Add support for no_std environments
Mind fixing your commit type?
A refactor, by definition, has no user facing changes while this does. I would use feat
Pull Request Test Coverage Report for Build 17143312963Details
💛 - Coveralls |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Using
env_loggerin ano_stdenvironment may not seem useful at first. However, theenv_filtercrate is very convenient for defining complex filters that can then be implemented by a customno_std-compatible logger.This approach leverages the convenience developers are already familiar with from
env_logger, while enabling the same flexibility inno_stdcontexts with other logging backends.