Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pull in fewer dependencies #91

Merged
merged 3 commits into from
Jul 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,4 @@ syn = { version = "1.0", features = ["full"] }
proc-macro2 = { version = "1.0", features = ["span-locations"] }
toml = "0.5"
url = "2.0"
itertools = "0.9"
regex = "1.1"
regex = { version = "1.3", default-features = false, features = ["std", "unicode"] }
23 changes: 22 additions & 1 deletion src/helpers.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,35 @@
use std::fmt::Display;
use std::fs::File;
use std::io::{self, Read};
use std::result;

use itertools::join;
use semver_parser::range::{Op, VersionReq};
use semver_parser::version::Version;

/// The common result type, our errors will be simple strings.
pub type Result<T> = result::Result<T, String>;

fn join<T>(iter: T, sep: &str) -> String
where
T: IntoIterator,
T::Item: Display,
{
let mut buf = String::new();
let mut iter = iter.into_iter();
if let Some(item) = iter.next() {
let item = item.to_string();
buf.push_str(&item);
} else {
return buf;
}
for item in iter {
buf.push_str(sep);
let item = item.to_string();
buf.push_str(&item);
}
buf
}

/// Return all data from `path`.
pub fn read_file(path: &str) -> io::Result<String> {
let mut file = File::open(path)?;
Expand Down