You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: derive Copy trait for messages where possible (#950)
* feat: derive Copy trait for messages where possible
Rust primitive types can be copied by simply copying the bits. Rust structs can also have this property by deriving the Copy trait.
Automatically derive Copy for:
- messages that only have fields with primitive types
- the Rust enum for one-of fields
- messages whose field type are messages that also implement Copy
Generated code for Protobuf enums already derives Copy.
* fix: Remove clone call when copy is implemented
Clippy reports: warning: using `clone` on type `Timestamp` which implements the `Copy` trait
Copy file name to clipboardExpand all lines: prost-types/src/protobuf.rs
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -94,7 +94,7 @@ pub mod descriptor_proto {
94
94
/// fields or extension ranges in the same message. Reserved ranges may
95
95
/// not overlap.
96
96
#[allow(clippy::derive_partial_eq_without_eq)]
97
-
#[derive(Clone,PartialEq,::prost::Message)]
97
+
#[derive(Clone,Copy,PartialEq,::prost::Message)]
98
98
pubstructReservedRange{
99
99
/// Inclusive.
100
100
#[prost(int32, optional, tag = "1")]
@@ -360,7 +360,7 @@ pub mod enum_descriptor_proto {
360
360
/// is inclusive such that it can appropriately represent the entire int32
361
361
/// domain.
362
362
#[allow(clippy::derive_partial_eq_without_eq)]
363
-
#[derive(Clone,PartialEq,::prost::Message)]
363
+
#[derive(Clone,Copy,PartialEq,::prost::Message)]
364
364
pubstructEnumReservedRange{
365
365
/// Inclusive.
366
366
#[prost(int32, optional, tag = "1")]
@@ -1853,7 +1853,7 @@ pub struct Mixin {
1853
1853
/// be expressed in JSON format as "3.000000001s", and 3 seconds and 1
1854
1854
/// microsecond should be expressed in JSON format as "3.000001s".
1855
1855
#[allow(clippy::derive_partial_eq_without_eq)]
1856
-
#[derive(Clone,PartialEq,::prost::Message)]
1856
+
#[derive(Clone,Copy,PartialEq,::prost::Message)]
1857
1857
pubstructDuration{
1858
1858
/// Signed seconds of the span of time. Must be from -315,576,000,000
1859
1859
/// to +315,576,000,000 inclusive. Note: these bounds are computed from:
@@ -2293,7 +2293,7 @@ impl NullValue {
2293
2293
/// the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use
2294
2294
/// the Joda Time's [`ISODateTimeFormat.dateTime()`](<http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D>) to obtain a formatter capable of generating timestamps in this format.
2295
2295
#[allow(clippy::derive_partial_eq_without_eq)]
2296
-
#[derive(Clone,PartialEq,::prost::Message)]
2296
+
#[derive(Clone,Copy,PartialEq,::prost::Message)]
2297
2297
pubstructTimestamp{
2298
2298
/// Represents seconds of UTC time since Unix epoch
2299
2299
/// 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
0 commit comments