Added impl of CursorType for floats
This commit is contained in:
parent
1ba5113cd5
commit
67a4929c76
|
@ -1,6 +1,6 @@
|
|||
use std::convert::Infallible;
|
||||
use std::fmt::Display;
|
||||
use std::num::ParseIntError;
|
||||
use std::num::{ParseFloatError, ParseIntError};
|
||||
|
||||
use crate::ID;
|
||||
|
||||
|
@ -78,3 +78,27 @@ impl CursorType for ID {
|
|||
self.to_string()
|
||||
}
|
||||
}
|
||||
|
||||
impl CursorType for f64 {
|
||||
type Error = ParseFloatError;
|
||||
|
||||
fn decode_cursor(s: &str) -> Result<Self, Self::Error> {
|
||||
s.parse()
|
||||
}
|
||||
|
||||
fn encode_cursor(&self) -> String {
|
||||
self.to_string()
|
||||
}
|
||||
}
|
||||
|
||||
impl CursorType for f32 {
|
||||
type Error = ParseFloatError;
|
||||
|
||||
fn decode_cursor(s: &str) -> Result<Self, Self::Error> {
|
||||
s.parse()
|
||||
}
|
||||
|
||||
fn encode_cursor(&self) -> String {
|
||||
self.to_string()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue