Skip to content

Commit

Permalink
fix(prost-build): MSRV for Context
Browse files Browse the repository at this point in the history
  • Loading branch information
mzabaluev committed Nov 19, 2024
1 parent eba3137 commit 7a01e89
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions prost-build/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use prost_types::{

use crate::extern_paths::ExternPaths;
use crate::message_graph::MessageGraph;
use crate::{path, BytesType, Config, MapType, ServiceGenerator};
use crate::{BytesType, Config, MapType, ServiceGenerator};

/// The context providing all the global information needed to generate code.
/// It also provides a more disciplined access to Config
Expand Down Expand Up @@ -49,20 +49,29 @@ impl<'a> Context<'a> {

/// Returns an iterator over the additional attributes configured
/// for the named type.
pub fn type_attributes(&self, fq_type_name: &str) -> path::Iter<'_, String> {
self.config.type_attributes.get(fq_type_name)
pub fn type_attributes(&self, fq_type_name: &str) -> impl Iterator<Item = &str> {
self.config
.type_attributes
.get(fq_type_name)
.map(|s| s.as_str())
}

/// Returns an iterator over the additional attributes configured
/// for the named message.
pub fn message_attributes(&self, fq_message_name: &str) -> path::Iter<'_, String> {
self.config.message_attributes.get(fq_message_name)
pub fn message_attributes(&self, fq_message_name: &str) -> impl Iterator<Item = &str> {
self.config
.message_attributes
.get(fq_message_name)
.map(|s| s.as_str())
}

/// Returns an iterator over the additional attributes configured
/// for the named enum.
pub fn enum_attributes(&self, fq_enum_name: &str) -> path::Iter<'_, String> {
self.config.enum_attributes.get(fq_enum_name)
pub fn enum_attributes(&self, fq_enum_name: &str) -> impl Iterator<Item = &str> {
self.config
.enum_attributes
.get(fq_enum_name)
.map(|s| s.as_str())
}

/// Returns an iterator over the additional attributes configured
Expand All @@ -71,10 +80,11 @@ impl<'a> Context<'a> {
&self,
fq_message_name: &str,
field_name: &str,
) -> path::Iter<'_, String> {
) -> impl Iterator<Item = &str> {
self.config
.field_attributes
.get_field(fq_message_name, field_name)
.map(|s| s.as_str())
}

/// Returns the bytes type configured for the named message field.
Expand Down

0 comments on commit 7a01e89

Please sign in to comment.