Skip to content

Commit 5b5ec10

Browse files
committed
Delete no_try_from config for rustc older than 1.34
1 parent 673f460 commit 5b5ec10

File tree

2 files changed

+1
-19
lines changed

2 files changed

+1
-19
lines changed

build.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,6 @@ fn main() {
5858
println!("cargo:rustc-cfg=span_locations");
5959
}
6060

61-
if version.minor < 34 {
62-
println!("cargo:rustc-cfg=no_try_from");
63-
}
64-
6561
if version.minor < 39 {
6662
println!("cargo:rustc-cfg=no_bind_by_move_pattern_guard");
6763
}

src/convert.rs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,3 @@
11
pub(crate) fn usize_to_u32(u: usize) -> Option<u32> {
2-
#[cfg(not(no_try_from))]
3-
{
4-
u32::try_from(u).ok()
5-
}
6-
7-
#[cfg(no_try_from)]
8-
{
9-
use core::mem;
10-
11-
if mem::size_of::<usize>() <= mem::size_of::<u32>() || u <= u32::max_value() as usize {
12-
Some(u as u32)
13-
} else {
14-
None
15-
}
16-
}
2+
u32::try_from(u).ok()
173
}

0 commit comments

Comments
 (0)