Skip to content

Commit af69ae3

Browse files
Auto-format: cargo fmt --all
1 parent 59718f2 commit af69ae3

File tree

2 files changed

+22
-39
lines changed

2 files changed

+22
-39
lines changed

crates/vm/src/stdlib/codecs.rs

Lines changed: 21 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -791,9 +791,7 @@ mod _codecs_windows {
791791
};
792792

793793
if size <= 0 {
794-
let err_code = std::io::Error::last_os_error()
795-
.raw_os_error()
796-
.unwrap_or(0);
794+
let err_code = std::io::Error::last_os_error().raw_os_error().unwrap_or(0);
797795
if err_code == 1113 {
798796
// ERROR_NO_UNICODE_TRANSLATION
799797
return Ok(None);
@@ -828,9 +826,7 @@ mod _codecs_windows {
828826
};
829827

830828
if result <= 0 {
831-
let err_code = std::io::Error::last_os_error()
832-
.raw_os_error()
833-
.unwrap_or(0);
829+
let err_code = std::io::Error::last_os_error().raw_os_error().unwrap_or(0);
834830
if err_code == 1113 {
835831
return Ok(None);
836832
}
@@ -917,11 +913,7 @@ mod _codecs_windows {
917913
let mut output = Vec::new();
918914

919915
// Collect code points for random access
920-
let code_points: Vec<u32> = s
921-
.as_wtf8()
922-
.code_points()
923-
.map(|cp| cp.to_u32())
924-
.collect();
916+
let code_points: Vec<u32> = s.as_wtf8().code_points().map(|cp| cp.to_u32()).collect();
925917

926918
let mut pos = 0usize;
927919
while pos < code_points.len() {
@@ -1111,9 +1103,7 @@ mod _codecs_windows {
11111103
}
11121104
}
11131105

1114-
let err_code = std::io::Error::last_os_error()
1115-
.raw_os_error()
1116-
.unwrap_or(0);
1106+
let err_code = std::io::Error::last_os_error().raw_os_error().unwrap_or(0);
11171107
// ERROR_INVALID_FLAGS = 1004
11181108
if flags != 0 && err_code == 1004 {
11191109
flags = 0;
@@ -1143,9 +1133,9 @@ mod _codecs_windows {
11431133

11441134
let len = data.len();
11451135
let encoding_str = vm.ctx.new_str(encoding_name);
1146-
let reason_str = vm.ctx.new_str(
1147-
"No mapping for the Unicode character exists in the target code page.",
1148-
);
1136+
let reason_str = vm
1137+
.ctx
1138+
.new_str("No mapping for the Unicode character exists in the target code page.");
11491139

11501140
// For strict+final, find the failing position and raise
11511141
if errors == "strict" && is_final {
@@ -1172,9 +1162,7 @@ mod _codecs_windows {
11721162
found = true;
11731163
break;
11741164
}
1175-
let err_code = std::io::Error::last_os_error()
1176-
.raw_os_error()
1177-
.unwrap_or(0);
1165+
let err_code = std::io::Error::last_os_error().raw_os_error().unwrap_or(0);
11781166
if err_code == 1004 && flags_s != 0 {
11791167
flags_s = 0;
11801168
continue;
@@ -1230,9 +1218,7 @@ mod _codecs_windows {
12301218
if outsize > 0 {
12311219
break;
12321220
}
1233-
let err_code = std::io::Error::last_os_error()
1234-
.raw_os_error()
1235-
.unwrap_or(0);
1221+
let err_code = std::io::Error::last_os_error().raw_os_error().unwrap_or(0);
12361222
if err_code == 1004 && flags != 0 {
12371223
// ERROR_INVALID_FLAGS - retry with flags=0
12381224
flags = 0;
@@ -1300,31 +1286,30 @@ mod _codecs_windows {
13001286
let handler = error_handler.as_ref().unwrap();
13011287
let res = handler.call((exc,), vm)?;
13021288
let tuple_err = || {
1303-
vm.new_type_error(
1304-
"decoding error handler must return (str, int) tuple",
1305-
)
1289+
vm.new_type_error("decoding error handler must return (str, int) tuple")
13061290
};
1307-
let tuple: &PyTuple =
1308-
res.downcast_ref().ok_or_else(&tuple_err)?;
1291+
let tuple: &PyTuple = res.downcast_ref().ok_or_else(&tuple_err)?;
13091292
let tuple_slice = tuple.as_slice();
13101293
if tuple_slice.len() != 2 {
13111294
return Err(tuple_err());
13121295
}
13131296

1314-
let replacement: PyStrRef =
1315-
tuple_slice[0].clone().try_into_value(vm).map_err(|_| tuple_err())?;
1316-
let new_pos: isize =
1317-
tuple_slice[1].clone().try_into_value(vm).map_err(|_| tuple_err())?;
1297+
let replacement: PyStrRef = tuple_slice[0]
1298+
.clone()
1299+
.try_into_value(vm)
1300+
.map_err(|_| tuple_err())?;
1301+
let new_pos: isize = tuple_slice[1]
1302+
.clone()
1303+
.try_into_value(vm)
1304+
.map_err(|_| tuple_err())?;
13181305

13191306
for cp in replacement.as_wtf8().code_points() {
13201307
let u = cp.to_u32();
13211308
if u < 0x10000 {
13221309
wide_buf.push(u as u16);
13231310
} else {
1324-
wide_buf
1325-
.push(((u - 0x10000) >> 10) as u16 + 0xD800);
1326-
wide_buf
1327-
.push(((u - 0x10000) & 0x3FF) as u16 + 0xDC00);
1311+
wide_buf.push(((u - 0x10000) >> 10) as u16 + 0xD800);
1312+
wide_buf.push(((u - 0x10000) & 0x3FF) as u16 + 0xDC00);
13281313
}
13291314
}
13301315

crates/vm/src/stdlib/io.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5346,9 +5346,7 @@ mod fileio {
53465346
if let Err(err) = fd_fstat {
53475347
// If the fd is invalid, prevent destructor from trying to close it
53485348
if err.raw_os_error()
5349-
== Some(
5350-
windows_sys::Win32::Foundation::ERROR_INVALID_HANDLE as i32,
5351-
)
5349+
== Some(windows_sys::Win32::Foundation::ERROR_INVALID_HANDLE as i32)
53525350
{
53535351
zelf.fd.store(-1);
53545352
}

0 commit comments

Comments
 (0)