duesee/imap-next

Use `AtomicUsize` instead of `AtomicU64`

Closed this issue · 2 comments

For Debian packaging, I currently use the following patch, which at least compiles (not sure if it is sane):

--- a/src/handle.rs
+++ b/src/handle.rs
@@ -1,7 +1,7 @@
 use std::{
     fmt::{Debug, Formatter},
     marker::PhantomData,
-    sync::atomic::{AtomicU64, Ordering},
+    sync::atomic::{AtomicUsize, Ordering},
 };
 
 pub trait Handle {
@@ -55,14 +55,14 @@
 }
 
 pub struct HandleGeneratorGenerator<H: Handle> {
-    next_handle_generator_id: AtomicU64,
+    next_handle_generator_id: AtomicUsize,
     _h: PhantomData<H>,
 }
 
 impl<H: Handle> HandleGeneratorGenerator<H> {
     pub const fn new() -> Self {
         Self {
-            next_handle_generator_id: AtomicU64::new(0),
+            next_handle_generator_id: AtomicUsize::new(0),
             _h: PhantomData,
         }
     }
@@ -75,7 +75,7 @@
             .fetch_add(1, Ordering::Relaxed);
 
         HandleGenerator {
-            generator_id,
+            generator_id: generator_id.try_into().unwrap(),
             next_handle_id: 0,
             _h: PhantomData,
         }

Thanks! I think it makes sense! I further resolved the .unwrap() line and added you as a co-author. Are you fine with this? :-) See #295