Fix typo in From trait impls for enums
PiperOrigin-RevId: 447672411
diff --git a/rs_bindings_from_cc/src_code_gen.rs b/rs_bindings_from_cc/src_code_gen.rs
index 89af19b..4411495 100644
--- a/rs_bindings_from_cc/src_code_gen.rs
+++ b/rs_bindings_from_cc/src_code_gen.rs
@@ -1237,12 +1237,12 @@
}
impl From<#underlying_type> for #name {
fn from(value: #underlying_type) -> #name {
- #name(v)
+ #name(value)
}
}
impl From<#name> for #underlying_type {
fn from(value: #name) -> #underlying_type {
- v.0
+ value.0
}
}
})
@@ -3466,12 +3466,12 @@
}
impl From<u32> for Color {
fn from(value: u32) -> Color {
- Color(v)
+ Color(value)
}
}
impl From<Color> for u32 {
fn from(value: Color) -> u32 {
- v.0
+ value.0
}
}
}
@@ -3495,12 +3495,12 @@
}
impl From<i32> for Color {
fn from(value: i32) -> Color {
- Color(v)
+ Color(value)
}
}
impl From<Color> for i32 {
fn from(value: Color) -> i32 {
- v.0
+ value.0
}
}
}
@@ -3529,12 +3529,12 @@
}
impl From<i64> for Color {
fn from(value: i64) -> Color {
- Color(v)
+ Color(value)
}
}
impl From<Color> for i64 {
fn from(value: Color) -> i64 {
- v.0
+ value.0
}
}
}
@@ -3561,12 +3561,12 @@
}
impl From<u64> for Color {
fn from(value: u64) -> Color {
- Color(v)
+ Color(value)
}
}
impl From<Color> for u64 {
fn from(value: Color) -> u64 {
- v.0
+ value.0
}
}
}
@@ -3595,12 +3595,12 @@
}
impl From<i32> for Color {
fn from(value: i32) -> Color {
- Color(v)
+ Color(value)
}
}
impl From<Color> for i32 {
fn from(value: Color) -> i32 {
- v.0
+ value.0
}
}
}
@@ -3625,12 +3625,12 @@
}
impl From<u32> for Color {
fn from(value: u32) -> Color {
- Color(v)
+ Color(value)
}
}
impl From<Color> for u32 {
fn from(value: Color) -> u32 {
- v.0
+ value.0
}
}
}
diff --git a/rs_bindings_from_cc/test/golden/types.h b/rs_bindings_from_cc/test/golden/types.h
index 9abfc93..e0eaee4 100644
--- a/rs_bindings_from_cc/test/golden/types.h
+++ b/rs_bindings_from_cc/test/golden/types.h
@@ -96,4 +96,6 @@
inline void VoidReturningFunction() {}
+enum Color : unsigned int { kRed, kBlue, kLimeGreen = 4294967295 };
+
#endif // CRUBIT_RS_BINDINGS_FROM_CC_TEST_GOLDEN_TYPES_H_
diff --git a/rs_bindings_from_cc/test/golden/types_rs_api.rs b/rs_bindings_from_cc/test/golden/types_rs_api.rs
index 03c1457..aed8b99 100644
--- a/rs_bindings_from_cc/test/golden/types_rs_api.rs
+++ b/rs_bindings_from_cc/test/golden/types_rs_api.rs
@@ -214,6 +214,25 @@
unsafe { detail::__rust_thunk___Z21VoidReturningFunctionv() }
}
+#[repr(transparent)]
+#[derive(Debug, PartialEq, Eq, Copy, Clone, Hash, PartialOrd, Ord)]
+pub struct Color(u32);
+impl Color {
+ pub const kRed: Color = Color(0);
+ pub const kBlue: Color = Color(1);
+ pub const kLimeGreen: Color = Color(4294967295);
+}
+impl From<u32> for Color {
+ fn from(value: u32) -> Color {
+ Color(value)
+ }
+}
+impl From<Color> for u32 {
+ fn from(value: Color) -> u32 {
+ value.0
+ }
+}
+
// CRUBIT_RS_BINDINGS_FROM_CC_TEST_GOLDEN_TYPES_H_
mod detail {