]> git.lizzy.rs Git - rust.git/blobdiff - crates/stdx/src/lib.rs
Remove proc macro management thread
[rust.git] / crates / stdx / src / lib.rs
index 340fcacfa3fa05f1e1ee265471f3412b15684770..e83d5db437d1d218d5fe3c3696e23790366b9de1 100644 (file)
@@ -110,7 +110,8 @@ fn drop(&mut self) {
     D(Some(f))
 }
 
-#[repr(transparent)]
+#[cfg_attr(not(target_arch = "wasm32"), repr(transparent))]
+#[derive(Debug)]
 pub struct JodChild(pub std::process::Child);
 
 impl ops::Deref for JodChild {
@@ -135,11 +136,42 @@ fn drop(&mut self) {
 
 impl JodChild {
     pub fn into_inner(self) -> std::process::Child {
-        // SAFETY: repr transparent
+        if cfg!(target_arch = "wasm32") {
+            panic!("no processes on wasm");
+        }
+        // SAFETY: repr transparent, except on WASM
         unsafe { std::mem::transmute::<JodChild, std::process::Child>(self) }
     }
 }
 
+// feature: iter_order_by
+// Iterator::eq_by
+pub fn iter_eq_by<I, I2, F>(this: I2, other: I, mut eq: F) -> bool
+where
+    I: IntoIterator,
+    I2: IntoIterator,
+    F: FnMut(I2::Item, I::Item) -> bool,
+{
+    let mut other = other.into_iter();
+    let mut this = this.into_iter();
+
+    loop {
+        let x = match this.next() {
+            None => return other.next().is_none(),
+            Some(val) => val,
+        };
+
+        let y = match other.next() {
+            None => return false,
+            Some(val) => val,
+        };
+
+        if !eq(x, y) {
+            return false;
+        }
+    }
+}
+
 #[cfg(test)]
 mod tests {
     use super::*;