From 9ff5cd7990a59adcfe6ac728843ffff1d2311240 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Fri, 10 Oct 2025 22:11:08 -0700 Subject: [PATCH] Drop flagset crate in favor of enumset. --- rust/Cargo.lock | 7 ------ rust/pspp/Cargo.toml | 1 - rust/pspp/src/command.rs | 35 +++++++++++++-------------- rust/pspp/src/command/crosstabs.rs | 4 +-- rust/pspp/src/command/ctables.rs | 4 +-- rust/pspp/src/command/data_list.rs | 4 +-- rust/pspp/src/command/descriptives.rs | 4 +-- 7 files changed, 25 insertions(+), 34 deletions(-) diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 814831bacf..ca955f116f 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -782,12 +782,6 @@ dependencies = [ "windows-sys 0.59.0", ] -[[package]] -name = "flagset" -version = "0.4.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7ac824320a75a52197e8f2d787f6a38b6718bb6897a35142d749af3c0e8f4fe" - [[package]] name = "flate2" version = "1.1.1" @@ -1878,7 +1872,6 @@ dependencies = [ "enum-iterator", "enum-map", "enumset", - "flagset", "flate2", "hashbrown 0.15.5", "hexplay", diff --git a/rust/pspp/Cargo.toml b/rust/pspp/Cargo.toml index 60337e1db7..1f60f971cf 100644 --- a/rust/pspp/Cargo.toml +++ b/rust/pspp/Cargo.toml @@ -22,7 +22,6 @@ indexmap = { version = "2.1.0", features = ["serde"] } unicode-width = "0.2.0" chardetng = "0.1.17" enum-map = { version = "2.7.3", features = ["serde"] } -flagset = "0.4.6" pspp-derive = { version = "0.1.0", path = "../pspp-derive" } either = "1.13.0" enum-iterator = "2.1.0" diff --git a/rust/pspp/src/command.rs b/rust/pspp/src/command.rs index 471bb84485..78f88f708b 100644 --- a/rust/pspp/src/command.rs +++ b/rust/pspp/src/command.rs @@ -26,7 +26,7 @@ use ctables::ctables_command; use data_list::data_list_command; use descriptives::descriptives_command; use either::Either; -use flagset::{FlagSet, flags}; +use enumset::{EnumSet, EnumSetType}; use pspp_derive::FromTokens; use crate::{ @@ -46,30 +46,29 @@ pub mod ctables; pub mod data_list; pub mod descriptives; -flags! { - enum State: u8 { - /// No active dataset yet defined. - Initial, +#[derive(Debug, EnumSetType)] +enum State { + /// No active dataset yet defined. + Initial, - /// Active dataset has been defined. - Data, + /// Active dataset has been defined. + Data, - /// Inside `INPUT PROGRAM`. - InputProgram, + /// Inside `INPUT PROGRAM`. + InputProgram, - /// Inside `FILE TYPE`. - FileType, + /// Inside `FILE TYPE`. + FileType, - /// State nested inside `LOOP` or `DO IF`, inside [State::Data]. - NestedData, + /// State nested inside `LOOP` or `DO IF`, inside [State::Data]. + NestedData, - /// State nested inside `LOOP` or `DO IF`, inside [State::InputProgram]. - NestedInputProgram, - } + /// State nested inside `LOOP` or `DO IF`, inside [State::InputProgram]. + NestedInputProgram, } struct Command { - allowed_states: FlagSet, + allowed_states: EnumSet, enhanced_only: bool, testing_only: bool, no_abbrev: bool, @@ -817,7 +816,7 @@ fn commands() -> &'static [Command] { ctables_command(), data_list_command(), Command { - allowed_states: FlagSet::full(), + allowed_states: EnumSet::all(), enhanced_only: false, testing_only: false, no_abbrev: false, diff --git a/rust/pspp/src/command/crosstabs.rs b/rust/pspp/src/command/crosstabs.rs index 38079857b8..53344af149 100644 --- a/rust/pspp/src/command/crosstabs.rs +++ b/rust/pspp/src/command/crosstabs.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License along with // this program. If not, see . -use flagset::FlagSet; +use enumset::EnumSet; use super::{By, Comma, Command, Equals, Integer, Number, Punctuated, Subcommands, VarList}; use crate::command::{ @@ -24,7 +24,7 @@ use crate::command::{ pub(super) fn crosstabs_command() -> Command { Command { - allowed_states: FlagSet::full(), + allowed_states: EnumSet::all(), enhanced_only: false, testing_only: false, no_abbrev: false, diff --git a/rust/pspp/src/command/ctables.rs b/rust/pspp/src/command/ctables.rs index a42e9fcd2d..2556bdd8cc 100644 --- a/rust/pspp/src/command/ctables.rs +++ b/rust/pspp/src/command/ctables.rs @@ -17,7 +17,7 @@ use std::fmt::Debug; use either::Either; -use flagset::FlagSet; +use enumset::EnumSet; use super::{ And, Asterisk, By, Command, Dash, Equals, Exp, Gt, InSquares, Integer, Number, Plus, @@ -31,7 +31,7 @@ use crate::{ pub(super) fn ctables_command() -> Command { Command { - allowed_states: FlagSet::full(), + allowed_states: EnumSet::all(), enhanced_only: false, testing_only: false, no_abbrev: false, diff --git a/rust/pspp/src/command/data_list.rs b/rust/pspp/src/command/data_list.rs index ea52f708a6..c5becd3657 100644 --- a/rust/pspp/src/command/data_list.rs +++ b/rust/pspp/src/command/data_list.rs @@ -15,7 +15,7 @@ // this program. If not, see . use either::Either; -use flagset::FlagSet; +use enumset::EnumSet; use super::{Comma, Command, Equals, Integer, Punctuated, Seq0, Seq1, Slash}; use crate::{ @@ -25,7 +25,7 @@ use crate::{ pub(super) fn data_list_command() -> Command { Command { - allowed_states: FlagSet::full(), + allowed_states: EnumSet::all(), enhanced_only: false, testing_only: false, no_abbrev: false, diff --git a/rust/pspp/src/command/descriptives.rs b/rust/pspp/src/command/descriptives.rs index 9f8fb2d8b6..656274dffa 100644 --- a/rust/pspp/src/command/descriptives.rs +++ b/rust/pspp/src/command/descriptives.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License along with // this program. If not, see . -use flagset::FlagSet; +use enumset::EnumSet; use super::{Comma, Command, Equals, Punctuated, Seq1, Subcommands}; use crate::command::{ @@ -24,7 +24,7 @@ use crate::command::{ pub(super) fn descriptives_command() -> Command { Command { - allowed_states: FlagSet::full(), + allowed_states: EnumSet::all(), enhanced_only: false, testing_only: false, no_abbrev: false, -- 2.30.2