diff options
| author | Benoît du Garreau <bdgdlm@outlook.com> | 2021-07-29 19:39:56 +0200 |
|---|---|---|
| committer | Benoît du Garreau <bdgdlm@outlook.com> | 2021-10-01 19:08:13 +0200 |
| commit | fe11483afa90628106971993049b4fd2f0dae6fc (patch) | |
| tree | e5d97e0cba9ae2501e83360b8341f9357aab4652 /library/std/src/io | |
| parent | ed937594d3912ced11f6f35a90bb8bf591909d2a (diff) | |
| download | rust-fe11483afa90628106971993049b4fd2f0dae6fc.tar.gz rust-fe11483afa90628106971993049b4fd2f0dae6fc.zip | |
Add functions to add unsigned and signed integers
Diffstat (limited to 'library/std/src/io')
| -rw-r--r-- | library/std/src/io/cursor.rs | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/library/std/src/io/cursor.rs b/library/std/src/io/cursor.rs index 25cc5e67ad1..980b2531192 100644 --- a/library/std/src/io/cursor.rs +++ b/library/std/src/io/cursor.rs @@ -292,12 +292,7 @@ where SeekFrom::End(n) => (self.inner.as_ref().len() as u64, n), SeekFrom::Current(n) => (self.pos, n), }; - let new_pos = if offset >= 0 { - base_pos.checked_add(offset as u64) - } else { - base_pos.checked_sub((offset.wrapping_neg()) as u64) - }; - match new_pos { + match base_pos.checked_add_signed(offset) { Some(n) => { self.pos = n; Ok(self.pos) |
