Uploaded image for project: 'Apache Arrow'
  1. Apache Arrow
  2. ARROW-7692

[Rust] Several pattern matches are hard to read

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • None
    • 0.16.0
    • Rust

    Description

      Several pattern matches can be rewritten directly using a combinator, e.g. array's `value_as_date`, more succintly expressed as a `map`:

      match self.value_as_datetime {
       Some(datetime) => Some(datetime.date()),
       None => None,
       }

      More importantly some of these matches obscure what the code is doing, e.g. parquet column writer `read_fully`'s extraction of a mutable slice:
       let actual_def_levels = match &mut def_levels {
       Some(ref mut vec) => Some(&mut vec[..]),
       None => None,
       };
      which can be written, using `as_mut` and `map`, as:

      let actual_def_levels = def_levels.as_mut().map(|vec| &mut vec[..]);

      A large # of these are meant to be addressed in https://github.com/apache/arrow/pull/6292/files

      Attachments

        Issue Links

          Activity

            People

              huitseeker François Garillot
              huitseeker François Garillot
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 0.5h Original Estimate - 0.5h
                  0.5h
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 40m
                  40m