1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
pub struct Unit { coe: i32, pow: i32, } impl Unit { pub fn new(coe: i32, pow: i32) -> Unit { Unit { coe, pow, } } pub fn build_string(&self) -> String { format!("{}x^{}", self.coe, self.pow) } }