Dandandan commented on a change in pull request #8839:
URL: https://github.com/apache/arrow/pull/8839#discussion_r537592747
##########
File path: rust/datafusion/src/logical_plan/dfschema.rs
##########
@@ -136,12 +136,11 @@ impl DFSchema {
/// Find the index of the column with the given name
pub fn index_of(&self, name: &str) -> Result<usize> {
- for i in 0..self.fields.len() {
- if self.fields[i].name() == name {
- return Ok(i);
- }
+ if let Some(i) = self.fields.iter().position(|f| f.name() == name) {
+ Ok(i)
Review comment:
small style thing but I guess we could do it roughly like this instead?
```rust
self.fields.iter().position(|f| f.name() == name)
.ok_or_else(|| DataFusionError::Plan(format!("No field named '{}'",
name)))
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]