mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-08-30 23:27:24 +00:00
Use split_once polyfill
This commit is contained in:
parent
239dd506f6
commit
be49547b44
5 changed files with 30 additions and 22 deletions
|
@ -2,7 +2,7 @@
|
|||
//! rust-analyzer database from a single string.
|
||||
|
||||
use rustc_hash::FxHashMap;
|
||||
use stdx::{lines_with_ends, split_delim, trim_indent};
|
||||
use stdx::{lines_with_ends, split_once, trim_indent};
|
||||
|
||||
#[derive(Debug, Eq, PartialEq)]
|
||||
pub struct Fixture {
|
||||
|
@ -71,14 +71,14 @@ impl Fixture {
|
|||
let mut cfg_key_values = Vec::new();
|
||||
let mut env = FxHashMap::default();
|
||||
for component in components[1..].iter() {
|
||||
let (key, value) = split_delim(component, ':').unwrap();
|
||||
let (key, value) = split_once(component, ':').unwrap();
|
||||
match key {
|
||||
"crate" => krate = Some(value.to_string()),
|
||||
"deps" => deps = value.split(',').map(|it| it.to_string()).collect(),
|
||||
"edition" => edition = Some(value.to_string()),
|
||||
"cfg" => {
|
||||
for entry in value.split(',') {
|
||||
match split_delim(entry, '=') {
|
||||
match split_once(entry, '=') {
|
||||
Some((k, v)) => cfg_key_values.push((k.to_string(), v.to_string())),
|
||||
None => cfg_atoms.push(entry.to_string()),
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ impl Fixture {
|
|||
}
|
||||
"env" => {
|
||||
for key in value.split(',') {
|
||||
if let Some((k, v)) = split_delim(key, '=') {
|
||||
if let Some((k, v)) = split_once(key, '=') {
|
||||
env.insert(k.into(), v.into());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue