Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error Compiling Default String Field With Bytes #395

Closed
dharesign opened this issue Mar 3, 2019 · 1 comment
Closed

Error Compiling Default String Field With Bytes #395

dharesign opened this issue Mar 3, 2019 · 1 comment
Labels

Comments

@dharesign
Copy link

I'm using protobuf-codegen-pure = "2.3", and running into the following issue.

Given foo.proto:

message Foo {
    optional string bar = 1 [default = "test"];
}

The generated foo.rs:

impl Foo {
    pub fn mut_bar(&mut self) -> &mut ::protobuf::Chars {
        if self.bar.is_none() {
            self.bar = ::std::option::Option::Some("test");
        }
        self.bar.as_mut().unwrap()
    }
}

Fails to compile:

error[E0308]: mismatched types
  --> src/foo.rs:57:52
   |
57 |             self.bar = ::std::option::Option::Some("test");
   |                                                    ^^^^^^ expected struct `protobuf::chars::Chars`, found reference
   |
   = note: expected type `protobuf::chars::Chars`
              found type `&'static str`
@stepancheg
Copy link
Owner

Published fix as 2.3.1.

Thank you for the bugreport!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants