From c43c5bab499cb51a8c7cf2a7da89da3009c1600e Mon Sep 17 00:00:00 2001 From: Temirkhan Myrzamadi Date: Tue, 28 Jul 2020 01:06:40 +0600 Subject: [PATCH] Add setters to LabeledPrice --- src/types/label_price.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/types/label_price.rs b/src/types/label_price.rs index 0e003443..4c6841a9 100644 --- a/src/types/label_price.rs +++ b/src/types/label_price.rs @@ -20,6 +20,28 @@ pub struct LabeledPrice { pub amount: i32, } +impl LabeledPrice { + pub fn new(label: S, amount: i32) -> Self + where + S: Into, + { + Self { label: label.into(), amount } + } + + pub fn label(mut self, val: S) -> Self + where + S: Into, + { + self.label = val.into(); + self + } + + pub fn amount(mut self, val: i32) -> Self { + self.amount = val; + self + } +} + #[cfg(test)] mod tests { use super::*;