Skip to content

Commit

Permalink
update to rust 1.25 → fmt/clippy
Browse files Browse the repository at this point in the history
- adjust to current rustfmt/clippy
- make `gtmpl_derive` a dev-dependency
  • Loading branch information
fiji-flo committed Mar 29, 2018
1 parent ba9a267 commit 6576674
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 36 deletions.
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "gtmpl"
version = "0.5.0"
version = "0.5.1"
authors = ["Florian Merz <flomerz@gmail.com>"]
description = "The Golang Templating Language for Rust"
license = "MIT"
Expand All @@ -22,4 +22,6 @@ itertools = "0.7"
lazy_static = "1.0"
percent-encoding = "1.0"
gtmpl_value = "0.3"

[dev-dependencies]
gtmpl_derive = "0.3"
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ seamless integration of Rust application into the world of devops tools around
Add the following dependency to your Cargo manifest…
```toml
[dependencies]
gtmpl = "0.5.0"
gtmpl = "0.5.1"
```

and look at the docs:
Expand Down Expand Up @@ -103,7 +103,7 @@ there might be some convenient additions:
Enable `gtmpl_dynamic_template` in your `Cargo.toml`:
```toml
[dependencies.gtmpl]
version = "0.5.0"
version = "0.5.1"
features = ["gtmpl_dynamic_template"]

```
Expand Down
4 changes: 2 additions & 2 deletions src/exec.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use std::io::Write;
use std::collections::VecDeque;
use std::io::Write;

use node::*;
use template::Template;
use utils::is_true;
use node::*;

use gtmpl_value::{Func, Value};

Expand Down
26 changes: 10 additions & 16 deletions src/funcs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use gtmpl_value::{Func, Value};
extern crate percent_encoding;
use self::percent_encoding::{utf8_percent_encode, DEFAULT_ENCODE_SET};

use utils::is_true;
use printf::sprintf;
use utils::is_true;

pub static BUILTINS: &[(&'static str, Func)] = &[
("eq", eq as Func),
Expand Down Expand Up @@ -543,20 +543,16 @@ mod tests_mocked {

#[test]
fn test_macro() {
gtmpl_fn!(
fn f1(i: i64) -> Result<i64, String> {
Ok(i + 1)
}
);
gtmpl_fn!(fn f1(i: i64) -> Result<i64, String> {
Ok(i + 1)
});
let vals: Vec<Value> = vec![val!(1i64)];
let ret = f1(&vals);
assert_eq!(ret, Ok(Value::from(2i64)));

gtmpl_fn!(
fn f3(i: i64, j: i64, k: i64) -> Result<i64, String> {
Ok(i +j + k)
}
);
gtmpl_fn!(fn f3(i: i64, j: i64, k: i64) -> Result<i64, String> {
Ok(i + j + k)
});
let vals: Vec<Value> = vec![val!(1i64), val!(2i64), val!(3i64)];
let ret = f3(&vals);
assert_eq!(ret, Ok(Value::from(6i64)));
Expand Down Expand Up @@ -737,11 +733,9 @@ mod tests_mocked {

#[test]
fn test_gtmpl_fn() {
gtmpl_fn!(
fn add(a: u64, b: u64) -> Result<u64, String> {
Ok(a + b)
}
);
gtmpl_fn!(fn add(a: u64, b: u64) -> Result<u64, String> {
Ok(a + b)
});
let vals: Vec<Value> = vec![val!(1u32), val!(2u32)];
let ret = add(&vals);
assert_eq!(ret, Ok(Value::from(3u32)));
Expand Down
2 changes: 1 addition & 1 deletion src/lexer.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::collections::HashMap;
use std::fmt;
use std::thread;
use std::sync::mpsc::{channel, Receiver, Sender};
use std::thread;

type Pos = usize;

Expand Down
16 changes: 6 additions & 10 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,23 @@
//! let output = gtmpl::template("Finally! Some {{ . }} for Rust", "gtmpl");
//! assert_eq!(&output.unwrap(), "Finally! Some gtmpl for Rust");
//! ```
#[cfg_attr(feature = "cargo-clippy", allow(useless_attribute))]
#[allow(unused_imports)]
#[cfg(test)]
#[macro_use]
extern crate gtmpl_derive;
#[cfg_attr(feature = "cargo-clippy", allow(useless_attribute))]
#[allow(unused_imports)]
#[macro_use]
extern crate gtmpl_value;
extern crate itertools;
#[macro_use]
extern crate lazy_static;
mod exec;
#[doc(inlne)]
pub mod funcs;
mod lexer;
mod node;
mod parse;
#[doc(inlne)]
pub mod funcs;
mod template;
mod exec;
mod utils;
mod print_verb;
mod printf;
mod template;
mod utils;

#[doc(inline)]
pub use template::Template;
Expand Down
2 changes: 1 addition & 1 deletion src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -757,8 +757,8 @@ impl Iterator for Parser {
#[cfg(test)]
mod tests_mocked {
use super::*;
use lexer::ItemType;
use gtmpl_value::Value;
use lexer::ItemType;

/*
ItemText
Expand Down
3 changes: 1 addition & 2 deletions src/template.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::collections::HashMap;

use parse::{parse, Tree};
use funcs::BUILTINS;
use gtmpl_value::Func;
use parse::{parse, Tree};

/// The main template structure.
pub struct Template {
Expand Down Expand Up @@ -108,7 +108,6 @@ impl Template {
/// let output = tmpl.render(&Context::from("Hello World").unwrap());
/// assert_eq!(&output.unwrap(), "Hello World!");
/// ```
/// ```
pub fn add_template<N: Into<String>, T: Into<String>>(
&mut self,
name: N,
Expand Down
2 changes: 1 addition & 1 deletion src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::char;
use gtmpl_value::Value;
use std::char;

pub fn unquote_char(s: &str, quote: char) -> Option<char> {
if s.len() < 2 || !s.starts_with(quote) || !s.ends_with(quote) {
Expand Down

0 comments on commit 6576674

Please sign in to comment.