We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a22772d commit d8ab2f8Copy full SHA for d8ab2f8
src/libcollections/enum_set.rs
@@ -43,7 +43,27 @@ impl<E:CLike+fmt::Show> fmt::Show for EnumSet<E> {
43
}
44
45
46
-/// An interface for casting C-like enum to uint and back.
+/**
47
+An interface for casting C-like enum to uint and back.
48
+A typically implementation is as below.
49
+
50
+```{rust,ignore}
51
+#[repr(uint)]
52
+enum Foo {
53
+ A, B, C
54
+}
55
56
+impl CLike for Foo {
57
+ fn to_uint(&self) -> uint {
58
+ *self as uint
59
+ }
60
61
+ fn from_uint(v: uint) -> Foo {
62
+ unsafe { mem::transmute(v) }
63
64
65
+```
66
+*/
67
pub trait CLike {
68
/// Converts a C-like enum to a `uint`.
69
fn to_uint(&self) -> uint;
0 commit comments