Skip to content

Commit 880cd40

Browse files
committed
chore: Address nightly clippy lints double_ended_iterator_last and len_zero
1 parent c6dc4a9 commit 880cd40

File tree

8 files changed

+10
-10
lines changed

8 files changed

+10
-10
lines changed

core/src/avm1/globals/file_reference.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ pub fn download<'gc>(
333333
Some(file_name) => file_name.coerce_to_string(activation)?.to_string(),
334334
None => {
335335
// Try to get the end of the path as a file name, if we can't bail and return false
336-
match url.path().split('/').last() {
336+
match url.path().split('/').next_back() {
337337
Some(path_end) => path_end.to_string(),
338338
None => return Ok(false.into()),
339339
}

core/src/avm1/globals/shared_object.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ fn new_lso<'gc>(activation: &mut Activation<'_, 'gc>, name: &str, data: Object<'
272272
w.commit_lso(
273273
&name
274274
.split('/')
275-
.last()
275+
.next_back()
276276
.map(|e| e.to_string())
277277
.unwrap_or_else(|| "<unknown>".to_string()),
278278
)

core/src/avm2/globals/flash/net/shared_object.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ fn new_lso<'gc>(
2525
Ok(Lso::new(
2626
elements,
2727
name.split('/')
28-
.last()
28+
.next_back()
2929
.map(|e| e.to_string())
3030
.unwrap_or_else(|| "<unknown>".to_string()),
3131
AMFVersion::AMF3,

core/src/avm2/globals/xml_list.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ pub fn normalize<'gc>(
548548
)?;
549549
}
550550

551-
text.len() == 0
551+
text.is_empty()
552552
};
553553

554554
// ii. If list[i].[[Value]].length == 0

core/src/debug_ui/movie.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ pub fn open_character_button(ui: &mut Ui, character: &Character) {
277277
fn save_swf(movie: &Arc<SwfMovie>, messages: &mut Vec<Message>) {
278278
let suggested_name = if let Ok(url) = Url::parse(movie.url()) {
279279
url.path_segments()
280-
.and_then(|segments| segments.last())
280+
.and_then(|mut segments| segments.next_back())
281281
.map(|str| str.to_string())
282282
} else {
283283
None

core/src/html/layout.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1393,11 +1393,11 @@ impl<'gc> LayoutBox<'gc> {
13931393
LayoutContent::Text {
13941394
text_format: TextFormat { url: Some(url), .. },
13951395
..
1396-
} => url.len() > 0,
1396+
} => !url.is_empty(),
13971397
LayoutContent::Bullet {
13981398
text_format: TextFormat { url: Some(url), .. },
13991399
..
1400-
} => url.len() > 0,
1400+
} => !url.is_empty(),
14011401
_ => false,
14021402
}
14031403
}

core/src/html/text_format.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -867,8 +867,8 @@ impl FormatSpans {
867867
tag @ b"li" => {
868868
format = apply_style(style_sheet, format, WStr::from_units(tag));
869869

870-
let is_last_nl = text.iter().last() == Some(HTML_NEWLINE);
871-
if is_multiline && !is_last_nl && text.len() > 0 {
870+
let is_last_nl = text.iter().next_back() == Some(HTML_NEWLINE);
871+
if is_multiline && !is_last_nl && !text.is_empty() {
872872
// If the last paragraph was not closed and
873873
// there was some text since then,
874874
// we need to close it here.

frontend-utils/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub static INVALID_URL: &str = "invalid:///";
1616
pub fn url_to_readable_name(url: &Url) -> Cow<'_, str> {
1717
let name = url
1818
.path_segments()
19-
.and_then(|segments| segments.last())
19+
.and_then(|mut segments| segments.next_back())
2020
.unwrap_or_else(|| url.as_str());
2121

2222
urlencoding::decode(name).unwrap_or(Cow::Borrowed(name))

0 commit comments

Comments
 (0)