Skip to content

Commit a0932a9

Browse files
committed
refactor: Apply fix for get_first lint
1 parent 6e656fb commit a0932a9

File tree

11 files changed

+14
-14
lines changed

11 files changed

+14
-14
lines changed

fluent-bundle/examples/custom_formatter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ key-var-with-arg = Here is a variable formatted with an argument { NUMBER($num,
3636
.expect("Failed to add FTL resources to the bundle.");
3737
bundle
3838
.add_function("NUMBER", |positional, named| {
39-
match positional.get(0) {
39+
match positional.first() {
4040
Some(FluentValue::Number(n)) => {
4141
let mut num = n.clone();
4242
// This allows us to merge the arguments provided

fluent-bundle/examples/custom_type.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ key-date = Today is { DATETIME($epoch, dateStyle: "long", timeStyle: "short") }
165165
.expect("Failed to add FTL resources to the bundle.");
166166

167167
bundle
168-
.add_function("DATETIME", |positional, named| match positional.get(0) {
168+
.add_function("DATETIME", |positional, named| match positional.first() {
169169
Some(FluentValue::Number(n)) => {
170170
let epoch = n.value as usize;
171171
let options = named.into();

fluent-bundle/examples/functions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ fn main() {
2222
// Test for a function that accepts unnamed positional arguments
2323
bundle
2424
.add_function("MEANING_OF_LIFE", |args, _named_args| {
25-
if let Some(arg0) = args.get(0) {
25+
if let Some(arg0) = args.first() {
2626
if *arg0 == 42.into() {
2727
return "The answer to life, the universe, and everything".into();
2828
}

fluent-bundle/examples/simple-app.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ fn main() {
9595
NegotiationStrategy::Filtering,
9696
);
9797
let current_locale = resolved_locales
98-
.get(0)
98+
.first()
9999
.cloned()
100100
.expect("At least one locale should match.");
101101

fluent-bundle/src/bundle.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ impl<R> FluentBundle<R, IntlLangMemoizer> {
577577
///
578578
/// This will panic if no formatters can be found for the locales.
579579
pub fn new(locales: Vec<LanguageIdentifier>) -> Self {
580-
let first_locale = locales.get(0).cloned().unwrap_or_default();
580+
let first_locale = locales.first().cloned().unwrap_or_default();
581581
Self {
582582
locales,
583583
resources: vec![],

fluent-bundle/src/concurrent.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ impl<R> FluentBundle<R> {
3030
/// FluentBundle::new_concurrent(vec![langid_en]);
3131
/// ```
3232
pub fn new_concurrent(locales: Vec<LanguageIdentifier>) -> Self {
33-
let first_locale = locales.get(0).cloned().unwrap_or_default();
33+
let first_locale = locales.first().cloned().unwrap_or_default();
3434
Self {
3535
locales,
3636
resources: vec![],

fluent-bundle/tests/custom_types.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ key-ref = Hello { DATETIME($date, dateStyle: "full") } World
146146
bundle.set_use_isolating(false);
147147

148148
bundle
149-
.add_function("DATETIME", |positional, named| match positional.get(0) {
149+
.add_function("DATETIME", |positional, named| match positional.first() {
150150
Some(FluentValue::Custom(custom)) => {
151151
if let Some(that) = custom.as_ref().as_any().downcast_ref::<DateTime>() {
152152
let mut dt = that.clone();
@@ -202,7 +202,7 @@ key-num-explicit = Hello { NUMBER(5, minimumFractionDigits: 2) } World
202202
bundle.set_use_isolating(false);
203203

204204
bundle
205-
.add_function("NUMBER", |positional, named| match positional.get(0) {
205+
.add_function("NUMBER", |positional, named| match positional.first() {
206206
Some(FluentValue::Number(n)) => {
207207
let mut num = n.clone();
208208
num.options.merge(named);

fluent-bundle/tests/function.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ liked-count2 = { NUMBER($num) ->
2424
let mut bundle = FluentBundle::default();
2525

2626
bundle
27-
.add_function("NUMBER", |positional, named| match positional.get(0) {
27+
.add_function("NUMBER", |positional, named| match positional.first() {
2828
Some(FluentValue::Number(n)) => {
2929
let mut num = n.clone();
3030
num.options.merge(named);

fluent-bundle/tests/resolver_fixtures.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,10 @@ fn create_bundle(
155155
.into()
156156
}),
157157
"IDENTITY" => bundle.add_function(f.as_str(), |args, _name_args| {
158-
args.get(0).cloned().unwrap_or(FluentValue::Error)
158+
args.first().cloned().unwrap_or(FluentValue::Error)
159159
}),
160160
"NUMBER" => bundle.add_function(f.as_str(), |args, _name_args| {
161-
args.get(0).expect("Argument must be passed").clone()
161+
args.first().expect("Argument must be passed").clone()
162162
}),
163163
_ => unimplemented!("No such function."),
164164
};

fluent-fallback/tests/localization_test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ fn localization_format_missing_argument_error() {
454454

455455
let msgs = bundles.format_messages_sync(&keys, &mut errors).unwrap();
456456
assert_eq!(
457-
msgs.get(0).unwrap().as_ref().unwrap().value,
457+
msgs.first().unwrap().as_ref().unwrap().value,
458458
Some(Cow::Borrowed("Hello, John. [en]"))
459459
);
460460
assert_eq!(errors.len(), 0);
@@ -465,7 +465,7 @@ fn localization_format_missing_argument_error() {
465465
}];
466466
let msgs = bundles.format_messages_sync(&keys, &mut errors).unwrap();
467467
assert_eq!(
468-
msgs.get(0).unwrap().as_ref().unwrap().value,
468+
msgs.first().unwrap().as_ref().unwrap().value,
469469
Some(Cow::Borrowed("Hello, {$userName}. [en]"))
470470
);
471471
assert_eq!(

0 commit comments

Comments
 (0)