@@ -124,6 +124,9 @@ emitted for the owned message type (`Foo`). A subset of these functions with
124124functions with either ` &self ` or ` &mut self ` will also be included on the
125125` FooMut<'msg> ` .
126126
127+ To create an owned message type from a View / Mut type call ` to_owned() ` , which
128+ creates a deep copy.
129+
127130## Nested Types {#nested-types}
128131
129132Given the message declaration:
@@ -324,6 +327,8 @@ enum Bar {
324327The compiler generates a struct where each variant is an associated constant:
325328
326329``` rust
330+ #[derive(Clone , Copy , PartialEq , Eq , Hash )]
331+ #[repr(transparent)]
327332pub struct Bar (i32 );
328333
329334impl Bar {
@@ -366,6 +371,20 @@ enum Bar {
366371}
367372```
368373
374+ The compiler generates a struct where each variant is an associated constant:
375+
376+ ``` rust
377+ #[derive(Clone , Copy , PartialEq , Eq , Hash )]
378+ #[repr(transparent)]
379+ pub struct Bar (i32 );
380+
381+ impl Bar {
382+ pub const Unspecified : Bar = Bar (0 );
383+ pub const Value : Bar = Bar (1 );
384+ pub const OtherValue : Bar = Bar (2 );
385+ }
386+ ```
387+
369388For these field definitions:
370389
371390``` proto
@@ -536,14 +555,15 @@ enum FooBar {
536555The compiler will generate:
537556
538557``` rust
539- #[derive(Clone , Copy , PartialEq , Eq )]
540- pub struct Foo (i32 );
558+ #[derive(Clone , Copy , PartialEq , Eq , Hash )]
559+ #[repr(transparent)]
560+ pub struct FooBar (i32 );
541561
542562 impl FooBar {
543- pub const Unknown : Foo = Foo (0 );
544- pub const A : Foo = Foo (1 );
545- pub const FooB : Foo = Foo (5 );
546- pub const ValueC : Foo = Foo (1234 );
563+ pub const Unknown : FooBar = FooBar (0 );
564+ pub const A : FooBar = FooBar (1 );
565+ pub const FooB : FooBar = FooBar (5 );
566+ pub const ValueC : FooBar = FooBar (1234 );
547567 }
548568```
549569
0 commit comments