Skip to content

Commit

Permalink
[#15] impl QueryString 실수 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
myyrakle committed Aug 26, 2024
1 parent 15fef4b commit d4c90ba
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions rupring/src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,30 @@ impl QueryStringDeserializer<usize> for QueryString {
}
}

impl QueryStringDeserializer<f32> for QueryString {
type Error = ();

fn deserialize(&self) -> Result<f32, Self::Error> {
if let Some(e) = self.0.get(0) {
e.parse::<f32>().map_err(|_| ())
} else {
Err(())
}
}
}

impl QueryStringDeserializer<f64> for QueryString {
type Error = ();

fn deserialize(&self) -> Result<f64, Self::Error> {
if let Some(e) = self.0.get(0) {
e.parse::<f64>().map_err(|_| ())
} else {
Err(())
}
}
}

#[derive(Debug, Clone)]
pub struct ParamString(pub String);

Expand Down

0 comments on commit d4c90ba

Please sign in to comment.