Skip to content

Commit

Permalink
style: MessageGraph::new() can't actually fail (#1151)
Browse files Browse the repository at this point in the history
`MessageGraph` is an internal type. The currenly implementation can't fail, so it doesn't have to return a `Result`
  • Loading branch information
caspermeijn authored Sep 11, 2024
1 parent d059d05 commit d3fd54c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
3 changes: 1 addition & 2 deletions prost-build/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1080,8 +1080,7 @@ impl Config {
let mut modules = HashMap::new();
let mut packages = HashMap::new();

let message_graph = MessageGraph::new(requests.iter().map(|x| &x.1))
.map_err(|error| Error::new(ErrorKind::InvalidInput, error))?;
let message_graph = MessageGraph::new(requests.iter().map(|x| &x.1));
let extern_paths = ExternPaths::new(&self.extern_paths, self.prost_types)
.map_err(|error| Error::new(ErrorKind::InvalidInput, error))?;

Expand Down
6 changes: 2 additions & 4 deletions prost-build/src/message_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ pub struct MessageGraph {
}

impl MessageGraph {
pub fn new<'a>(
files: impl Iterator<Item = &'a FileDescriptorProto>,
) -> Result<MessageGraph, String> {
pub fn new<'a>(files: impl Iterator<Item = &'a FileDescriptorProto>) -> MessageGraph {
let mut msg_graph = MessageGraph {
index: HashMap::new(),
graph: Graph::new(),
Expand All @@ -39,7 +37,7 @@ impl MessageGraph {
}
}

Ok(msg_graph)
msg_graph
}

fn get_or_insert_index(&mut self, msg_name: String) -> NodeIndex {
Expand Down

0 comments on commit d3fd54c

Please sign in to comment.