Skip to content
This repository was archived by the owner on Oct 23, 2025. It is now read-only.

Commit 633cc6c

Browse files
committed
Upgrade to 2018 edition
1 parent 6973e15 commit 633cc6c

File tree

12 files changed

+38
-54
lines changed

12 files changed

+38
-54
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ description = "A Rust create for outputting information and log messages for hum
66
license = "Apache-2.0 OR MIT"
77
readme = "README.md"
88
repository = "https://github.com/killercup/convey"
9+
edition = "2018"
910

1011
[workspace]
1112
members = [

examples/cli.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
extern crate failure;
2-
extern crate structopt;
1+
use failure;
2+
use structopt;
33
#[macro_use]
44
extern crate serde_derive;
55
#[macro_use]

examples/concurrent.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
extern crate convey;
2-
extern crate failure;
3-
extern crate rand;
1+
use convey;
2+
use failure;
43

54
use convey::{human, json};
65
use rand::{thread_rng, Rng};
@@ -14,7 +13,7 @@ fn main() -> Result<(), failure::Error> {
1413

1514
let mut threads = vec![];
1615
for i in 0..100 {
17-
let mut out = out.clone();
16+
let out = out.clone();
1817
let t = thread::spawn(move || {
1918
let dur = Duration::from_millis(thread_rng().gen_range(0u64, 1));
2019
thread::sleep(dur);

examples/custom.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
extern crate failure;
1+
use failure;
22
#[macro_use]
33
extern crate convey;
44
#[macro_use]

examples/derive.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
extern crate convey;
2-
extern crate failure;
1+
use convey;
2+
use failure;
33
#[macro_use]
44
extern crate convey_derive;
55
#[macro_use]

src/components/span.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
use crate::{human, json, Error, Render};
12
use termcolor::ColorSpec;
2-
use {human, json, Error, Render};
33

44
/// Construct a new, empty span
55
pub fn span() -> Span {
@@ -54,7 +54,7 @@ macro_rules! span {
5454

5555
#[derive(Default)]
5656
pub struct Span {
57-
items: Vec<Box<Render>>,
57+
items: Vec<Box<dyn Render>>,
5858
fg: Option<::termcolor::Color>,
5959
bg: Option<::termcolor::Color>,
6060
bold: bool,
@@ -126,8 +126,8 @@ impl Render for Span {
126126
#[cfg(test)]
127127
mod test {
128128
use super::span;
129-
use components::text;
130-
use {human, json, Error, Render};
129+
use crate::components::text;
130+
use crate::{human, json, Error, Render};
131131

132132
#[test]
133133
fn renders_span_children() -> Result<(), Error> {
@@ -149,7 +149,7 @@ mod test {
149149
#[test]
150150
fn test_colored_output() -> Result<(), Error> {
151151
let test_target = human::test_with_color();
152-
let out = ::new().add_target(test_target.target())?;
152+
let out = crate::new().add_target(test_target.target())?;
153153

154154
out.print(span().add_item("hello").fg("green")?.bg("blue")?)?;
155155
out.flush()?;
@@ -164,7 +164,7 @@ mod test {
164164
#[test]
165165
fn test_bold_output() -> Result<(), Error> {
166166
let test_target = human::test_with_color();
167-
let out = ::new().add_target(test_target.target())?;
167+
let out = crate::new().add_target(test_target.target())?;
168168

169169
out.print(span().add_item("hello").bold(true)?)?;
170170
out.flush()?;
@@ -179,7 +179,7 @@ mod test {
179179
#[test]
180180
fn test_intense_output() -> Result<(), Error> {
181181
let test_target = human::test_with_color();
182-
let out = ::new().add_target(test_target.target())?;
182+
let out = crate::new().add_target(test_target.target())?;
183183

184184
out.print(span().add_item("hello").fg("green")?.intense(true)?)?;
185185
out.flush()?;
@@ -194,7 +194,7 @@ mod test {
194194
#[test]
195195
fn test_underline_output() -> Result<(), Error> {
196196
let test_target = human::test_with_color();
197-
let out = ::new().add_target(test_target.target())?;
197+
let out = crate::new().add_target(test_target.target())?;
198198

199199
out.print(span().add_item("hello").underline(true)?)?;
200200
out.flush()?;

src/components/text.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use {human, json, Error, Render};
1+
use crate::{human, json, Error, Render};
22

33
/// Render some text
44
pub fn text<T: AsRef<str>>(input: T) -> Text {
@@ -12,7 +12,7 @@ pub fn newline() -> Text {
1212
text("\n")
1313
}
1414

15-
#[derive(Clone, Serialize)]
15+
#[derive(Clone, serde_derive::Serialize)]
1616
pub struct Text(String);
1717

1818
impl Render for Text {
@@ -30,7 +30,8 @@ impl Render for Text {
3030
#[cfg(test)]
3131
mod test {
3232
use super::text;
33-
use {human, json, Render};
33+
use crate::{human, json, Render};
34+
use proptest::{prop_assert, prop_assert_eq, proptest, proptest_helper};
3435

3536
proptest! {
3637
#[test]
@@ -43,7 +44,7 @@ mod test {
4344

4445
let json = json::test();
4546
item.render_json(&mut json.formatter()).unwrap();
46-
prop_assert_eq!(json.to_string(), json!(s).to_string());
47+
prop_assert_eq!(json.to_string(), serde_json::json!(s).to_string());
4748
}
4849
}
4950
}

src/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub struct Error {
1212
}
1313

1414
impl Fail for Error {
15-
fn cause(&self) -> Option<&Fail> {
15+
fn cause(&self) -> Option<&dyn Fail> {
1616
self.inner.cause()
1717
}
1818

@@ -22,7 +22,7 @@ impl Fail for Error {
2222
}
2323

2424
impl Display for Error {
25-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
25+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2626
Display::fmt(&self.inner, f)
2727
}
2828
}

src/human.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
//! Human output
22
3+
use crate::{Error, Target};
34
use std::sync::Arc;
45
use termcolor::{ColorChoice, ColorSpec, StandardStream, WriteColor};
5-
use {Error, Target};
66

77
/// Construct a new human output target that writes to stdout
88
pub fn stdout() -> Result<Target, Error> {
@@ -215,8 +215,8 @@ macro_rules! render_for_humans {
215215

216216
mod test_helper {
217217
use super::Formatter;
218+
use crate::{test_buffer::TestBuffer, Target};
218219
use termcolor::Buffer;
219-
use {test_buffer::TestBuffer, Target};
220220

221221
/// Create a test output target
222222
///

src/json.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
//! JSON output
22
3+
use crate::{Error, Target};
34
use serde::Serialize;
45
use serde_json::to_vec as write_json;
56
use std::io::Write;
67
use std::path::Path;
78
use std::sync::Arc;
8-
use {Error, Target};
99

1010
/// Construct a new JSON output target that writes to stdout
1111
pub fn stdout() -> Result<Target, Error> {
@@ -216,9 +216,9 @@ macro_rules! render_json {
216216

217217
mod test_helper {
218218
use super::Formatter;
219+
use crate::test_buffer::TestBuffer;
220+
use crate::Target;
219221
use termcolor::Buffer;
220-
use test_buffer::TestBuffer;
221-
use Target;
222222

223223
/// Create a test output target
224224
///
@@ -285,9 +285,9 @@ mod test_helper {
285285

286286
#[cfg(test)]
287287
mod tests {
288+
use crate::json;
288289
use assert_fs::prelude::*;
289290
use assert_fs::TempDir;
290-
use json;
291291
use predicates::prelude::*;
292292

293293
type Res = Result<(), ::failure::Error>;
@@ -341,7 +341,7 @@ mod tests {
341341
log_file.assert(predicate::path::exists());
342342

343343
let target = json::file(log_file.path())?;
344-
let output = ::new().add_target(target)?;
344+
let output = crate::new().add_target(target)?;
345345
output.print("wtf")?;
346346
output.flush()?;
347347

0 commit comments

Comments
 (0)