Skip to content

Commit

Permalink
Merge pull request #3 from dgriffen/edition-update
Browse files Browse the repository at this point in the history
update the code to 2018 edition
  • Loading branch information
ZoeyR authored May 8, 2019
2 parents 3e7e661 + 8f76bcb commit fa7932d
Show file tree
Hide file tree
Showing 20 changed files with 29 additions and 70 deletions.
1 change: 1 addition & 0 deletions dotenv/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ readme = "README.md"
keywords = ["environment", "env", "dotenv", "settings", "config"]
license = "MIT"
repository = "https://github.com/dotenv-rs/dotenv"
edition = "2018"

[[bin]]
name = "dotenv"
Expand Down
2 changes: 0 additions & 2 deletions dotenv/examples/simple.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
extern crate dotenv;

use dotenv::dotenv;
use std::env;

Expand Down
1 change: 1 addition & 0 deletions dotenv/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::io;
use failure::Fail;

#[derive(Debug, Fail)]
pub enum Error {
Expand Down
4 changes: 2 additions & 2 deletions dotenv/src/find.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use std::fs::File;
use std::path::{Path, PathBuf};
use std::{env, fs, io};

use errors::*;
use iter::Iter;
use crate::errors::*;
use crate::iter::Iter;

pub struct Finder<'a> {
filename: &'a Path,
Expand Down
4 changes: 2 additions & 2 deletions dotenv/src/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use std::io::prelude::*;
use std::io::{BufReader, Lines};
use std::env;

use errors::*;
use parse;
use crate::errors::*;
use crate::parse;

pub struct Iter<R> {
lines: Lines<BufReader<R>>,
Expand Down
12 changes: 3 additions & 9 deletions dotenv/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@
//! file, if available, and mashes those with the actual environment variables
//! provided by the operating system.
#[macro_use]
extern crate failure;
#[macro_use]
extern crate lazy_static;
extern crate regex;

mod parse;
mod errors;
mod iter;
Expand All @@ -22,9 +16,9 @@ use std::fs::File;
use std::path::{Path, PathBuf};
use std::sync::{Once, ONCE_INIT};

pub use errors::*;
use iter::Iter;
use find::Finder;
pub use crate::errors::*;
use crate::iter::Iter;
use crate::find::Finder;

static START: Once = ONCE_INIT;

Expand Down
9 changes: 5 additions & 4 deletions dotenv/src/parse.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use regex::{Captures, Regex};
use errors::*;
use crate::errors::*;
use lazy_static::lazy_static;

// for readability's sake
pub type ParsedLine = Result<Option<(String, String)>>;
Expand Down Expand Up @@ -31,7 +32,7 @@ pub fn parse_line(line: &str) -> ParsedLine {

match (key, value) {
(Some(k), Some(v)) => {
let parsed_value = try!(parse_value(&v));
let parsed_value = parse_value(&v)?;

Ok(Some((k, parsed_value)))
}
Expand All @@ -48,7 +49,7 @@ pub fn parse_line(line: &str) -> ParsedLine {
})
}

fn named_string(captures: &Captures, name: &str) -> Option<String> {
fn named_string(captures: &Captures<'_>, name: &str) -> Option<String> {
captures
.name(name)
.and_then(|v| Some(v.as_str().to_owned()))
Expand Down Expand Up @@ -140,7 +141,7 @@ fn parse_value(input: &str) -> Result<String> {
mod test {
use super::*;

use iter::Iter;
use crate::iter::Iter;

#[test]
fn test_parse_line_env() {
Expand Down
5 changes: 1 addition & 4 deletions dotenv/tests/test-child-dir.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
extern crate dotenv;
extern crate tempfile;

mod common;

use std::{env, fs};
use dotenv::*;

use common::*;
use crate::common::*;

#[test]
fn test_child_dir() {
Expand Down
5 changes: 1 addition & 4 deletions dotenv/tests/test-default-location.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
extern crate dotenv;
extern crate tempfile;

mod common;

use std::env;
use dotenv::*;

use common::*;
use crate::common::*;

#[test]
fn test_default_location() {
Expand Down
5 changes: 1 addition & 4 deletions dotenv/tests/test-dotenv-iter.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
extern crate dotenv;
extern crate tempfile;

mod common;

use std::env;
use dotenv::*;

use common::*;
use crate::common::*;

#[test]
fn test_dotenv_iter() {
Expand Down
5 changes: 1 addition & 4 deletions dotenv/tests/test-from-filename-iter.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
extern crate dotenv;
extern crate tempfile;

mod common;

use std::env;
use dotenv::*;

use common::*;
use crate::common::*;

#[test]
fn test_from_filename_iter() {
Expand Down
5 changes: 1 addition & 4 deletions dotenv/tests/test-from-filename.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
extern crate dotenv;
extern crate tempfile;

mod common;

use std::env;
use dotenv::*;

use common::*;
use crate::common::*;

#[test]
fn test_from_filename() {
Expand Down
5 changes: 1 addition & 4 deletions dotenv/tests/test-from-path-iter.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
extern crate dotenv;
extern crate tempfile;

mod common;

use std::env;
use dotenv::*;

use common::*;
use crate::common::*;

#[test]
fn test_from_path_iter() {
Expand Down
5 changes: 1 addition & 4 deletions dotenv/tests/test-from-path.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
extern crate dotenv;
extern crate tempfile;

mod common;

use std::env;
use dotenv::*;

use common::*;
use crate::common::*;

#[test]
fn test_from_path() {
Expand Down
5 changes: 1 addition & 4 deletions dotenv/tests/test-var.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
extern crate dotenv;
extern crate tempfile;

mod common;

use std::env;

use dotenv::*;

use common::*;
use crate::common::*;

#[test]
fn test_var() {
Expand Down
5 changes: 1 addition & 4 deletions dotenv/tests/test-vars.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
extern crate dotenv;
extern crate tempfile;

mod common;

use std::collections::HashMap;
use std::env;

use dotenv::*;

use common::*;
use crate::common::*;

#[test]
fn test_vars() {
Expand Down
1 change: 1 addition & 0 deletions dotenv_codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ license = "MIT"
homepage = "https://github.com/dotenv-rs/dotenv"
repository = "https://github.com/dotenv-rs/dotenv"
description = "A `dotenv` implementation for Rust"
edition = "2018"

[dependencies]
dotenv_codegen_implementation = { version = "0.14", path = "../dotenv_codegen_implementation" }
Expand Down
5 changes: 1 addition & 4 deletions dotenv_codegen/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#[macro_use]
extern crate proc_macro_hack;

extern crate dotenv_codegen_implementation;
use proc_macro_hack::proc_macro_hack;

#[proc_macro_hack]
pub use dotenv_codegen_implementation::dotenv;
2 changes: 1 addition & 1 deletion dotenv_codegen_implementation/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ license = "MIT"
homepage = "https://github.com/dotenv-rs/dotenv"
repository = "https://github.com/dotenv-rs/dotenv"
description = "A `dotenv` implementation for Rust"

edition = "2018"

[dependencies]
proc-macro2 = "0.4"
Expand Down
13 changes: 3 additions & 10 deletions dotenv_codegen_implementation/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
#[macro_use]
extern crate proc_macro_hack;
#[macro_use]
extern crate quote;

extern crate dotenv;
extern crate proc_macro;
extern crate proc_macro2;

#[macro_use]
extern crate syn;

use std::env;

use syn::punctuated::Punctuated;
use syn::parse::Parser;
use syn::Token;
use proc_macro::TokenStream;
use proc_macro_hack::proc_macro_hack;
use quote::quote;

#[proc_macro_hack]
pub fn dotenv(input: TokenStream) -> TokenStream {
Expand Down

0 comments on commit fa7932d

Please sign in to comment.