Skip to content

Commit

Permalink
Add use regex::Regex instead of using full path
Browse files Browse the repository at this point in the history
  • Loading branch information
camelid committed Oct 27, 2020
1 parent 7962dfe commit 3c01125
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/cli/rustup_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use std::process::Command;
use std::str::FromStr;

use clap::{App, AppSettings, Arg, ArgGroup, ArgMatches, Shell, SubCommand};
use regex::Regex;

use super::common;
use super::errors::*;
Expand Down Expand Up @@ -1324,7 +1325,7 @@ fn toolchain_remove(cfg: &mut Cfg, m: &ArgMatches<'_>) -> Result<utils::ExitCode
"exactly one regex filter must be supplied"
);

let regex = regex::Regex::from_str(m.values_of("toolchain").unwrap().next().unwrap())
let regex = Regex::from_str(m.values_of("toolchain").unwrap().next().unwrap())
.expect("invalid regex");

for toolchain in cfg.get_toolchains_from_regex(regex)? {
Expand Down
3 changes: 2 additions & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use std::str::FromStr;
use std::sync::Arc;

use pgp::{Deserializable, SignedPublicKey};
use regex::Regex;
use serde::Deserialize;

use crate::dist::download::DownloadCfg;
Expand Down Expand Up @@ -363,7 +364,7 @@ impl Cfg {
Toolchain::from(self, name)
}

pub fn get_toolchains_from_regex(&self, regex: regex::Regex) -> Result<Vec<Toolchain<'_>>> {
pub fn get_toolchains_from_regex(&self, regex: Regex) -> Result<Vec<Toolchain<'_>>> {
Ok(self
.list_toolchains_iter()?
.filter(|toolchain| regex.is_match(toolchain))
Expand Down

0 comments on commit 3c01125

Please sign in to comment.