From 67a4929c7680afea4efbc6e5498913f7d3a5a6ea Mon Sep 17 00:00:00 2001 From: sorenholsthansen Date: Wed, 20 Apr 2022 00:41:30 +0200 Subject: [PATCH] Added impl of CursorType for floats --- src/types/connection/cursor.rs | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/types/connection/cursor.rs b/src/types/connection/cursor.rs index fdb67319..15d9faa8 100644 --- a/src/types/connection/cursor.rs +++ b/src/types/connection/cursor.rs @@ -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 { + s.parse() + } + + fn encode_cursor(&self) -> String { + self.to_string() + } +} + +impl CursorType for f32 { + type Error = ParseFloatError; + + fn decode_cursor(s: &str) -> Result { + s.parse() + } + + fn encode_cursor(&self) -> String { + self.to_string() + } +}