Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply new clippy lint fixes #375

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions fluent-bundle/examples/custom_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ enum DateTimeStyleValue {

// This is just a helper to make it easier to convert
// a value provided to FluentArgs into an option value.
impl<'l> From<&FluentValue<'l>> for DateTimeStyleValue {
impl From<&FluentValue<'_>> for DateTimeStyleValue {
fn from(input: &FluentValue) -> Self {
if let FluentValue::String(s) = input {
match s.as_ref() {
Expand Down Expand Up @@ -73,7 +73,7 @@ impl DateTimeOptions {
}
}

impl<'l> From<&FluentArgs<'l>> for DateTimeOptions {
impl From<&FluentArgs<'_>> for DateTimeOptions {
fn from(input: &FluentArgs) -> Self {
let mut opts = Self::default();
opts.merge(input);
Expand Down
4 changes: 2 additions & 2 deletions fluent-bundle/examples/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ fn main() {
// Test for a function that accepts named arguments
bundle
.add_function("BASE_OWNERSHIP", |_args, named_args| {
return match named_args.get("ownership") {
match named_args.get("ownership") {
Some(FluentValue::String(ref string)) => {
format!("All your base belong to {}", string).into()
}
_ => FluentValue::Error,
};
}
})
.expect("Failed to add a function to the bundle.");

Expand Down
6 changes: 3 additions & 3 deletions fluent-bundle/src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ pub enum FluentValue<'source> {
Error,
}

impl<'s> PartialEq for FluentValue<'s> {
impl PartialEq for FluentValue<'_> {
fn eq(&self, other: &Self) -> bool {
match (self, other) {
(FluentValue::String(s), FluentValue::String(s2)) => s == s2,
Expand All @@ -95,7 +95,7 @@ impl<'s> PartialEq for FluentValue<'s> {
}
}

impl<'s> Clone for FluentValue<'s> {
impl Clone for FluentValue<'_> {
fn clone(&self) -> Self {
match self {
FluentValue::String(s) => FluentValue::String(s.clone()),
Expand Down Expand Up @@ -291,7 +291,7 @@ impl<'source> FluentValue<'source> {
}
}

impl<'source> From<String> for FluentValue<'source> {
impl From<String> for FluentValue<'_> {
fn from(s: String) -> Self {
FluentValue::String(s.into())
}
Expand Down
8 changes: 2 additions & 6 deletions fluent-bundle/src/types/number.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,7 @@ impl FluentNumber {
if let Some(minfd) = self.options.minimum_fraction_digits {
if let Some(pos) = val.find('.') {
let frac_num = val.len() - pos - 1;
let missing = if frac_num > minfd {
0
} else {
minfd - frac_num
};
let missing = minfd.saturating_sub(frac_num);
val = format!("{}{}", val, "0".repeat(missing));
} else {
val = format!("{}.{}", val, "0".repeat(minfd));
Expand All @@ -179,7 +175,7 @@ impl FromStr for FluentNumber {
}
}

impl<'l> From<FluentNumber> for FluentValue<'l> {
impl From<FluentNumber> for FluentValue<'_> {
fn from(input: FluentNumber) -> Self {
FluentValue::Number(input)
}
Expand Down
4 changes: 2 additions & 2 deletions fluent-bundle/tests/custom_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ fn fluent_date_time_builtin() {
None,
}

impl<'l> From<&FluentValue<'l>> for DateTimeStyleValue {
impl From<&FluentValue<'_>> for DateTimeStyleValue {
fn from(input: &FluentValue) -> Self {
if let FluentValue::String(s) = input {
match s.as_ref() {
Expand Down Expand Up @@ -91,7 +91,7 @@ fn fluent_date_time_builtin() {
}
}

impl<'l> From<&FluentArgs<'l>> for DateTimeOptions {
impl From<&FluentArgs<'_>> for DateTimeOptions {
fn from(input: &FluentArgs) -> Self {
let mut opts = Self::default();
opts.merge(input);
Expand Down
2 changes: 1 addition & 1 deletion fluent-syntax/src/parser/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub trait Slice<'s>: AsRef<str> + Clone + PartialEq {
fn trim(&mut self);
}

impl<'s> Slice<'s> for String {
impl Slice<'_> for String {
fn slice(&self, range: Range<usize>) -> Self {
self[range].to_string()
}
Expand Down
Loading