mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
use strip_prefix() instead of starts_with and slicing (clippy::manual_strip)
This commit is contained in:
parent
3d9b3a8575
commit
8a67116857
4 changed files with 9 additions and 13 deletions
|
@ -154,8 +154,8 @@ fn hide_hash_comments(text: &str) -> String {
|
|||
fn reveal_hash_comments(text: &str) -> String {
|
||||
text.split('\n') // want final newline
|
||||
.map(|it| {
|
||||
if it.starts_with("# ") {
|
||||
&it[2..]
|
||||
if let Some(stripped) = it.strip_prefix("# ") {
|
||||
stripped
|
||||
} else if it == "#" {
|
||||
""
|
||||
} else {
|
||||
|
|
|
@ -60,12 +60,10 @@ fn collect_tests(s: &str) -> Vec<Test> {
|
|||
let mut res = Vec::new();
|
||||
for comment_block in extract_comment_blocks(s) {
|
||||
let first_line = &comment_block[0];
|
||||
let (name, ok) = if first_line.starts_with("test ") {
|
||||
let name = first_line["test ".len()..].to_string();
|
||||
(name, true)
|
||||
} else if first_line.starts_with("test_err ") {
|
||||
let name = first_line["test_err ".len()..].to_string();
|
||||
(name, false)
|
||||
let (name, ok) = if let Some(name) = first_line.strip_prefix("test ") {
|
||||
(name.to_string(), true)
|
||||
} else if let Some(name) = first_line.strip_prefix("test_err ") {
|
||||
(name.to_string(), false)
|
||||
} else {
|
||||
continue;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue