Skip to content

Commit 2ad77c2

Browse files
authored
derive Default for enums (#229)
1 parent f9f3217 commit 2ad77c2

File tree

3 files changed

+6
-21
lines changed

3 files changed

+6
-21
lines changed

crates/jiter/src/lib.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -178,19 +178,14 @@ pub use py_string_cache::{
178178
#[cfg(feature = "python")]
179179
pub use python::{map_json_error, PythonParse};
180180

181-
#[derive(Debug, Clone, Copy)]
181+
#[derive(Debug, Clone, Copy, Default)]
182182
pub enum PartialMode {
183+
#[default]
183184
Off,
184185
On,
185186
TrailingStrings,
186187
}
187188

188-
impl Default for PartialMode {
189-
fn default() -> Self {
190-
Self::Off
191-
}
192-
}
193-
194189
impl From<bool> for PartialMode {
195190
fn from(mode: bool) -> Self {
196191
if mode {

crates/jiter/src/py_lossless_float.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,14 @@ use pyo3::types::PyType;
55

66
use crate::Jiter;
77

8-
#[derive(Debug, Clone, Copy)]
8+
#[derive(Debug, Clone, Copy, Default)]
99
pub enum FloatMode {
10+
#[default]
1011
Float,
1112
Decimal,
1213
LosslessFloat,
1314
}
1415

15-
impl Default for FloatMode {
16-
fn default() -> Self {
17-
Self::Float
18-
}
19-
}
20-
2116
const FLOAT_ERROR: &str = "Invalid float mode, should be `'float'`, `'decimal'` or `'lossless-float'`";
2217

2318
impl<'py> FromPyObject<'_, 'py> for FloatMode {

crates/jiter/src/py_string_cache.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,14 @@ use pyo3::types::{PyBool, PyString};
77

88
use crate::string_decoder::StringOutput;
99

10-
#[derive(Debug, Clone, Copy)]
10+
#[derive(Debug, Clone, Copy, Default)]
1111
pub enum StringCacheMode {
12+
#[default]
1213
All,
1314
Keys,
1415
None,
1516
}
1617

17-
impl Default for StringCacheMode {
18-
fn default() -> Self {
19-
Self::All
20-
}
21-
}
22-
2318
impl<'py> FromPyObject<'_, 'py> for StringCacheMode {
2419
type Error = PyErr;
2520

0 commit comments

Comments
 (0)