rust: Run `cargo fmt`.
authorBen Pfaff <blp@cs.stanford.edu>
Wed, 24 Sep 2025 00:16:56 +0000 (17:16 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Wed, 24 Sep 2025 14:39:49 +0000 (07:39 -0700)
45 files changed:
rust/pspp/build.rs
rust/pspp/src/command.rs
rust/pspp/src/command/ctables.rs
rust/pspp/src/convert.rs
rust/pspp/src/crypto.rs
rust/pspp/src/data.rs
rust/pspp/src/decrypt.rs
rust/pspp/src/dictionary.rs
rust/pspp/src/format.rs
rust/pspp/src/format/display/tests.rs
rust/pspp/src/format/parse.rs
rust/pspp/src/identifier.rs
rust/pspp/src/lex/lexer.rs
rust/pspp/src/lex/segment.rs
rust/pspp/src/locale_charset.rs
rust/pspp/src/macros.rs
rust/pspp/src/output/cairo/driver.rs
rust/pspp/src/output/cairo/fsm.rs
rust/pspp/src/output/cairo/pager.rs
rust/pspp/src/output/csv.rs
rust/pspp/src/output/driver.rs
rust/pspp/src/output/html.rs
rust/pspp/src/output/json.rs
rust/pspp/src/output/page.rs
rust/pspp/src/output/pivot.rs
rust/pspp/src/output/pivot/look_xml.rs
rust/pspp/src/output/pivot/output.rs
rust/pspp/src/output/pivot/tests.rs
rust/pspp/src/output/pivot/tlo.rs
rust/pspp/src/output/render.rs
rust/pspp/src/output/spv.rs
rust/pspp/src/output/table.rs
rust/pspp/src/output/text.rs
rust/pspp/src/por/read.rs
rust/pspp/src/por/write.rs
rust/pspp/src/show.rs
rust/pspp/src/show_por.rs
rust/pspp/src/sys/cooked.rs
rust/pspp/src/sys/encoding.rs
rust/pspp/src/sys/raw.rs
rust/pspp/src/sys/raw/records.rs
rust/pspp/src/sys/sack.rs
rust/pspp/src/sys/tests.rs
rust/pspp/src/sys/write.rs
rust/pspp/src/variable.rs

index 13e9534d16e105b3380f9bfdcbb179e108834151..ff821f6f919691df632194647f86ac1fb9cb1902 100644 (file)
 // You should have received a copy of the GNU General Public License along with
 // this program.  If not, see <http://www.gnu.org/licenses/>.
 
-use anyhow::{anyhow, Result as AnyResult};
+use anyhow::{Result as AnyResult, anyhow};
 use std::{
     collections::{BTreeMap, HashSet, VecDeque},
     env::var_os,
-    fs::{read_to_string, File},
+    fs::{File, read_to_string},
     io::{Error as IoError, Write},
     path::{Path, PathBuf},
 };
@@ -197,9 +197,11 @@ fn main() -> AnyResult<()> {
         (99998, Source::Codepage, "replacement"),
         (99999, Source::Codepage, "x-user-defined"),
     ] {
-        assert!(codepages
-            .insert(codepage, [(source, vec![name])].into_iter().collect())
-            .is_none());
+        assert!(
+            codepages
+                .insert(codepage, [(source, vec![name])].into_iter().collect())
+                .is_none()
+        );
     }
 
     let output_file_name = Path::new(&var_os("OUT_DIR").unwrap()).join("encodings.rs");
index 5f0d1ec55bad7a1cf555d572d5edd137455e0fff..471bb84485659e66afc1de75f4a7b012c13ea899 100644 (file)
@@ -26,7 +26,7 @@ use ctables::ctables_command;
 use data_list::data_list_command;
 use descriptives::descriptives_command;
 use either::Either;
-use flagset::{flags, FlagSet};
+use flagset::{FlagSet, flags};
 use pspp_derive::FromTokens;
 
 use crate::{
@@ -34,9 +34,9 @@ use crate::{
     identifier::Identifier,
     integer::ToInteger,
     lex::{
+        Punct, Token,
         command_name::CommandMatcher,
         lexer::{LexToken, TokenSlice},
-        Punct, Token,
     },
     message::{Diagnostic, Diagnostics},
 };
index fd6596152382cb896e97f98c2c6dbd43003aa7b7..a42e9fcd2d2b8c7acf435a3a10e8c1cba552ecfe 100644 (file)
@@ -161,12 +161,12 @@ struct Expression(MulExpression, Seq0<(Either<Plus, Dash>, Expression)>);
 
 impl Debug for Expression {
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
-        if self.1 .0.is_empty() {
+        if self.1.0.is_empty() {
             self.0.fmt(f)
         } else {
             write!(f, "(")?;
             self.0.fmt(f)?;
-            for (operator, operand) in &self.1 .0 {
+            for (operator, operand) in &self.1.0 {
                 if operator.is_left() {
                     write!(f, " + ")?;
                 } else {
@@ -187,12 +187,12 @@ struct MulExpression(
 
 impl Debug for MulExpression {
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
-        if self.1 .0.is_empty() {
+        if self.1.0.is_empty() {
             self.0.fmt(f)
         } else {
             write!(f, "(")?;
             self.0.fmt(f)?;
-            for (operator, operand) in &self.1 .0 {
+            for (operator, operand) in &self.1.0 {
                 if operator.is_left() {
                     write!(f, " * ")?;
                 } else {
@@ -210,12 +210,12 @@ struct PowExpression(Terminal, Seq0<(Exp, PowExpression)>);
 
 impl Debug for PowExpression {
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
-        if self.1 .0.is_empty() {
+        if self.1.0.is_empty() {
             self.0.fmt(f)
         } else {
             write!(f, "(")?;
             self.0.fmt(f)?;
-            for (_operator, operand) in &self.1 .0 {
+            for (_operator, operand) in &self.1.0 {
                 write!(f, " ** {operand:?}")?;
             }
             write!(f, ")")
index aa59cbfa42c2a153f9855214f9646708695adf13..34aed906bb66b67c837d60f12f60ad0451dc6895 100644 (file)
 
 use std::{
     fs::File,
-    io::{stdout, Write},
+    io::{Write, stdout},
     path::{Path, PathBuf},
 };
 
-use anyhow::{anyhow, bail, Error as AnyError, Result};
+use anyhow::{Error as AnyError, Result, anyhow, bail};
 use chrono::{Datelike, NaiveTime, Timelike};
 use clap::{Args, ValueEnum};
 use csv::Writer;
@@ -31,7 +31,7 @@ use pspp::{
     file::FileType,
     format::{DisplayPlain, Type},
     por::PortableFile,
-    sys::{raw::records::Compression, ReadOptions, WriteOptions},
+    sys::{ReadOptions, WriteOptions, raw::records::Compression},
     util::ToSmallString,
     variable::Variable,
 };
index 0d1282f74cf0fc49caf430eba5d864017007e41f..cce9825632e674bc6cbf07793eeb8fc01f06d31b 100644 (file)
@@ -12,8 +12,8 @@
 #![cfg_attr(not(test), warn(missing_docs))]
 
 use aes::{
-    cipher::{generic_array::GenericArray, BlockDecrypt, KeyInit},
     Aes256, Aes256Dec,
+    cipher::{BlockDecrypt, KeyInit, generic_array::GenericArray},
 };
 use cmac::{Cmac, Mac};
 use smallvec::SmallVec;
@@ -23,7 +23,7 @@ use std::{
 };
 use thiserror::Error as ThisError;
 
-use binrw::{io::NoSeek, BinRead};
+use binrw::{BinRead, io::NoSeek};
 
 /// Error reading an encrypted file.
 #[derive(Clone, Debug, ThisError)]
@@ -130,7 +130,7 @@ where
             _ => {
                 return Err(Error::UnknownFileType(
                     header.file_type.iter().map(|b| *b as char).collect(),
-                ))
+                ));
             }
         };
         let mut first_block = [0; 16];
index ebacd6108e6eb4df697ee68f240abe3b541bfbd7..5552b813f5b74ecedeb74d2f9104a96a4b436d3f 100644 (file)
@@ -35,20 +35,20 @@ use std::{
     str::from_utf8,
 };
 
-use encoding_rs::{mem::decode_latin1, Encoding, UTF_8};
+use encoding_rs::{Encoding, UTF_8, mem::decode_latin1};
 use itertools::Itertools;
 use ordered_float::OrderedFloat;
 use serde::{
-    ser::{SerializeSeq, SerializeTupleVariant},
     Serialize,
+    ser::{SerializeSeq, SerializeTupleVariant},
 };
 
 use crate::{
     dictionary::Dictionary,
     format::DisplayPlain,
     output::{
-        pivot::{Axis3, Dimension, Group, PivotTable, Value},
         Item, Text,
+        pivot::{Axis3, Dimension, Group, PivotTable, Value},
     },
     variable::{VarType, VarWidth},
 };
index 5500b0093d01d84d703c71db22fd56217d26df43..50e0629cae819199bc2613c04017e8f7a1a0100d 100644 (file)
@@ -14,7 +14,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>. */
 
-use anyhow::{anyhow, Result};
+use anyhow::{Result, anyhow};
 use clap::Args;
 use pspp::crypto::EncryptedFile;
 use std::{fs::File, path::PathBuf};
index 7a0088a47efa2871ba0b3558d6e1ac1ce0f1a163..1f305636558c9abd7e1a19368ab332f678bd80a8 100644 (file)
@@ -19,7 +19,7 @@
 use core::str;
 use std::{
     borrow::Cow,
-    collections::{btree_set, BTreeSet, HashSet},
+    collections::{BTreeSet, HashSet, btree_set},
     ops::{Bound, Index, RangeBounds, RangeInclusive},
 };
 
@@ -27,8 +27,8 @@ use encoding_rs::{Encoding, UTF_8};
 use enum_map::{Enum, EnumMap};
 use indexmap::IndexSet;
 use serde::{
-    ser::{SerializeMap, SerializeSeq, SerializeStruct},
     Serialize,
+    ser::{SerializeMap, SerializeSeq, SerializeStruct},
 };
 use smallvec::SmallVec;
 use thiserror::Error as ThisError;
@@ -275,10 +275,11 @@ impl Dictionary {
     }
 
     pub fn add_variable_set(&mut self, set: DictIndexVariableSet) {
-        assert!(set
-            .variables
-            .iter()
-            .all(|dict_index| *dict_index < self.variables.len()));
+        assert!(
+            set.variables
+                .iter()
+                .all(|dict_index| *dict_index < self.variables.len())
+        );
         self.variable_sets.push(set);
     }
 
@@ -1412,7 +1413,9 @@ pub enum MrSetError {
     /// Counted value {value} has width {width}, but it must be no wider than
     /// {max_width}, the width of the narrowest variable in multiple response
     /// set {mr_set}.
-    #[error("Counted value {value} has width {width}, but it must be no wider than {max_width}, the width of the narrowest variable in multiple response set {mr_set}.")]
+    #[error(
+        "Counted value {value} has width {width}, but it must be no wider than {max_width}, the width of the narrowest variable in multiple response set {mr_set}."
+    )]
     TooWideMDGroupCountedValue {
         /// Multiple response set name.
         mr_set: Identifier,
index 401b22f0faba86b9d3c19d41ab66a9ad24fff738..e9d26895e0b3d91b88fcf64530d808b7eeeccfc9 100644 (file)
@@ -22,7 +22,7 @@ use std::{
 };
 
 use chrono::{Datelike, Local};
-use enum_iterator::{all, Sequence};
+use enum_iterator::{Sequence, all};
 use enum_map::{Enum, EnumMap};
 use serde::{Deserialize, Serialize};
 use thiserror::Error as ThisError;
@@ -68,7 +68,9 @@ pub enum Error {
     #[error("Numeric variable is not compatible with string format {0}.")]
     UnnamedVariableNotCompatibleWithStringFormat(Type),
 
-    #[error("String variable {variable} with width {width} is not compatible with format {bad_spec}.  Use format {good_spec} instead.")]
+    #[error(
+        "String variable {variable} with width {width} is not compatible with format {bad_spec}.  Use format {good_spec} instead."
+    )]
     NamedStringVariableBadSpecWidth {
         variable: String,
         width: Width,
@@ -76,7 +78,9 @@ pub enum Error {
         good_spec: Format,
     },
 
-    #[error("String variable with width {width} is not compatible with format {bad_spec}.  Use format {good_spec} instead.")]
+    #[error(
+        "String variable with width {width} is not compatible with format {bad_spec}.  Use format {good_spec} instead."
+    )]
     UnnamedStringVariableBadSpecWidth {
         width: Width,
         bad_spec: Format,
index 9ddd3047f2a993e27c76be070b8431163c1f6f4f..e0bbf84cc9b7f4efc547f6c502ca4011f91d6d46 100644 (file)
@@ -16,7 +16,7 @@
 
 use std::{fmt::Write, fs::File, io::BufRead, path::Path};
 
-use binrw::{io::BufReader, Endian};
+use binrw::{Endian, io::BufReader};
 use encoding_rs::UTF_8;
 use itertools::Itertools;
 use smallstr::SmallString;
@@ -24,8 +24,8 @@ use smallvec::SmallVec;
 
 use crate::{
     data::{ByteString, Datum, WithEncoding},
-    format::{AbstractFormat, Epoch, Format, Settings, Type, UncheckedFormat, CC},
-    lex::{scan::StringScanner, segment::Syntax, Punct, Token},
+    format::{AbstractFormat, CC, Epoch, Format, Settings, Type, UncheckedFormat},
+    lex::{Punct, Token, scan::StringScanner, segment::Syntax},
     settings::EndianSettings,
 };
 
@@ -1294,10 +1294,10 @@ fn test_times(format: Format, name: &str) {
             .display(format)
             .to_string();
         assert!(
-                formatted == expect,
-                "formatting {}:{line_number} as {format}:\n  actual: {formatted:?}\nexpected: {expect:?}",
-                input_filename.display()
-            );
+            formatted == expect,
+            "formatting {}:{line_number} as {format}:\n  actual: {formatted:?}\nexpected: {expect:?}",
+            input_filename.display()
+        );
     }
 }
 
index 2161e3dc0a6c8d3e43b05602e4734b83b4eddf2f..45b37b57bc2fe94571f92c09f076cecf0cc6d4e9 100644 (file)
@@ -15,7 +15,7 @@
 // this program.  If not, see <http://www.gnu.org/licenses/>.
 
 use crate::{
-    calendar::{calendar_gregorian_to_offset, DateError},
+    calendar::{DateError, calendar_gregorian_to_offset},
     data::{ByteString, Datum, EncodedString, OwnedDatum, RawString, WithEncoding},
     endian::FromBytes,
     format::{DateTemplate, Decimals, Settings, TemplateItem, Type},
@@ -106,7 +106,9 @@ enum ParseErrorKind {
     InvalidWeek(i32),
 
     /// Unrecognized month format.
-    #[error("Unrecognized month format.  Months may be specified as Arabic or Roman numerals or as at least 3 letters of their English names.")]
+    #[error(
+        "Unrecognized month format.  Months may be specified as Arabic or Roman numerals or as at least 3 letters of their English names."
+    )]
     InvalidMonth,
 
     /// Delimiter expected between fields in time.
@@ -122,7 +124,9 @@ enum ParseErrorKind {
     InvalidMinute(i32),
 
     /// Invalid weekday name.
-    #[error("Unrecognized weekday name.  At least the first two letters of an English weekday name must be specified.")]
+    #[error(
+        "Unrecognized weekday name.  At least the first two letters of an English weekday name must be specified."
+    )]
     InvalidWeekdayName,
 
     /// Expected character.
@@ -925,8 +929,8 @@ mod tests {
         calendar::{days_in_month, is_leap_year},
         data::{ByteStr, Datum, EncodedString, OwnedDatum, RawString},
         format::{
-            parse::{ParseError, ParseErrorKind, Sign},
             Epoch, Format, Settings as FormatSettings, Type,
+            parse::{ParseError, ParseErrorKind, Sign},
         },
         settings::EndianSettings,
     };
index 700b1cd087784f39163c65b819bc3df5d147487e..5422c534c1ec96377d8686e453064ee0681f7b18 100644 (file)
@@ -126,7 +126,9 @@ pub enum Error {
     #[error("\"!\" is not a valid identifier.")]
     Bang,
 
-    #[error("{string:?} may not be used as an identifier because it begins with disallowed character {c:?}.")]
+    #[error(
+        "{string:?} may not be used as an identifier because it begins with disallowed character {c:?}."
+    )]
     BadFirstCharacter { string: String, c: char },
 
     #[error(
@@ -134,7 +136,9 @@ pub enum Error {
     )]
     BadLaterCharacter { string: String, c: char },
 
-    #[error("Identifier \"{id}\" is {length} bytes in the encoding in use ({encoding}), which exceeds the {max}-byte limit.")]
+    #[error(
+        "Identifier \"{id}\" is {length} bytes in the encoding in use ({encoding}), which exceeds the {max}-byte limit."
+    )]
     TooLong {
         id: String,
         length: usize,
@@ -142,7 +146,9 @@ pub enum Error {
         max: usize,
     },
 
-    #[error("\"{id}\" may not be used as an identifier because the encoding in use ({encoding}) cannot represent \"{c}\".")]
+    #[error(
+        "\"{id}\" may not be used as an identifier because the encoding in use ({encoding}) cannot represent \"{c}\"."
+    )]
     NotEncodable {
         id: String,
         encoding: &'static str,
index 62a30b0d1e422155e495f6d22036a29b995ae47c..319ff36d00f6a003426d84fe186f462ae278448a 100644 (file)
@@ -36,7 +36,7 @@ use unicode_width::{UnicodeWidthChar, UnicodeWidthStr};
 
 use crate::{
     lex::scan::merge_tokens,
-    macros::{macro_tokens_to_syntax, MacroSet, ParseStatus, Parser},
+    macros::{MacroSet, ParseStatus, Parser, macro_tokens_to_syntax},
     message::{Category, Diagnostic, Location, Point, Severity},
     settings::Settings,
 };
index 27313a71840ae611da8b9c297775f0e8adc6478e..625fbd9a1a34749c6acf337df7651b62ed0fd74e 100644 (file)
 use std::cmp::Ordering;
 
 use crate::{
-    identifier::{id_match, id_match_n, IdentifierChar},
+    identifier::{IdentifierChar, id_match, id_match_n},
     prompt::PromptStyle,
 };
 use bitflags::bitflags;
 
-use super::command_name::{command_match, COMMAND_NAMES};
+use super::command_name::{COMMAND_NAMES, command_match};
 
 /// Syntax variant.
 ///
@@ -1286,7 +1286,7 @@ impl Segmenter {
             };
             match c {
                 '!' if strip_prefix_ignore_ascii_case(input, "!ENDDEFINE").is_some() => {
-                    return Some(input)
+                    return Some(input);
                 }
                 '\'' | '"' => {
                     let index = rest.find(c)?;
index 26856ef803a44f2e113d4dfb16c0fd7de39cc097..534d0e729776064c886c380c842324b8058060fa 100644 (file)
@@ -221,11 +221,11 @@ fn map_aliases(s: &str) -> &'static str {
 #[cfg(unix)]
 mod inner {
     use std::{
-        ffi::{c_int, CStr, CString},
+        ffi::{CStr, CString, c_int},
         ptr::null,
     };
 
-    use libc::{self, nl_langinfo, setlocale, CODESET, LC_CTYPE};
+    use libc::{self, CODESET, LC_CTYPE, nl_langinfo, setlocale};
 
     unsafe fn string_from_pointer(s: *const i8) -> Option<String> {
         if s.is_null() {
@@ -256,7 +256,7 @@ mod inner {
 
 #[cfg(windows)]
 mod inner {
-    use libc::{setlocale, LC_CTYPE};
+    use libc::{LC_CTYPE, setlocale};
     use std::ffi::{CStr, CString};
     use windows_sys::Win32::Globalization::GetACP;
 
index c5d9c9e94fd7a1faaf5856518d7737996e2440c1..5107842e4bd7ab0ecf80ee34b022ea44eb98e67b 100644 (file)
@@ -31,9 +31,9 @@ use unicase::UniCase;
 use crate::{
     identifier::Identifier,
     lex::{
+        Punct, Token,
         scan::{ScanError, StringScanner, StringSegmenter},
         segment::Syntax,
-        Punct, Token,
     },
     message::Location,
     settings::Settings,
@@ -134,11 +134,15 @@ pub enum MacroError {
     BadNumericMacroExpression(String),
 
     /// Too many iteration for list-based loop.
-    #[error("`!DO` loop over list exceeded maximum number of iterations {0}.  (Use `SET MITERATE` to change the limit.)")]
+    #[error(
+        "`!DO` loop over list exceeded maximum number of iterations {0}.  (Use `SET MITERATE` to change the limit.)"
+    )]
     MiterateList(usize),
 
     /// Too many iteration for numerical loop.
-    #[error("Numerical `!DO` loop  exceeded maximum number of iterations {0}.  (Use `SET MITERATE` to change the limit.)")]
+    #[error(
+        "Numerical `!DO` loop  exceeded maximum number of iterations {0}.  (Use `SET MITERATE` to change the limit.)"
+    )]
     MiterateNumeric(usize),
 
     /// Expecting `!TO`  in numerical `!DO` loop.
index fbcabc06c0b8fb3de55c17aa2ed5ce116ce5b001..e2392981108db39e1c19f700c4672b8cce2cff4a 100644 (file)
@@ -21,19 +21,19 @@ use std::{
 };
 
 use cairo::{Context, PdfSurface};
-use enum_map::{enum_map, EnumMap};
+use enum_map::{EnumMap, enum_map};
 use pango::SCALE;
 use serde::{Deserialize, Serialize};
 
 use crate::output::{
+    Item,
     cairo::{
-        fsm::{parse_font_style, CairoFsmStyle},
+        fsm::{CairoFsmStyle, parse_font_style},
         pager::{CairoPageStyle, CairoPager},
     },
     driver::Driver,
     page::PageSetup,
     pivot::{Color, Coord2, FontStyle},
-    Item,
 };
 
 use crate::output::pivot::Axis2;
index ccf4d21f1cc1f82f91e2235547953cdb69004dd6..13597f30a0d7f8388a591ac47ba23b226cf8815d 100644 (file)
 use std::{cmp::min, f64::consts::PI, fmt::Write, ops::DerefMut, sync::Arc};
 
 use cairo::Context;
-use enum_map::{enum_map, EnumMap};
+use enum_map::{EnumMap, enum_map};
 use itertools::Itertools;
 use pango::{
-    parse_markup, AttrFloat, AttrFontDesc, AttrInt, AttrList, Attribute, FontDescription, FontMask,
-    Layout, Underline, Weight, SCALE, SCALE_SMALL,
+    AttrFloat, AttrFontDesc, AttrInt, AttrList, Attribute, FontDescription, FontMask, Layout,
+    SCALE, SCALE_SMALL, Underline, Weight, parse_markup,
 };
 use pangocairo::functions::show_layout;
-use smallvec::{smallvec, SmallVec};
+use smallvec::{SmallVec, smallvec};
 
 use crate::output::cairo::{horz_align_to_pango, px_to_xr, xr_to_pt};
 use crate::output::pivot::{Axis2, BorderStyle, Coord2, FontStyle, HorzAlign, Rect2, Stroke};
 use crate::output::render::{Device, Extreme, Pager, Params};
 use crate::output::table::DrawCell;
-use crate::output::{pivot::Color, table::Content};
 use crate::output::{Details, Item};
+use crate::output::{pivot::Color, table::Content};
 
 /// Width of an ordinary line.
 const LINE_WIDTH: usize = LINE_SPACE / 2;
index d490fc696b3335d1b5c3ef6c4355a11b69850ca0..6106eb6a0e55026d4bcd58d30a116822a9047fd5 100644 (file)
@@ -21,13 +21,13 @@ use enum_map::EnumMap;
 use pango::{FontDescription, Layout};
 
 use crate::output::{
+    Item, ItemCursor,
     cairo::{
         fsm::{CairoFsm, CairoFsmStyle},
         horz_align_to_pango, xr_to_pt,
     },
     page::Heading,
     pivot::Axis2,
-    Item, ItemCursor,
 };
 
 #[derive(Clone, Debug)]
index 0626d90eb22c1b8775e4bfd4a8a82267a8d977b8..0eded20bdb228a5ec9a146e8d2fc2a95edea0cb0 100644 (file)
@@ -24,13 +24,13 @@ use std::{
 };
 
 use serde::{
-    de::{Unexpected, Visitor},
     Deserialize, Deserializer, Serialize,
+    de::{Unexpected, Visitor},
 };
 
 use crate::output::pivot::Coord2;
 
-use super::{driver::Driver, pivot::PivotTable, table::Table, Details, Item, TextType};
+use super::{Details, Item, TextType, driver::Driver, pivot::PivotTable, table::Table};
 
 #[derive(Clone, Debug, Serialize, Deserialize)]
 pub struct CsvConfig {
index 5d97660126756aabb6c3217ae776b4a00acbddfe..6015ed82841c3d674a95d3eb332b1c8d0c92ef18 100644 (file)
@@ -28,7 +28,7 @@ use crate::output::{
     text::{TextConfig, TextDriver},
 };
 
-use super::{page::PageSetup, Item};
+use super::{Item, page::PageSetup};
 
 // An output driver.
 pub trait Driver {
index cfc515d19adcee4256049298e2ceb14990719b42..949724b9afc9b16e94d2e56f2e67db5a8e9c4d09 100644 (file)
@@ -27,10 +27,10 @@ use serde::{Deserialize, Serialize};
 use smallstr::SmallString;
 
 use crate::output::{
+    Details, Item,
     driver::Driver,
     pivot::{Axis2, BorderStyle, Color, Coord2, HorzAlign, PivotTable, Rect2, Stroke, VertAlign},
     table::{DrawCell, Table},
-    Details, Item,
 };
 
 #[derive(Clone, Debug, Deserialize, Serialize)]
index af6923d3904a7af477672f52594784bdeaeb6b6a..c7f52bd5e755ab7baca8d3ba8ce25af938b51332 100644 (file)
@@ -24,7 +24,7 @@ use std::{
 
 use serde::{Deserialize, Serialize};
 
-use super::{driver::Driver, Item};
+use super::{Item, driver::Driver};
 
 #[derive(Clone, Debug, Serialize, Deserialize)]
 pub struct JsonConfig {
index 4240b8d9f57a582d856d53b047a33cae487fdde6..6872a6aeabf87808fdfbb406543ab4cb301eeaf4 100644 (file)
@@ -14,7 +14,7 @@
 // You should have received a copy of the GNU General Public License along with
 // this program.  If not, see <http://www.gnu.org/licenses/>.
 
-use enum_map::{enum_map, EnumMap};
+use enum_map::{EnumMap, enum_map};
 use serde::{Deserialize, Serialize};
 
 use super::pivot::{Axis2, HorzAlign};
index c909d8dd38320d1ddd30acd29c4a6335d9e62933..5ceab55e8e0446c054a19755e54deb894fda91fd 100644 (file)
@@ -46,24 +46,24 @@ use std::{
     collections::HashMap,
     fmt::{Debug, Display, Write},
     io::Read,
-    iter::{once, repeat, repeat_n, FusedIterator},
+    iter::{FusedIterator, once, repeat, repeat_n},
     ops::{Index, IndexMut, Not, Range, RangeInclusive},
-    str::{from_utf8, FromStr, Utf8Error},
+    str::{FromStr, Utf8Error, from_utf8},
     sync::{Arc, OnceLock},
 };
 
 use binrw::Error as BinError;
 use chrono::NaiveDateTime;
 pub use color::ParseError as ParseColorError;
-use color::{palette::css::TRANSPARENT, AlphaColor, Rgba8, Srgb};
+use color::{AlphaColor, Rgba8, Srgb, palette::css::TRANSPARENT};
 use enum_iterator::Sequence;
-use enum_map::{enum_map, Enum, EnumMap};
+use enum_map::{Enum, EnumMap, enum_map};
 use look_xml::TableProperties;
-use quick_xml::{de::from_str, DeError};
+use quick_xml::{DeError, de::from_str};
 use serde::{
+    Deserialize, Serialize, Serializer,
     de::Visitor,
     ser::{SerializeMap, SerializeStruct},
-    Deserialize, Serialize, Serializer,
 };
 use smallstr::SmallString;
 use smallvec::SmallVec;
index c935125e3161b4e579397f0aff4127ed89064fb8..a9e1264f55e567a2fdf164539711149174771081 100644 (file)
@@ -17,7 +17,7 @@
 use std::{fmt::Debug, num::ParseFloatError, str::FromStr};
 
 use enum_map::enum_map;
-use serde::{de::Visitor, Deserialize};
+use serde::{Deserialize, de::Visitor};
 
 use crate::{
     format::Decimal,
index 3a6f24cbebb3dcd40757da6c4882c93a7d7d81b9..8df1ae536929d7c0e2873969c6d5c031c833c149 100644 (file)
@@ -16,7 +16,7 @@
 
 use std::{iter::zip, ops::Range, sync::Arc};
 
-use enum_map::{enum_map, EnumMap};
+use enum_map::{EnumMap, enum_map};
 use itertools::Itertools;
 
 use crate::output::{
index a69f82153205d79fba6c35e2b89964e95aaed1f7..27c3f1975de018f9d4f6fafa6cfc46ba2b3cde2c 100644 (file)
@@ -19,6 +19,7 @@ use std::{fmt::Display, fs::File, path::Path, sync::Arc};
 use enum_map::EnumMap;
 
 use crate::output::{
+    Details, Item,
     cairo::{CairoConfig, CairoDriver},
     driver::Driver,
     html::HtmlDriver,
@@ -28,7 +29,6 @@ use crate::output::{
         Look, PivotTable, RowColBorder, Stroke,
     },
     spv::SpvDriver,
-    Details, Item,
 };
 
 use super::{Axis3, Value};
index dfa292c911159f95193e31ce2359d48ca473fdfa..e8577848091e6afafc0d18e08f6a6e5666c526e6 100644 (file)
@@ -25,7 +25,7 @@ use crate::{
 };
 
 use super::{Area, BorderStyle, Color, HorzAlign, Look, Stroke, VertAlign};
-use binrw::{binread, BinRead, BinResult, Error as BinError};
+use binrw::{BinRead, BinResult, Error as BinError, binread};
 use enum_map::enum_map;
 
 #[binread]
index 075a1fa69f52bd62e64d9c0f5facc54c6f75e32f..61ac68af473169cd6342e1818501fa3d16aec751 100644 (file)
@@ -20,7 +20,7 @@ use std::iter::once;
 use std::ops::Range;
 use std::sync::Arc;
 
-use enum_map::{enum_map, Enum, EnumMap};
+use enum_map::{Enum, EnumMap, enum_map};
 use itertools::interleave;
 use num::Integer;
 use smallvec::SmallVec;
@@ -777,9 +777,11 @@ impl Page {
                         overflow[a][1] +=
                             pixel1 + self.axis_width(a, cell_ofs(z1)..cell_ofs(cell.rect[a].end));
                     }
-                    assert!(overflows
-                        .insert(s.coord_to_subpage(cell.rect.top_left()), overflow)
-                        .is_none());
+                    assert!(
+                        overflows
+                            .insert(s.coord_to_subpage(cell.rect.top_left()), overflow)
+                            .is_none()
+                    );
                 }
                 z += cell.rect[b].len();
             }
@@ -796,9 +798,11 @@ impl Page {
                 let mut overflow = self.overflows.get(&d).cloned().unwrap_or_default();
                 overflow[a][1] +=
                     pixel1 + self.axis_width(a, cell_ofs(z1)..cell_ofs(cell.rect[a].end));
-                assert!(overflows
-                    .insert(s.coord_to_subpage(cell.rect.top_left()), overflow)
-                    .is_none());
+                assert!(
+                    overflows
+                        .insert(s.coord_to_subpage(cell.rect.top_left()), overflow)
+                        .is_none()
+                );
             }
             z += cell.rect[b].len();
         }
@@ -1130,11 +1134,7 @@ fn measure_rule(device: &dyn Device, table: &Table, a: Axis2, z: usize) -> usize
         .into_iter()
         .map(
             |(rule, present)| {
-                if present {
-                    line_widths[rule]
-                } else {
-                    0
-                }
+                if present { line_widths[rule] } else { 0 }
             },
         )
         .max()
index 89ae457544974905fc72de7096e6c226398f3a79..9f7290f1b3f6b922b44482d231b8de76c48af19d 100644 (file)
@@ -28,16 +28,17 @@ use binrw::{BinWrite, Endian};
 use chrono::Utc;
 use enum_map::EnumMap;
 use quick_xml::{
-    events::{attributes::Attribute, BytesText},
-    writer::Writer as XmlWriter,
     ElementWriter,
+    events::{BytesText, attributes::Attribute},
+    writer::Writer as XmlWriter,
 };
 use serde::{Deserialize, Serialize};
-use zip::{result::ZipResult, write::SimpleFileOptions, ZipWriter};
+use zip::{ZipWriter, result::ZipResult, write::SimpleFileOptions};
 
 use crate::{
     format::{Format, Type},
     output::{
+        Item, Text,
         driver::Driver,
         page::{Heading, PageSetup},
         pivot::{
@@ -46,7 +47,6 @@ use crate::{
             Footnotes, Group, HeadingRegion, HorzAlign, LabelPosition, Leaf, PivotTable,
             RowColBorder, Stroke, Value, ValueInner, ValueStyle, VertAlign,
         },
-        Item, Text,
     },
     settings::Show,
     util::ToSmallString,
index d9ef87f6245cde0f7643a4880e80c2c3f96c8b57..98d5a0b16f4b7269c138d8a106c9464bf91034ec 100644 (file)
@@ -28,7 +28,7 @@
 
 use std::{ops::Range, sync::Arc};
 
-use enum_map::{enum_map, EnumMap};
+use enum_map::{EnumMap, enum_map};
 use ndarray::{Array, Array2};
 
 use crate::output::pivot::{Coord2, DisplayValue, Footnote, HorzAlign, ValueInner};
index 147f475d53d80e6b36dc7c5327d42f688e76ec49..990f1fae7a2ee0036dbf3424208fc21ae8f180f4 100644 (file)
@@ -24,20 +24,20 @@ use std::{
     sync::{Arc, LazyLock},
 };
 
-use enum_map::{enum_map, Enum, EnumMap};
+use enum_map::{Enum, EnumMap, enum_map};
 use serde::{Deserialize, Serialize};
-use unicode_linebreak::{linebreaks, BreakOpportunity};
+use unicode_linebreak::{BreakOpportunity, linebreaks};
 use unicode_width::UnicodeWidthStr;
 
 use crate::output::{render::Extreme, table::DrawCell, text_line::Emphasis};
 
 use super::{
+    Details, Item,
     driver::Driver,
     pivot::{Axis2, BorderStyle, Coord2, HorzAlign, PivotTable, Rect2, Stroke},
     render::{Device, Pager, Params},
     table::Content,
-    text_line::{clip_text, TextLine},
-    Details, Item,
+    text_line::{TextLine, clip_text},
 };
 
 #[derive(Clone, Debug, Default, Deserialize, Serialize)]
@@ -672,7 +672,9 @@ mod tests {
     fn test_line_breaks(input: &str, width: usize, expected: Vec<&str>) {
         let actual = new_line_breaks(input, width).collect::<Vec<_>>();
         if expected != actual {
-            panic!("filling {input:?} to {width} columns:\nexpected: {expected:?}\nactual:   {actual:?}");
+            panic!(
+                "filling {input:?} to {width} columns:\nexpected: {expected:?}\nactual:   {actual:?}"
+            );
         }
     }
     #[test]
index ac726cae464af3569185d216098667c22835716f..51ccfbef8e38f165e49babb1a9cacbc3d6f75011 100644 (file)
@@ -28,7 +28,7 @@ use codepage_437::CP437_WINGDINGS;
 use encoding_rs::WINDOWS_1252;
 use indexmap::set::MutableValues;
 use num::{Bounded, NumCast};
-use serde::{ser::SerializeSeq, Serialize, Serializer};
+use serde::{Serialize, Serializer, ser::SerializeSeq};
 
 use crate::{
     data::{ByteString, Case, Datum, RawString, WithEncoding},
@@ -1158,8 +1158,8 @@ mod tests {
     use crate::{
         data::cases_to_output,
         output::{
-            pivot::{tests::assert_lines_eq, PivotTable},
             Details, Item, Text,
+            pivot::{PivotTable, tests::assert_lines_eq},
         },
         por::{PortableFile, ReadPad},
     };
@@ -1170,7 +1170,10 @@ mod tests {
             b"abcdefghijklmnop\r\n0123456789\r\n",
         )))
         .lines();
-        assert_eq!(lines.next().unwrap().unwrap(), "abcdefghijklmnop                                                                0123456789                                                                      ");
+        assert_eq!(
+            lines.next().unwrap().unwrap(),
+            "abcdefghijklmnop                                                                0123456789                                                                      "
+        );
     }
 
     fn test_porfile(name: &str) {
index 15aad13820ede737655e4fa74e175d962038261e..c5150c96ab667b7c04d2e27578c8ed561b74fdbd 100644 (file)
@@ -295,11 +295,7 @@ where
 {
     fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
         fn handle_error(error: std::io::Error, ofs: usize) -> std::io::Result<usize> {
-            if ofs > 0 {
-                Ok(ofs)
-            } else {
-                Err(error)
-            }
+            if ofs > 0 { Ok(ofs) } else { Err(error) }
         }
 
         fn write_chunk<W>(mut writer: W, chunk: &[u8]) -> std::io::Result<usize>
@@ -831,15 +827,15 @@ mod tests {
 
     use encoding_rs::{UTF_8, WINDOWS_1252};
     use indexmap::set::MutableValues;
-    use itertools::{zip_eq, Itertools};
+    use itertools::{Itertools, zip_eq};
 
     use crate::{
         data::{ByteString, Datum, RawString},
         dictionary::Dictionary,
         identifier::Identifier,
         por::{
-            write::{write_case, DictionaryWriter, Precision, TrigesimalFloat, TrigesimalInt},
             WriteOptions,
+            write::{DictionaryWriter, Precision, TrigesimalFloat, TrigesimalInt, write_case},
         },
         variable::{MissingValueRange, MissingValues, VarWidth, Variable},
     };
@@ -1242,12 +1238,20 @@ A1/\
         output.sort();
 
         let expected = [
-   ("1/4/VAR01/", vec!["1/3/One"]),
-    ("1/4/VAR31/", vec!["4/abcd3/One"]),
-    ("1/4/VAR41/", vec!["8/abcdefghI/Longer value label"]),
-    ("1/4/VAR51/", vec!["9/abcdefghiS/value label for 9-byte value"]),
-    ("1/4/VAR61/", vec!["A0/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx10/value label for 300-byte value"]),
-    ("2/4/VAR14/VAR22/", vec!["1/3/One", "2/3/Two"]),
+            ("1/4/VAR01/", vec!["1/3/One"]),
+            ("1/4/VAR31/", vec!["4/abcd3/One"]),
+            ("1/4/VAR41/", vec!["8/abcdefghI/Longer value label"]),
+            (
+                "1/4/VAR51/",
+                vec!["9/abcdefghiS/value label for 9-byte value"],
+            ),
+            (
+                "1/4/VAR61/",
+                vec![
+                    "A0/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx10/value label for 300-byte value",
+                ],
+            ),
+            ("2/4/VAR14/VAR22/", vec!["1/3/One", "2/3/Two"]),
         ];
 
         for (actual, (exp_prefix, exp_suffixes)) in zip_eq(output, expected) {
index 699425e85cefdde2e3cc3a0c9e5089c4c3d54c2d..2a866c5d470bc0fcfca57807d690907dca10bd0c 100644 (file)
 // this program.  If not, see <http://www.gnu.org/licenses/>.
 
 use crate::parse_encoding;
-use anyhow::{anyhow, Result};
+use anyhow::{Result, anyhow};
 use clap::{Args, ValueEnum};
 use encoding_rs::Encoding;
 use pspp::{
     data::cases_to_output,
     output::{
+        Details, Item, Text,
         driver::{Config, Driver},
         pivot::PivotTable,
-        Details, Item, Text,
     },
     sys::{
-        raw::{infer_encoding, Decoder, EncodingReport, Magic, Reader, Record},
         Records,
+        raw::{Decoder, EncodingReport, Magic, Reader, Record, infer_encoding},
     },
 };
 use serde::Serialize;
@@ -36,7 +36,7 @@ use std::{
     ffi::OsStr,
     fmt::{Display, Write as _},
     fs::File,
-    io::{stdout, BufReader, Write},
+    io::{BufReader, Write, stdout},
     path::{Path, PathBuf},
     rc::Rc,
     sync::Arc,
index 28529e231529714d099a31e1a2dbfd13734daaca..d0ba365ecaedfa949ecb78e6d1d79a47356c15c8 100644 (file)
 // You should have received a copy of the GNU General Public License along with
 // this program.  If not, see <http://www.gnu.org/licenses/>.
 
-use anyhow::{anyhow, Result};
+use anyhow::{Result, anyhow};
 use clap::{Args, ValueEnum};
 use pspp::{
     data::cases_to_output,
     output::{
+        Details, Item, Text,
         driver::{Config, Driver},
         pivot::PivotTable,
-        Details, Item, Text,
     },
     por::PortableFile,
 };
@@ -31,7 +31,7 @@ use std::{
     ffi::OsStr,
     fmt::{Display, Write as _},
     fs::File,
-    io::{stdout, BufReader, Write},
+    io::{BufReader, Write, stdout},
     path::{Path, PathBuf},
     rc::Rc,
     sync::Arc,
index 78440d801c35931b4290e34002fa426cc7d9a914..7316d29b9d0f7c724e9e0687ad8f7102e1859121 100644 (file)
@@ -36,7 +36,7 @@ use crate::{
     output::pivot::{Axis3, Dimension, Group, PivotTable, Value},
     sys::{
         raw::{
-            self, infer_encoding,
+            self, DecodedRecord, RawCases, RawDatum, RawWidth, Reader, infer_encoding,
             records::{
                 Compression, DocumentRecord, EncodingRecord, Extension, FileAttributesRecord,
                 FileHeader, FloatInfoRecord, IntegerInfoRecord, LongName, LongNamesRecord,
@@ -45,13 +45,12 @@ use crate::{
                 VarDisplayRecord, VariableAttributesRecord, VariableRecord, VariableSetRecord,
                 VeryLongStringsRecord,
             },
-            DecodedRecord, RawCases, RawDatum, RawWidth, Reader,
         },
         serialize_endian,
     },
     variable::{InvalidRole, MissingValues, MissingValuesError, VarType, VarWidth, Variable},
 };
-use anyhow::{anyhow, Error as AnyError};
+use anyhow::{Error as AnyError, anyhow};
 use binrw::{BinRead, BinWrite, Endian};
 use chrono::{NaiveDate, NaiveDateTime, NaiveTime};
 use encoding_rs::{Encoding, UTF_8};
@@ -64,14 +63,18 @@ use thiserror::Error as ThisError;
 #[derive(ThisError, Clone, Debug)]
 pub enum Error {
     /// File creation date is not in the expected format format.
-    #[error("File creation date {0} is not in the expected format \"DD MMM YY\" format.  Using 01 Jan 1970.")]
+    #[error(
+        "File creation date {0} is not in the expected format \"DD MMM YY\" format.  Using 01 Jan 1970."
+    )]
     InvalidCreationDate(
         /// Date.
         String,
     ),
 
     /// File creation time is not in the expected format.
-    #[error("File creation time {0} is not in the expected format \"HH:MM:SS\" format.  Using midnight.")]
+    #[error(
+        "File creation time {0} is not in the expected format \"HH:MM:SS\" format.  Using midnight."
+    )]
     InvalidCreationTime(
         /// Time.
         String,
@@ -124,7 +127,9 @@ pub enum Error {
     /// Variable index {start_index} is a {width} that should be followed by
     /// long string continuation records through index {end_index} (inclusive),
     /// but index {error_index} is not a continuation.
-    #[error("Variable index {start_index} is a {width} that should be followed by long string continuation records through index {end_index} (inclusive), but index {error_index} is not a continuation")]
+    #[error(
+        "Variable index {start_index} is a {width} that should be followed by long string continuation records through index {end_index} (inclusive), but index {error_index} is not a continuation"
+    )]
     MissingLongStringContinuation {
         /// Width of variable.
         width: RawWidth,
@@ -200,9 +205,7 @@ pub enum Error {
     MrSetError(#[from] MrSetError),
 
     /// Invalid numeric format for counted value {number} in multiple response set {mr_set}.
-    #[error(
-        "Invalid numeric format for counted value {number} in multiple response set {mr_set}."
-    )]
+    #[error("Invalid numeric format for counted value {number} in multiple response set {mr_set}.")]
     InvalidMDGroupCountedValue {
         /// Multiple response set name.
         mr_set: Identifier,
@@ -254,7 +257,9 @@ pub enum Error {
 
     /// Variable with short name {short_name} listed in very long string record
     /// with width {width}, which requires only one segment.
-    #[error("Variable with short name {short_name} listed in very long string record with width {width}, which requires only one segment.")]
+    #[error(
+        "Variable with short name {short_name} listed in very long string record with width {width}, which requires only one segment."
+    )]
     ShortVeryLongString {
         /// Short variable name.
         short_name: Identifier,
@@ -266,7 +271,9 @@ pub enum Error {
     /// with width {width} requires string segments for {n_segments} dictionary
     /// indexes starting at index {index}, but the dictionary only contains
     /// {len} indexes.
-    #[error("Variable with short name {short_name} listed in very long string record with width {width} requires string segments for {n_segments} dictionary indexes starting at index {index}, but the dictionary only contains {len} indexes.")]
+    #[error(
+        "Variable with short name {short_name} listed in very long string record with width {width} requires string segments for {n_segments} dictionary indexes starting at index {index}, but the dictionary only contains {len} indexes."
+    )]
     VeryLongStringOverflow {
         /// Short variable name.
         short_name: Identifier,
@@ -283,7 +290,9 @@ pub enum Error {
     /// Variable with short name {short_name} listed in very long string record
     /// with width {width} has segment {index} of width {actual} (expected
     /// {expected}).
-    #[error("Variable with short name {short_name} listed in very long string record with width {width} has segment {index} of width {actual} (expected {expected}).")]
+    #[error(
+        "Variable with short name {short_name} listed in very long string record with width {width} has segment {index} of width {actual} (expected {expected})."
+    )]
     VeryLongStringInvalidSegmentWidth {
         /// Variable short name.
         short_name: Identifier,
@@ -306,7 +315,9 @@ pub enum Error {
 
     /// File designates string variable {name} (index {index}) as weight
     /// variable, but weight variables must be numeric.
-    #[error("File designates string variable {name} (index {index}) as weight variable, but weight variables must be numeric.")]
+    #[error(
+        "File designates string variable {name} (index {index}) as weight variable, but weight variables must be numeric."
+    )]
     InvalidWeightVar {
         /// Variable name.
         name: Identifier,
@@ -373,7 +384,9 @@ pub enum Error {
 
     /// Long string missing values record says variable {name} has {count}
     /// missing values, but only 1 to 3 missing values are allowed.
-    #[error("Long string missing values record says variable {name} has {count} missing values, but only 1 to 3 missing values are allowed.")]
+    #[error(
+        "Long string missing values record says variable {name} has {count} missing values, but only 1 to 3 missing values are allowed."
+    )]
     LongStringMissingValueInvalidCount {
         /// Variable name.
         name: Identifier,
@@ -391,7 +404,9 @@ pub enum Error {
     /// Unknown extension record with subtype {subtype} at offset {offset:#x},
     /// consisting of {count} {size}-byte units.  Please feel free to report
     /// this as a bug.
-    #[error("Unknown extension record with subtype {subtype} at offset {offset:#x}, consisting of {count} {size}-byte units.  Please feel free to report this as a bug.")]
+    #[error(
+        "Unknown extension record with subtype {subtype} at offset {offset:#x}, consisting of {count} {size}-byte units.  Please feel free to report this as a bug."
+    )]
     UnknownExtensionRecord {
         /// Extension record file starting offset.
         offset: u64,
index 4e7468829b39bc0b210b8a2058769ef6b221523f..f4ee5f3c8d4d8a5d0c675a2671078a43f847f440 100644 (file)
@@ -47,7 +47,9 @@ pub fn codepage_from_encoding(encoding: &'static Encoding) -> u32 {
 #[serde(rename_all = "snake_case")]
 pub enum Error {
     /// Warning that the system file doesn't indicate its own encoding.
-    #[error("This system file does not indicate its own character encoding.  For best results, specify an encoding explicitly.  Use SYSFILE INFO with ENCODING=\"DETECT\" to analyze the possible encodings.")]
+    #[error(
+        "This system file does not indicate its own character encoding.  For best results, specify an encoding explicitly.  Use SYSFILE INFO with ENCODING=\"DETECT\" to analyze the possible encodings."
+    )]
     NoEncoding,
 
     /// Unknown code page.
index a4c9990f21f394de283c5f049f46d8509e5c87d1..d9f770ba6a93fed7ffbd8cfa00fff251afa6d1ce 100644 (file)
@@ -24,11 +24,11 @@ use crate::{
     endian::{FromBytes, ToBytes},
     identifier::{Error as IdError, Identifier},
     output::{
-        pivot::{Axis3, Dimension, Group, PivotTable, Value},
         Details, Item, Text,
+        pivot::{Axis3, Dimension, Group, PivotTable, Value},
     },
     sys::{
-        encoding::{default_encoding, get_encoding, Error as EncodingError},
+        encoding::{Error as EncodingError, default_encoding, get_encoding},
         raw::records::{
             AttributeWarning, Compression, DocumentRecord, EncodingRecord, Extension,
             ExtensionWarning, FileAttributesRecord, FileHeader, FloatInfoRecord, HeaderWarning,
@@ -49,11 +49,11 @@ use crate::{
 
 use binrw::Endian;
 use encoding_rs::{
-    Encoding, BIG5, EUC_JP, EUC_KR, GB18030, IBM866, ISO_2022_JP, ISO_8859_10, ISO_8859_13,
-    ISO_8859_14, ISO_8859_16, ISO_8859_2, ISO_8859_3, ISO_8859_4, ISO_8859_5, ISO_8859_6,
-    ISO_8859_7, ISO_8859_8, KOI8_R, KOI8_U, MACINTOSH, SHIFT_JIS, UTF_8, WINDOWS_1250,
-    WINDOWS_1251, WINDOWS_1252, WINDOWS_1253, WINDOWS_1254, WINDOWS_1255, WINDOWS_1256,
-    WINDOWS_1257, WINDOWS_1258, WINDOWS_874,
+    BIG5, EUC_JP, EUC_KR, Encoding, GB18030, IBM866, ISO_2022_JP, ISO_8859_2, ISO_8859_3,
+    ISO_8859_4, ISO_8859_5, ISO_8859_6, ISO_8859_7, ISO_8859_8, ISO_8859_10, ISO_8859_13,
+    ISO_8859_14, ISO_8859_16, KOI8_R, KOI8_U, MACINTOSH, SHIFT_JIS, UTF_8, WINDOWS_874,
+    WINDOWS_1250, WINDOWS_1251, WINDOWS_1252, WINDOWS_1253, WINDOWS_1254, WINDOWS_1255,
+    WINDOWS_1256, WINDOWS_1257, WINDOWS_1258,
 };
 use flate2::bufread::ZlibDecoder;
 use indexmap::IndexMap;
@@ -65,7 +65,7 @@ use std::{
     cell::RefCell,
     collections::VecDeque,
     fmt::{Debug, Display, Formatter, Result as FmtResult},
-    io::{empty, BufRead, Error as IoError, Read, Seek, SeekFrom},
+    io::{BufRead, Error as IoError, Read, Seek, SeekFrom, empty},
     iter::repeat_n,
     mem::take,
     num::NonZeroU8,
@@ -149,9 +149,7 @@ pub enum ErrorDetails {
     InvalidZsavCompression(u32),
 
     /// Document record has document line count ({n}) greater than the maximum number {max}.
-    #[error(
-        "Document record has document line count ({n}) greater than the maximum number {max}."
-    )]
+    #[error("Document record has document line count ({n}) greater than the maximum number {max}.")]
     BadDocumentLength {
         /// Number of document lines.
         n: usize,
@@ -194,10 +192,9 @@ pub enum ErrorDetails {
 
     /// Following value label record, found record type {0} instead of expected
     /// type 4 for variable index record.
-    #[
-        error(
-            "Following value label record, found record type {0} instead of expected type 4 for variable index record"
-        )]
+    #[error(
+        "Following value label record, found record type {0} instead of expected type 4 for variable index record"
+    )]
     ExpectedVarIndexRecord(
         /// Record type.
         u32,
@@ -229,7 +226,9 @@ pub enum ErrorDetails {
     },
 
     /// Unexpected end of file {case_ofs} bytes into a {case_len}-byte case.
-    #[error("Unexpected end of file {case_ofs} bytes into case {case_number} with expected length {case_len} bytes.")]
+    #[error(
+        "Unexpected end of file {case_ofs} bytes into case {case_number} with expected length {case_len} bytes."
+    )]
     EofInCase {
         /// Offset into case in bytes.
         case_ofs: u64,
@@ -2291,7 +2290,7 @@ fn common_prefix<'a>(a: &'a str, b: &'a str) -> &'a str {
                 }
             }
             EitherOrBoth::Left((offset, _)) | EitherOrBoth::Right((offset, _)) => {
-                return &a[..offset]
+                return &a[..offset];
             }
         }
     }
index a977eddcf4a49555b5091bb9e54fa1f40c282a5a..592d29b54f03906e4a22432bcc797866ab66f742 100644 (file)
@@ -18,11 +18,12 @@ use crate::{
     format::{DisplayPlain, Format, Type},
     identifier::{Error as IdError, Identifier},
     sys::{
+        ProductVersion,
         raw::{
-            read_bytes, read_string, read_vec, Decoder, Error, ErrorDetails, Magic, RawDatum,
-            RawWidth, Record, RecordString, UntypedDatum, VarTypes, Warning, WarningDetails,
+            Decoder, Error, ErrorDetails, Magic, RawDatum, RawWidth, Record, RecordString,
+            UntypedDatum, VarTypes, Warning, WarningDetails, read_bytes, read_string, read_vec,
         },
-        serialize_endian, ProductVersion,
+        serialize_endian,
     },
     variable::{
         Alignment, Attributes, Measure, MissingValueRange, MissingValues, MissingValuesError,
@@ -30,11 +31,11 @@ use crate::{
     },
 };
 
-use binrw::{binrw, BinRead, BinWrite, Endian, Error as BinError};
+use binrw::{BinRead, BinWrite, Endian, Error as BinError, binrw};
 use clap::ValueEnum;
 use encoding_rs::Encoding;
 use itertools::Itertools;
-use serde::{ser::SerializeTuple, Serialize, Serializer};
+use serde::{Serialize, Serializer, ser::SerializeTuple};
 use thiserror::Error as ThisError;
 
 /// Type of compression in a system file.
@@ -288,9 +289,9 @@ struct RawFormatDisplayMeaning(RawFormat);
 
 impl Display for RawFormatDisplayMeaning {
     fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {
-        let type_ = format_name(self.0 .0 >> 16);
-        let w = (self.0 .0 >> 8) & 0xff;
-        let d = self.0 .0 & 0xff;
+        let type_ = format_name(self.0.0 >> 16);
+        let w = (self.0.0 >> 8) & 0xff;
+        let d = self.0.0 & 0xff;
         write!(f, "{type_}{w}.{d}")
     }
 }
@@ -396,7 +397,7 @@ impl RawMissingValues {
                 return Err(Error::new(
                     Some(offsets),
                     ErrorDetails::BadMissingValueCode(code),
-                ))
+                ));
             }
         };
 
index 348fda6bf5b6c284c7f4fee89dde84f30d8acf3e..d2ccfccc365b756d264904dbea0dc472a7d2c26b 100644 (file)
@@ -18,7 +18,7 @@ use binrw::Endian;
 use num::{Bounded, Zero};
 use ordered_float::OrderedFloat;
 use std::{
-    collections::{hash_map::Entry, HashMap},
+    collections::{HashMap, hash_map::Entry},
     error::Error as StdError,
     fmt::{Display, Formatter, Result as FmtResult},
     iter::repeat_n,
index 64750fed06c720a17e299e751d96ecf758288ee1..857e12ce8ea10bcda795b8388c06f7a83f21b1bd 100644 (file)
@@ -31,14 +31,14 @@ use crate::{
     dictionary::Dictionary,
     identifier::Identifier,
     output::{
-        pivot::{tests::assert_lines_eq, Axis3, Dimension, Group, PivotTable, Value},
         Details, Item, Text,
+        pivot::{Axis3, Dimension, Group, PivotTable, Value, tests::assert_lines_eq},
     },
     sys::{
+        WriteOptions,
         cooked::ReadOptions,
-        raw::{self, records::Compression, ErrorDetails},
+        raw::{self, ErrorDetails, records::Compression},
         sack::sack,
-        WriteOptions,
     },
     variable::{VarWidth, Variable},
 };
@@ -567,7 +567,10 @@ fn encrypted_file_without_password() {
     .open_file("src/crypto/testdata/test-encrypted.sav")
     .unwrap_err();
     assert!(matches!(
-        error.downcast::<raw::Error>().unwrap().details,
+        error
+            .downcast::<raw::Error<ErrorDetails>>()
+            .unwrap()
+            .details,
         ErrorDetails::Encrypted
     ));
 }
@@ -672,13 +675,25 @@ fn write_string(compression: Option<Compression>, compression_string: &str) {
         .write_writer(&dictionary, Cursor::new(Vec::new()))
         .unwrap();
     for case in [
-            ["1", "1", "1", "xyzzyquux", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\nabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\nabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\nabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\nabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\nabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\nabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\nabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\nabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\n"],
-            ["1", "2", "1", "8", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"],
-        ] {
-            cases
-                .write_case(case.into_iter().map(|s| Datum::String(s)))
-                .unwrap();
-        }
+        [
+            "1",
+            "1",
+            "1",
+            "xyzzyquux",
+            "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\nabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\nabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\nabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\nabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\nabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\nabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\nabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\nabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\n",
+        ],
+        [
+            "1",
+            "2",
+            "1",
+            "8",
+            "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
+        ],
+    ] {
+        cases
+            .write_case(case.into_iter().map(|s| Datum::String(s)))
+            .unwrap();
+    }
     let sysfile = cases.finish().unwrap().unwrap().into_inner();
     let expected_filename = PathBuf::from(&format!(
         "src/sys/testdata/write-string-{compression_string}.expected"
index 60f4b2cfceb48f90062470453123ed3cedcf2b1e..741a9dd42328bdda40c6fdbbadaab65d7123a802 100644 (file)
@@ -39,15 +39,15 @@ use crate::{
     identifier::Identifier,
     output::spv::Zeros,
     sys::{
+        ProductVersion,
         encoding::codepage_from_encoding,
         raw::{
+            Magic,
             records::{
                 Compression, FloatInfoRecord, RawFormat, RawHeader, RawIntegerInfoRecord,
                 RawVariableRecord, RawZHeader, RawZTrailer, ZBlock,
             },
-            Magic,
         },
-        ProductVersion,
     },
     variable::{Alignment, Attributes, Measure, ValueLabels, VarWidth},
 };
@@ -1232,14 +1232,14 @@ mod tests {
         },
         identifier::Identifier,
         sys::{
+            ReadOptions, WriteOptions,
             raw::{
+                Decoder, VarTypes,
                 records::{
                     DocumentRecord, Extension, RawHeader, RawVariableRecord, VariableRecord,
                 },
-                Decoder, VarTypes,
             },
             write::DictionaryWriter,
-            ReadOptions, WriteOptions,
         },
         variable::{Alignment, Attributes, Measure, MissingValueRange, VarWidth, Variable},
     };
@@ -1694,10 +1694,12 @@ mod tests {
             .unwrap()
             .dictionary;
 
-        assert!(actual
-            .variable_sets()
-            .iter()
-            .eq(expected.variable_sets().iter()),);
+        assert!(
+            actual
+                .variable_sets()
+                .iter()
+                .eq(expected.variable_sets().iter()),
+        );
     }
 
     /// Test writing multiple response sets.
index 3b4f72741e76523406d5f1b4130db529fb1a4b2d..1ebad2cbc33461ea0c7aff7b7d1a0514c49ace2f 100644 (file)
@@ -29,7 +29,7 @@ use encoding_rs::{Encoding, UTF_8};
 use hashbrown::HashMap;
 use indexmap::Equivalent;
 use num::integer::div_ceil;
-use serde::{ser::SerializeSeq, Serialize};
+use serde::{Serialize, ser::SerializeSeq};
 use thiserror::Error as ThisError;
 use unicase::UniCase;