Skip to content

Commit

Permalink
Remove usage of as usize in places
Browse files Browse the repository at this point in the history
And replace it with a safer alternative.
  • Loading branch information
Thomasdezeeuw committed Sep 23, 2023
1 parent f26e7c1 commit 234073f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions remote/src/net_relay/uuid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ impl Serialize for Uuid {
for idx in BYTE_POSITIONS[group]..BYTE_POSITIONS[group + 1] {
let byte = self.0[idx];
let out_idx = group + 2 * idx;
buf[out_idx] = HEX_CHARS[(byte >> 4) as usize];
buf[out_idx + 1] = HEX_CHARS[(byte & 0b1111) as usize];
buf[out_idx] = HEX_CHARS[usize::from(byte >> 4)];
buf[out_idx + 1] = HEX_CHARS[usize::from(byte & 0b1111)];
}
if group != 4 {
buf[HYPHEN_POSITIONS[group]] = b'-';
Expand Down
4 changes: 2 additions & 2 deletions src/future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,7 @@ impl<RT> ActorFutureBuilder<RT> {
RT: Clone,
{
let rt = self.rt;
let (inbox, sender, receiver) =
inbox::Manager::new_channel(self.inbox_size.0.get() as usize);
let (inbox, sender, receiver) = inbox::Manager::new_channel(self.inbox_size.get());
let actor_ref = ActorRef::local(sender);
let ctx = actor::Context::new(receiver, rt.clone());
let actor = match new_actor.new(ctx, argument) {
Expand Down Expand Up @@ -351,6 +350,7 @@ impl InboxSize {

/// Returns itself as `usize`.
pub const fn get(self) -> usize {
// TODO: replace with `usize::from`, once const stable.
self.0.get() as usize
}
}
Expand Down

0 comments on commit 234073f

Please sign in to comment.