Info
This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: How to define unsupported enum value like invalid_atomic_ordering
I got an error atomic loads cannot have "Release" or "AcqRel" ordering
in the code below:
use std::sync::atomic::{AtomicUsize, Ordering};
fn main() {
let counter = AtomicUsize::new(0);
println!("Result: {}", counter.load(Ordering::AcqRel));
}
I wonder if it's possible apply this on a custom Enum?
enum E1 {
A1,
A2,
A3,
}
// How to let compiler report error when pass constant value E1::A3?
fn some_function(v: E1) {
if let E1::A3 = v{
panic!("A3 not supported")
}
// do something
}
3 posts - 3 participants
🏷️ rust_feed