@@ -51,7 +51,14 @@ impl Display for NoSubscriptKnown {
5151
5252impl Error for NoSubscriptKnown { }
5353
54- pub fn subscript_char ( ch : char ) -> Result < char , NoSubscriptKnown > {
54+ /// Return the corresponding subscript representation for `ch`.
55+ ///
56+ /// # Errors
57+ /// `NoSubscriptKnown` when no corresponding subscript is known,
58+ pub const fn subscript_char ( ch : char ) -> Result < char , NoSubscriptKnown > {
59+ // The cases here are ordered so as to make it obvious when an
60+ // item is missing, and so we expect that some of the failure
61+ // cases will have the same bodies.
5562 match ch {
5663 '0' => Ok ( '\u{2080}' ) , // ₀
5764 '1' => Ok ( '\u{2081}' ) , // ₁
@@ -85,7 +92,15 @@ impl Display for NoSuperscriptKnown {
8592
8693impl Error for NoSuperscriptKnown { }
8794
95+ /// Return the corresponding superscript representation for `ch`.
96+ ///
97+ /// # Errors
98+ /// `NoSuperscriptKnown` when no corresponding superscript is known,
8899pub fn superscript_char ( ch : char ) -> Result < char , NoSuperscriptKnown > {
100+ // The cases here are ordered so as to make it obvious when an
101+ // item is missing, and so we expect that some of the failure
102+ // cases will have the same bodies.
103+ #[ allow( clippy:: match_same_arms) ]
89104 match ch {
90105 '0' => Ok ( '\u{2070}' ) ,
91106 '1' => Ok ( '\u{00B9}' ) ,
@@ -174,6 +189,7 @@ pub enum Script {
174189}
175190
176191impl Script {
192+ #[ must_use]
177193 pub fn shift ( & self ) -> u32 {
178194 match self {
179195 Script :: Super => 30 , // This is a config value.
@@ -209,7 +225,7 @@ pub enum LwKeyboardCase {
209225}
210226
211227impl LwKeyboardCase {
212- fn as_str ( & self ) -> & ' static str {
228+ fn as_str ( self ) -> & ' static str {
213229 match self {
214230 LwKeyboardCase :: Lower => "lower" ,
215231 LwKeyboardCase :: Upper => "upper" ,
@@ -305,7 +321,7 @@ pub struct DescribedChar {
305321 /// or normal character, and what colour it is.
306322 pub base_char : LincolnChar ,
307323 /// If the character has a direct Unicode translation, that is in
308- /// unicode_representation. Some characters, for example
324+ /// ` unicode_representation` . Some characters, for example
309325 /// superscript Y, have no Unicode representation.
310326 pub unicode_representation : Option < char > ,
311327 /// Specifies whether the character is upper-case, lower-case
@@ -330,7 +346,7 @@ fn unprintable(c: Unsigned6Bit, state: LincolnState) -> DescribedChar {
330346 label_matches_unicode : false ,
331347 }
332348}
333- fn bycase ( lower : char , upper : char , state : & LincolnState ) -> Option < char > {
349+ const fn bycase ( lower : char , upper : char , state : LincolnState ) -> Option < char > {
334350 Some ( match state. case {
335351 LwKeyboardCase :: Upper => upper,
336352 LwKeyboardCase :: Lower => lower,
@@ -408,7 +424,7 @@ pub fn lincoln_char_to_described_char(
408424) -> Option < DescribedChar > {
409425 lincoln_writer_state_update ( lin_ch, state) ;
410426 let advance: bool = lin_ch != 0o12 && lin_ch != 0o13 ;
411- let by_case = |lower, upper : char | -> Option < char > { bycase ( lower, upper, state) } ;
427+ let by_case = |lower, upper : char | -> Option < char > { bycase ( lower, upper, * state) } ;
412428 let base_char: Option < char > = match u8:: from ( lin_ch) {
413429 0o00 => by_case ( '0' , '☛' ) , // \U261B, black hand pointing right
414430 0o01 => by_case ( '1' , 'Σ' ) , // \U03A3, Greek capital letter Sigma
0 commit comments