Skip to content

Commit 7bf6de6

Browse files
committed
💚 chore: default impl
1 parent 10648b9 commit 7bf6de6

File tree

4 files changed

+14
-23
lines changed

4 files changed

+14
-23
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "lta_models"
33
version = "0.6.0"
4-
authors = ["budinverse <[email protected]>"]
4+
authors = ["zeon256 <[email protected]>"]
55
edition = "2021"
66
license = "MIT"
77
description = "🚍Models for lta-rs"

src/bus_enums.rs

+8-20
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub enum Operator {
3737
/// DD -> Double Decker
3838
///
3939
/// BD -> Bendy
40-
#[derive(Debug, Clone, PartialEq, PartialOrd, Deserialize, Serialize)]
40+
#[derive(Debug, Clone, PartialEq, PartialOrd, Deserialize, Serialize, Default)]
4141
#[serde(rename_all = "PascalCase")]
4242
pub enum BusType {
4343
#[serde(rename = "SD")]
@@ -49,22 +49,17 @@ pub enum BusType {
4949
#[serde(rename = "BD")]
5050
Bendy,
5151

52+
#[default]
5253
#[serde(other)]
5354
Unknown,
5455
}
5556

56-
impl Default for BusType {
57-
fn default() -> Self {
58-
BusType::Unknown
59-
}
60-
}
61-
6257
/// SEA -> Seats available
6358
///
6459
/// SDA -> Standing available
6560
///
6661
/// LSD -> Limited standing
67-
#[derive(Debug, Clone, PartialEq, PartialOrd, Deserialize, Serialize)]
62+
#[derive(Debug, Clone, PartialEq, PartialOrd, Deserialize, Serialize, Default)]
6863
pub enum BusLoad {
6964
#[serde(rename = "SEA")]
7065
SeatsAvailable,
@@ -75,32 +70,24 @@ pub enum BusLoad {
7570
#[serde(rename = "LSD")]
7671
LimitedStanding,
7772

73+
#[default]
7874
#[serde(other)]
7975
Unknown,
8076
}
8177

82-
impl Default for BusLoad {
83-
fn default() -> Self {
84-
BusLoad::Unknown
85-
}
86-
}
8778

88-
#[derive(Debug, Clone, PartialEq, PartialOrd, Deserialize, Serialize)]
79+
#[derive(Debug, Clone, PartialEq, PartialOrd, Deserialize, Serialize, Default)]
8980
pub enum BusFeature {
9081
#[serde(rename = "WAB")]
9182
WheelChairAccessible,
9283

84+
#[default]
9385
#[serde(other)]
9486
Unknown,
9587
}
9688

97-
impl Default for BusFeature {
98-
fn default() -> Self {
99-
BusFeature::Unknown
100-
}
101-
}
10289

103-
#[derive(Debug, Clone, PartialEq, PartialOrd, Deserialize, Serialize)]
90+
#[derive(Debug, Clone, PartialEq, PartialOrd, Deserialize, Serialize, Default)]
10491
pub enum BusCategory {
10592
#[serde(alias = "EXPRESS")]
10693
Express,
@@ -132,6 +119,7 @@ pub enum BusCategory {
132119
#[serde(alias = "FLAT FARE $2.00")]
133120
FlatFareTwoDollar,
134121

122+
#[default]
135123
#[serde(other)]
136124
Unknown,
137125
}

src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
//! Data Structures for lta-rs and for LTA datamall APIs
22
33
// Forbid warnings in release builds:
4+
#![forbid(unsafe_code)]
45
#![cfg_attr(not(debug_assertions), deny(warnings))]
56
#![warn(
67
clippy::all,
8+
clippy::linkedlist,
79
clippy::await_holding_lock,
810
clippy::char_lit_as_u8,
911
clippy::checked_conversions,
@@ -26,7 +28,6 @@
2628
clippy::invalid_upcast_comparisons,
2729
clippy::large_types_passed_by_value,
2830
clippy::let_unit_value,
29-
clippy::linkedlist,
3031
clippy::lossy_float_literal,
3132
clippy::macro_use_imports,
3233
clippy::manual_ok_or,

src/utils.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,9 @@ pub mod de {
234234
write!(f, "StringWrapErr")
235235
}
236236
}
237-
237+
238+
/// # Errors
239+
/// Fails when data cant be deserialized to String
238240
pub fn treat_error_as_none<'de, T, D>(deserializer: D) -> Result<Option<T>, D::Error>
239241
where
240242
T: Deserialize<'de>,

0 commit comments

Comments
 (0)