diff --git a/README.md b/README.md index 36dd5f1d1..ff77d00a8 100644 --- a/README.md +++ b/README.md @@ -164,7 +164,7 @@ The `#[derive(::prost::Enumeration)]` annotation added to the generated ```rust,ignore impl PhoneType { - pub fn is_valid(value: i32) -> bool { ... } + pub const fn is_valid(value: i32) -> bool { ... } #[deprecated] pub fn from_i32(value: i32) -> Option { ... } } diff --git a/prost-derive/src/lib.rs b/prost-derive/src/lib.rs index 3289da9bf..a300082f1 100644 --- a/prost-derive/src/lib.rs +++ b/prost-derive/src/lib.rs @@ -317,7 +317,7 @@ fn try_enumeration(input: TokenStream) -> Result { let expanded = quote! { impl #impl_generics #ident #ty_generics #where_clause { #[doc=#is_valid_doc] - pub fn is_valid(value: i32) -> bool { + pub const fn is_valid(value: i32) -> bool { match value { #(#is_valid,)* _ => false, diff --git a/prost/README.md b/prost/README.md index 36dd5f1d1..ff77d00a8 100644 --- a/prost/README.md +++ b/prost/README.md @@ -164,7 +164,7 @@ The `#[derive(::prost::Enumeration)]` annotation added to the generated ```rust,ignore impl PhoneType { - pub fn is_valid(value: i32) -> bool { ... } + pub const fn is_valid(value: i32) -> bool { ... } #[deprecated] pub fn from_i32(value: i32) -> Option { ... } }