Skip to content

Commit

Permalink
Rename F to V and make clippy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
Dexterp37 committed Jul 21, 2020
1 parent e58bcc3 commit 27ab281
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions glean-core/src/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ impl DebugOptions {
/// A representation of a debug option,
/// where the value can be set programmatically or come from an environment variable.
#[derive(Debug)]
pub struct DebugOption<T, E = fn(String) -> Option<T>, F = fn(&T) -> bool> {
pub struct DebugOption<T, E = fn(String) -> Option<T>, V = fn(&T) -> bool> {
/// The name of the environment variable related to this debug option.
env: String,
/// The actual value of this option.
Expand All @@ -80,18 +80,18 @@ pub struct DebugOption<T, E = fn(String) -> Option<T>, F = fn(&T) -> bool> {
extraction: E,
/// Optional function to validate the value parsed from the environment
/// or passed to the `set` function.
validation: Option<F>,
validation: Option<V>,
}

impl<T, E, F> DebugOption<T, E, F>
impl<T, E, V> DebugOption<T, E, V>
where
T: Clone,
E: Fn(String) -> Option<T>,
F: Fn(&T) -> bool,
V: Fn(&T) -> bool,
{
/// Create a new debug option,
/// tries to get the initial value of the option from the environment.
pub fn new(env: &str, extraction: E, validation: Option<F>) -> Self {
pub fn new(env: &str, extraction: E, validation: Option<V>) -> Self {
let mut option = Self {
env: env.into(),
value: None,
Expand Down Expand Up @@ -177,6 +177,7 @@ fn tokenize_string(value: String) -> Option<Vec<String>> {
///
/// The regex crate isn't used here because it adds to the binary size,
/// and the Glean SDK doesn't use regular expressions anywhere else.
#[allow(clippy::ptr_arg)]
fn validate_tag(value: &String) -> bool {
if value.is_empty() {
log::error!("A tag must have at least one character.");
Expand Down Expand Up @@ -210,6 +211,7 @@ fn validate_tag(value: &String) -> bool {
///
/// This builds upon the existing `validate_tag` function, since all the
/// tags should respect the same rules to make the pipeline happy.
#[allow(clippy::ptr_arg)]
fn validate_source_tags(tags: &Vec<String>) -> bool {
if tags.is_empty() {
return false;
Expand Down Expand Up @@ -246,6 +248,7 @@ mod test {

#[test]
fn debug_option_is_correctly_validated_when_necessary() {
#[allow(clippy::ptr_arg)]
fn validate(value: &String) -> bool {
value == "test"
}
Expand Down

0 comments on commit 27ab281

Please sign in to comment.