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

Commit 29e4d65

Browse files
authored
Merge pull request killercup#35 from jcreekmore/std-result-macros
allow the user to type alias Result in their code
2 parents e209947 + 843f5d7 commit 29e4d65

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ script:
1010

1111
matrix:
1212
include:
13-
- rust: 1.31.1
13+
- rust: 1.38.0
1414
env: CLIPPY=YESPLEASE
1515
before_script: rustup component add clippy-preview
1616
script: cargo clippy --all-targets --all -- -D warnings
17-
- rust: 1.31.1
17+
- rust: 1.38.0
1818
env: RUSTFMT=YESPLEASE
1919
before_script: rustup component add rustfmt-preview
2020
script: cargo fmt --all -- --check

src/human.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,12 @@ enum Response {
200200
#[macro_export]
201201
macro_rules! render_for_humans {
202202
($this:ident -> []) => {
203-
fn render_for_humans(&self, fmt: &mut $crate::human::Formatter) -> Result<(), $crate::Error> {
203+
fn render_for_humans(&self, fmt: &mut $crate::human::Formatter) -> ::std::result::Result<(), $crate::Error> {
204204
Ok(())
205205
}
206206
};
207207
($self:ident -> [$($item:expr,)*]) => {
208-
fn render_for_humans(&$self, fmt: &mut $crate::human::Formatter) -> Result<(), $crate::Error> {
208+
fn render_for_humans(&$self, fmt: &mut $crate::human::Formatter) -> ::std::result::Result<(), $crate::Error> {
209209
let span = $crate::span!([ $( $item, )* ]);
210210
span.render_for_humans(fmt)?;
211211
Ok(())
@@ -269,11 +269,13 @@ mod test_helper {
269269
pub fn target(&self) -> Target {
270270
Target::human(self.formatter())
271271
}
272+
}
272273

273-
pub fn to_string(&self) -> String {
274+
impl ::std::fmt::Display for TestTarget {
275+
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> Result<(), ::std::fmt::Error> {
274276
let target = self.buffer.0.clone();
275277
let buffer = target.read().unwrap();
276-
String::from_utf8_lossy(buffer.as_slice()).to_string()
278+
write!(f, "{}", String::from_utf8_lossy(buffer.as_slice()))
277279
}
278280
}
279281
}

src/json.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ enum Response {
212212
#[macro_export]
213213
macro_rules! render_json {
214214
() => {
215-
fn render_json(&self, fmt: &mut $crate::json::Formatter) -> Result<(), $crate::Error> {
215+
fn render_json(&self, fmt: &mut $crate::json::Formatter) -> ::std::result::Result<(), $crate::Error> {
216216
fmt.write(self)?;
217217
Ok(())
218218
}
@@ -279,11 +279,13 @@ mod test_helper {
279279
pub fn target(&self) -> Target {
280280
Target::json(self.formatter())
281281
}
282+
}
282283

283-
pub fn to_string(&self) -> String {
284+
impl ::std::fmt::Display for TestTarget {
285+
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> Result<(), ::std::fmt::Error> {
284286
let target = self.buffer.0.clone();
285287
let buffer = target.read().unwrap();
286-
String::from_utf8_lossy(buffer.as_slice()).to_string()
288+
write!(f, "{}", String::from_utf8_lossy(buffer.as_slice()))
287289
}
288290
}
289291
}

0 commit comments

Comments
 (0)