mirror of
https://github.com/notohh/rustlings.git
synced 2024-11-22 14:02:22 -05:00
Avoid allocations on every call to Path::join
This commit is contained in:
parent
51712cc19f
commit
d095a307dd
1 changed files with 4 additions and 10 deletions
|
@ -3,7 +3,7 @@ use glob::glob;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::PathBuf;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
/// Contains the structure of resulting rust-project.json file
|
/// Contains the structure of resulting rust-project.json file
|
||||||
|
@ -45,15 +45,9 @@ impl RustAnalyzerProject {
|
||||||
|
|
||||||
println!("Determined toolchain: {toolchain}\n");
|
println!("Determined toolchain: {toolchain}\n");
|
||||||
|
|
||||||
let Ok(sysroot_src) = Path::new(toolchain)
|
let mut sysroot_src = PathBuf::with_capacity(256);
|
||||||
.join("lib")
|
sysroot_src.extend([toolchain, "lib", "rustlib", "src", "rust", "library"]);
|
||||||
.join("rustlib")
|
let Ok(sysroot_src) = sysroot_src.into_os_string().into_string() else {
|
||||||
.join("src")
|
|
||||||
.join("rust")
|
|
||||||
.join("library")
|
|
||||||
.into_os_string()
|
|
||||||
.into_string()
|
|
||||||
else {
|
|
||||||
bail!("The sysroot path is invalid UTF8");
|
bail!("The sysroot path is invalid UTF8");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue