chiark / gitweb /
currency: Break out describe()
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 19 May 2022 19:36:15 +0000 (20:36 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 19 May 2022 19:54:44 +0000 (20:54 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/currency.rs

index 23d84ae38e6a3a9c7c0365847f6ef53b38fbbae5..bce79d678414d4bb893333fa2be4f3f654949eee 100644 (file)
@@ -112,9 +112,7 @@ impl PieceTrait for Banknote {
   #[throws(IE)]
   fn describe_html(&self, gpc: &GPiece, _: &GOccults) -> Html {
     let value: &Value = gpc.xdata.get_exp()?;
-    hformat!("{}, {}{}",
-             self.image.describe_html(gpc.face)?,
-             &value.html(), &self.currency)
+    self.describe(gpc.face, &value.html())?
   }
 
   #[throws(IE)]
@@ -289,6 +287,13 @@ impl Value {
 }
 
 impl Banknote {
+  #[throws(IE)]
+  fn describe(&self, face: FaceId, qty: &HtmlStr) -> Html {
+    hformat!("{}, {}{}",
+             self.image.describe_html(face)?,
+             qty, &self.currency)
+  }
+
   #[throws(IE)]
   fn render(&self, f: &mut Html, vpid: VisiblePieceId, face: FaceId,
             xdata_for_image_only: &PieceXDataState, qty: &HtmlStr) {