Skip to content

Commit 7717d25

Browse files
authored
Merge pull request #1724 from sdroege/io-error-other
Use std::io::Error::other() instead of new()
2 parents 7f6712d + e91e135 commit 7717d25

File tree

6 files changed

+457
-15
lines changed

6 files changed

+457
-15
lines changed

cairo/src/surface_png.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,6 @@ impl Surface {
152152

153153
#[cfg(test)]
154154
mod tests {
155-
use std::io::ErrorKind;
156-
157155
use super::*;
158156
use crate::enums::Format;
159157

@@ -162,7 +160,7 @@ mod tests {
162160
// A reader that always returns an error
163161
impl Read for IoErrorReader {
164162
fn read(&mut self, _: &mut [u8]) -> Result<usize, io::Error> {
165-
Err(io::Error::new(ErrorKind::Other, "yikes!"))
163+
Err(io::Error::other("yikes!"))
166164
}
167165
}
168166

gio/src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ impl From<IOErrorEnum> for io::ErrorKind {
3131
pub(crate) fn to_std_io_result<T>(result: Result<T, glib::Error>) -> io::Result<T> {
3232
result.map_err(|g_error| match g_error.kind::<IOErrorEnum>() {
3333
Some(io_error_enum) => io::Error::new(io_error_enum.into(), g_error),
34-
None => io::Error::new(io::ErrorKind::Other, g_error),
34+
None => io::Error::other(g_error),
3535
})
3636
}
3737

gio/src/read_input_stream.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -234,14 +234,11 @@ impl AnyReader {
234234
Ok(res) => res,
235235
Err(panic) => {
236236
self.reader = AnyOrPanic::Panic(panic);
237-
Err(std::io::Error::new(std::io::ErrorKind::Other, "Panicked"))
237+
Err(std::io::Error::other("Panicked"))
238238
}
239239
}
240240
}
241-
AnyOrPanic::Panic(_) => Err(std::io::Error::new(
242-
std::io::ErrorKind::Other,
243-
"Panicked before",
244-
)),
241+
AnyOrPanic::Panic(_) => Err(std::io::Error::other("Panicked before")),
245242
}
246243
}
247244

gio/src/write_output_stream.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -263,14 +263,11 @@ impl AnyWriter {
263263
Ok(res) => res,
264264
Err(panic) => {
265265
self.writer = AnyOrPanic::Panic(panic);
266-
Err(std::io::Error::new(std::io::ErrorKind::Other, "Panicked"))
266+
Err(std::io::Error::other("Panicked"))
267267
}
268268
}
269269
}
270-
AnyOrPanic::Panic(_) => Err(std::io::Error::new(
271-
std::io::ErrorKind::Other,
272-
"Panicked before",
273-
)),
270+
AnyOrPanic::Panic(_) => Err(std::io::Error::other("Panicked before")),
274271
}
275272
}
276273

glib/benches/gstring.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
use criterion::{black_box, criterion_group, criterion_main, Criterion};
1+
use criterion::{criterion_group, criterion_main, Criterion};
22
use glib::IntoGStr;
3+
use std::hint::black_box;
34

45
pub fn str_into_gstr(c: &mut Criterion) {
56
c.bench_function("str as IntoGStr", |b| {

0 commit comments

Comments
 (0)