diff options
| author | Yotam Ofek <yotam.ofek@gmail.com> | 2025-01-26 16:25:47 +0000 |
|---|---|---|
| committer | Yotam Ofek <yotam.ofek@gmail.com> | 2025-01-26 16:26:52 +0000 |
| commit | 614446887ea4e5708f85dac9db008b4f3a20f004 (patch) | |
| tree | cedf3d83d154efbada91c8b48b24ec9c096ad8bc /compiler/rustc_ast/src/util | |
| parent | 15c6f7e1a3a0e51c9b18ce5b9a391e0c324b751c (diff) | |
rustc_ast: replace some len-checks + indexing with slice patterns etc. 🧹
Diffstat (limited to 'compiler/rustc_ast/src/util')
| -rw-r--r-- | compiler/rustc_ast/src/util/comments.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/compiler/rustc_ast/src/util/comments.rs b/compiler/rustc_ast/src/util/comments.rs index f39142f08ba..e12818623d8 100644 --- a/compiler/rustc_ast/src/util/comments.rs +++ b/compiler/rustc_ast/src/util/comments.rs @@ -39,7 +39,7 @@ pub fn beautify_doc_string(data: Symbol, kind: CommentKind) -> Symbol { let mut i = 0; let mut j = lines.len(); // first line of all-stars should be omitted - if !lines.is_empty() && lines[0].chars().all(|c| c == '*') { + if lines.first().is_some_and(|line| line.chars().all(|c| c == '*')) { i += 1; } @@ -97,7 +97,7 @@ pub fn beautify_doc_string(data: Symbol, kind: CommentKind) -> Symbol { return None; } } - if lines.is_empty() { None } else { Some(lines[0][..i].into()) } + Some(lines.first()?[..i].to_string()) } let data_s = data.as_str(); |
