From 8b415320df73b54808ae06d0bf22adcb7dc706ee Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 8 Mar 2023 10:53:10 -0600 Subject: Add trivial derives to `utf8parser::Parser` Much like `std::ops::Range`, we likely don't want this to be `Copy` as that makes it too easy to get mixed up on what state you are using but `Clone` should be explicit enough to be safe. `PartialOrd` / `Ord` were left off because there isn't really a user-facing ordering to these types `Hash` was left off as the use cases for it isn't clear. --- utf8parse/src/lib.rs | 2 +- utf8parse/src/types.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'utf8parse/src') diff --git a/utf8parse/src/lib.rs b/utf8parse/src/lib.rs index 947a0aa..093de81 100644 --- a/utf8parse/src/lib.rs +++ b/utf8parse/src/lib.rs @@ -25,7 +25,7 @@ pub trait Receiver { /// A parser for Utf8 Characters /// /// Repeatedly call `advance` with bytes to emit Utf8 characters -#[derive(Default)] +#[derive(Clone, Default, PartialEq, Eq, Debug)] pub struct Parser { point: u32, state: State, diff --git a/utf8parse/src/types.rs b/utf8parse/src/types.rs index 77a79cc..f57a94d 100644 --- a/utf8parse/src/types.rs +++ b/utf8parse/src/types.rs @@ -26,7 +26,7 @@ pub enum Action { /// There is a state for each initial input of the 3 and 4 byte sequences since /// the following bytes are subject to different conditions than a tail byte. #[allow(non_camel_case_types)] -#[derive(Debug, Copy, Clone)] +#[derive(Debug, Copy, Clone, PartialEq, Eq)] pub enum State { /// Ground state; expect anything Ground = 0, -- cgit