Skip to content

Commit d4768e2

Browse files
committed
Make use of usize::from_unchecked in place of static_cast
1 parent 94bbd0b commit d4768e2

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

subspace/containers/__private/slice_iter.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ struct [[sus_trivial_abi]] SliceIter final
7373
::sus::iter::SizeHint size_hint() const noexcept final {
7474
// SAFETY: The constructor checks that end_ - ptr_ is positive and Slice can
7575
// not exceed isize::MAX.
76-
// TODO: Use from_unchecked()
77-
const auto remaining = ::sus::num::usize(static_cast<size_t>(end_ - ptr_));
76+
const auto remaining = ::sus::num::usize::from_unchecked(
77+
::sus::marker::unsafe_fn, end_ - ptr_);
7878
return ::sus::iter::SizeHint(
7979
remaining, ::sus::Option<::sus::num::usize>::some(remaining));
8080
}
@@ -83,8 +83,8 @@ struct [[sus_trivial_abi]] SliceIter final
8383
::sus::num::usize exact_size_hint() const noexcept {
8484
// SAFETY: The constructor checks that end_ - ptr_ is positive and Slice can
8585
// not exceed isize::MAX.
86-
// TODO: Use from_unchecked()
87-
return ::sus::num::usize::from(static_cast<size_t>(end_ - ptr_));
86+
return ::sus::num::usize::from_unchecked(::sus::marker::unsafe_fn,
87+
end_ - ptr_);
8888
}
8989

9090
private:
@@ -145,8 +145,8 @@ struct [[sus_trivial_abi]] SliceIterMut final
145145
::sus::iter::SizeHint size_hint() const noexcept final {
146146
// SAFETY: The constructor checks that end_ - ptr_ is positive and Slice can
147147
// not exceed isize::MAX.
148-
// TODO: Use from_unchecked()
149-
const auto remaining = ::sus::num::usize(static_cast<size_t>(end_ - ptr_));
148+
const auto remaining = ::sus::num::usize::from_unchecked(
149+
::sus::marker::unsafe_fn, end_ - ptr_);
150150
return ::sus::iter::SizeHint(
151151
remaining, ::sus::Option<::sus::num::usize>::some(remaining));
152152
}
@@ -155,8 +155,8 @@ struct [[sus_trivial_abi]] SliceIterMut final
155155
::sus::num::usize exact_size_hint() const noexcept {
156156
// SAFETY: The constructor checks that end_ - ptr_ is positive and Slice can
157157
// not exceed isize::MAX.
158-
// TODO: Use from_unchecked()
159-
return ::sus::num::usize::from(static_cast<size_t>(end_ - ptr_));
158+
return ::sus::num::usize::from_unchecked(::sus::marker::unsafe_fn,
159+
end_ - ptr_);
160160
}
161161

162162
private:

0 commit comments

Comments
 (0)