Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into patch-stack
Browse files Browse the repository at this point in the history
  • Loading branch information
mattklein123 committed Nov 21, 2023
2 parents c6d432a + 4cffee8 commit 0144102
Show file tree
Hide file tree
Showing 28 changed files with 244 additions and 91 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# Changelog

## [3.2] - Unreleased
## [3.3] - Unreleased

* [Unnecessary copy in print_to_string_internal](https://github.com/stepancheg/rust-protobuf/pull/684)

## [3.3.0] - 2023-09-30

* [protoc_extra_arg not passed through](https://github.com/stepancheg/rust-protobuf/issues/643)
* [move custom code before derive block in struct](https://github.com/stepancheg/rust-protobuf/issues/675)
* [Enum::from_str](https://github.com/stepancheg/rust-protobuf/pull/664)

## [3.2.0] - 2022-09-26

Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
## I just want to ask a question

Feel free to open an issue to ask a question, the volume of questions is low,
so it's OK at the moment. But please don't expect prompt answer.
so it's OK at the moment. But please don't expect a prompt answer.

## I have found a bug

Please open an issue. When reporting a bug please include minimal example
Please open an [issue](https://github.com/stepancheg/rust-protobuf/issues). When reporting a bug please include minimal example
providing as much information as possible. In particular, please specify:

* exact proto file
Expand Down Expand Up @@ -38,4 +38,4 @@ Are always welcome, especially if they are backward-compatible.

## Help wanted

Most of all documentation is needed, any changes to rustdoc or markdown pages on github are welcome.
Most of all documentation is needed, any changes to rustdoc or markdown pages on GitHub are welcome.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ See [CHANGELOG.md](CHANGELOG.md) for a list of changes and compatility issues be

## Related projects

* [prost](https://github.com/danburkert/prost) — another protobuf implementation in Rust, also has gRPC implementation
* [prost](https://github.com/tokio-rs/prost) — another protobuf implementation in Rust, also has gRPC implementation
* [quick-protobuf](https://github.com/tafia/quick-protobuf) — alternative protobuf implementation in Rust
* [grpc-rs](https://github.com/pingcap/grpc-rs/) — another gRPC implementation for Rust
* [grpc-rust](https://github.com/stepancheg/grpc-rust) — incomplete implementation of gRPC based on this library
1 change: 1 addition & 0 deletions protobuf-codegen/src/codegen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ impl Codegen {

parser.inputs(&self.inputs);
parser.includes(&self.includes);
parser.protoc_extra_args(&self.protoc_extra_args);

if self.capture_stderr {
parser.capture_stderr();
Expand Down
24 changes: 24 additions & 0 deletions protobuf-codegen/src/gen/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,28 @@ impl<'a> EnumGen<'a> {
);
}

fn write_impl_enum_fn_from_str(&self, w: &mut CodeWriter) {
w.def_fn(
&format!(
"from_str(str: &str) -> ::std::option::Option<{}>",
self.type_name
),
|w| {
w.match_expr("str", |w| {
let values = self.values_unique();
for value in values {
w.write_line(&format!(
"\"{}\" => ::std::option::Option::Some({}),",
value.value.proto.name(),
value.rust_name_outer()
));
}
w.write_line(&format!("_ => {}", EXPR_NONE));
});
},
);
}

fn write_impl_enum_const_values(&self, w: &mut CodeWriter) {
w.write_line(&format!("const VALUES: &'static [{}] = &[", self.type_name));
w.indented(|w| {
Expand All @@ -264,6 +286,8 @@ impl<'a> EnumGen<'a> {
w.write_line("");
self.write_impl_enum_fn_from_i32(w);
w.write_line("");
self.write_impl_enum_fn_from_str(w);
w.write_line("");
self.write_impl_enum_const_values(w);
},
);
Expand Down
11 changes: 6 additions & 5 deletions protobuf-codegen/src/gen/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -568,17 +568,18 @@ impl<'a> MessageGen<'a> {
}

fn write_struct(&self, w: &mut CodeWriter) {
write_protoc_insertion_point_for_message(
w,
&self.customize.for_elem,
&self.message_descriptor,
);
let mut derive = Vec::new();
if self.supports_derive_partial_eq() {
derive.push("PartialEq");
}
derive.extend(&["Clone", "Default", "Debug"]);
w.derive(&derive);
write_protoc_insertion_point_for_message(
w,
&self.customize.for_elem,
&self.message_descriptor,
);

w.pub_struct(&format!("{}", self.rust_name()), |w| {
if !self.fields_except_oneof().is_empty() {
w.comment("message fields");
Expand Down
4 changes: 2 additions & 2 deletions protobuf-parse/src/protobuf_rel_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ impl ProtobufRelPathRef {
}

pub fn self_and_parents(&self) -> Vec<&ProtobufRelPathRef> {
let mut tmp = self.clone();
let mut tmp = self;

let mut r = Vec::new();

r.push(self.clone());
r.push(self);

while let Some(parent) = tmp.parent() {
r.push(parent);
Expand Down
2 changes: 1 addition & 1 deletion protobuf-parse/src/pure/convert/option_resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl LookupScope2 {
match self.messages().iter().find(|m| m.name() == name.as_str()) {
Some(m) => {
let mut path = self.current_path();
path.push_simple(name.clone());
path.push_simple(name);
Some(LookupScope2::Message(m.clone(), path))
}
None => None,
Expand Down
2 changes: 1 addition & 1 deletion protobuf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ See `Customize` struct in [`protobuf-codegen` crate](https://docs.rs/protobuf-co
* [`protobuf-json-mapping`](https://docs.rs/protobuf-json-mapping)
implements JSON parsing and serialization for protobuf messages.
* [`protobuf-codegen`](https://docs.rs/protobuf-codegen)
can be used to rust code from `.proto` crates.
can be used to generate rust code from `.proto` crates.
* [`protoc-bin-vendored`](https://docs.rs/protoc-bin-vendored)
contains `protoc` command packed into the crate.
* [`protobuf-parse`](https://docs.rs/protobuf-parse) contains
Expand Down
Loading

0 comments on commit 0144102

Please sign in to comment.