Skip to content

Commit

Permalink
fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
NSoiffer committed Dec 20, 2023
1 parent ebdd19c commit bacfb8c
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 23 deletions.
4 changes: 2 additions & 2 deletions src/braille.rs
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ fn ueb_cleanup(pref_manager: Ref<PreferenceManager>, raw_braille: String) -> Str
}

fn convert_to_cap_passage_mode(braille: &str) -> String {
return "⠠⠠⠠".to_string() + &braille.replace(&['C', '𝐶'], "") + "⠠⠄";
return "⠠⠠⠠".to_string() + &braille.replace(['C', '𝐶'], "") + "⠠⠄";
}

/// Return true if the BANA or ICEB guidelines say it is ok to start with grade 2
Expand Down Expand Up @@ -2177,7 +2177,7 @@ impl NeedsToBeGrouped {
let text = as_text(mathml);
let parent = mathml.parent().unwrap().element().unwrap(); // there is always a "math" node
let parent_name = name(&parent); // there is always a "math" node
if is_base && (parent_name == "msub" || parent_name == "msup" || parent_name == "msubsup") && !text.contains(&[' ', '\u{00A0}']) {
if is_base && (parent_name == "msub" || parent_name == "msup" || parent_name == "msubsup") && !text.contains([' ', '\u{00A0}']) {
return false;
}
let mut chars = text.chars();
Expand Down
4 changes: 2 additions & 2 deletions src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ pub fn trim_element(e: &Element) {
}
if e.children().is_empty() && !single_text.is_empty() {
// debug!("Combining text in {}: '{}' -> '{}'", e.name().local_part(), single_text, trimmed_text);
e.set_text(&trimmed_text);
e.set_text(trimmed_text);
}

fn make_leaf_element(mathml_leaf: Element) {
Expand Down Expand Up @@ -493,7 +493,7 @@ pub fn trim_element(e: &Element) {
if !text.is_empty() {
text += space;
}
text += &child_text.trim_matches(WHITESPACE).to_string();
text += child_text.trim_matches(WHITESPACE);
}

}
Expand Down
28 changes: 20 additions & 8 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,21 @@ fn main() {
// </mrow>
// </math>";
let expr=r#"
<math><munder><mtext>this is a test</mtext><mrow><mi>x</mi><mo>&#x2192;</mo><mi>a</mi></mrow></munder>
<mi>f</mi><mo>(</mo><mi>x</mi><mo>)</mo><mo>=</mo><mn>1</mn></math>
"#;
<math display='block' id='id-0' data-id-added='true'>
<msup data-changed='added' id='id-1' data-id-added='true'>
<mrow data-changed='added' id='id-2' data-id-added='true'>
<mo stretchy='false' id='id-3' data-id-added='true'>(</mo>
<mrow data-changed='added' id='id-4' data-id-added='true'>
<mn id='id-5' data-id-added='true'>2</mn>
<mo data-changed='added' id='id-6' data-id-added='true'>&#x2062;</mo>
<mi id='id-7' data-id-added='true'>x</mi>
</mrow>
<mo stretchy='false' id='id-8' data-id-added='true'>)</mo>
</mrow>
<mn id='id-9' data-id-added='true'>2</mn>
</msup>
</math>
"#;

// let expr = "
// <math display='block'>
Expand Down Expand Up @@ -214,11 +226,11 @@ fn main() {
panic!("Error: exiting -- {}", errors_to_string(&e));
};

// match get_spoken_text() {
// Ok(speech) => info!("Computed speech string:\n '{}'", speech),
// Err(e) => panic!("{}", errors_to_string(&e)),
// }
// info!("SpeechStyle: {:?}", get_preference("SpeechStyle".to_string()).unwrap());
match get_spoken_text() {
Ok(speech) => info!("Computed speech string:\n '{}'", speech),
Err(e) => panic!("{}", errors_to_string(&e)),
}
info!("SpeechStyle: {:?}", get_preference("SpeechStyle".to_string()).unwrap());


set_preference("BrailleCode".to_string(), "UEB".to_string()).unwrap();
Expand Down
8 changes: 3 additions & 5 deletions src/prefs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -641,11 +641,9 @@ impl PreferenceManager {
Err(_) => return None, // I don't think this is possible
Ok(os_path) => os_path,
};
for dir_entry in entries {
if let Ok(entry) = dir_entry {
if entry.file_name().to_str().unwrap_or("").ends_with("_Rules.yaml") {
return Some(entry.file_name().to_str().unwrap().to_string());
}
for dir_entry in entries.flatten() {
if dir_entry.file_name().to_str().unwrap_or("").ends_with("_Rules.yaml") {
return Some(dir_entry.file_name().to_str().unwrap().to_string());
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/speech.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub fn is_quoted_string(str: &str) -> bool {
return false;
}
let bytes = str.as_bytes();
return &bytes[bytes.len()-N_BYTES_NO_EVAL_QUOTE_CHAR..] == NO_EVAL_QUOTE_CHAR_AS_BYTES;
return bytes[bytes.len()-N_BYTES_NO_EVAL_QUOTE_CHAR..] == NO_EVAL_QUOTE_CHAR_AS_BYTES;
}

/// Converts 'string' into a "quoted" string -- use is_quoted_string and unquote_string
Expand Down Expand Up @@ -1746,8 +1746,8 @@ impl UnicodeDef {
} else if first_ch != '0' { // exclude 0xDDDD
for ch in str.chars() { // restart the iterator
let ch_as_str = ch.to_string();
if let Some(_) = unicode_table.insert(ch as u32, ReplacementArray::build(&substitute_ch(replacements, &ch_as_str))
.chain_err(|| format!("In definition of char: '{}'", str))?.replacements) {
if unicode_table.insert(ch as u32, ReplacementArray::build(&substitute_ch(replacements, &ch_as_str))
.chain_err(|| format!("In definition of char: '{}'", str))?.replacements).is_some() {
error!("*** Character '{}' (0x{:X}) is repeated", ch, ch as u32);
}
}
Expand All @@ -1757,9 +1757,9 @@ impl UnicodeDef {
}

let ch = UnicodeDef::get_unicode_char(ch)?;
if let Some(_) = unicode_table.insert(ch, ReplacementArray::build(replacements)
if unicode_table.insert(ch, ReplacementArray::build(replacements)
.chain_err(|| format!("In definition of char: '{}' (0x{})",
char::from_u32(ch).unwrap(), ch))?.replacements) {
char::from_u32(ch).unwrap(), ch))?.replacements).is_some() {
error!("*** Character '{}' (0x{:X}) is repeated", char::from_u32(ch).unwrap(), ch);
}
return Ok( () );
Expand Down
2 changes: 1 addition & 1 deletion src/xpath_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1060,7 +1060,7 @@ impl FontSizeGuess {
// match one or more digits followed by a unit -- there are many more units, but they tend to be large and rarer(?)
static ref FONT_VALUE: Regex = Regex::new(r"(-?[0-9]*\.?[0-9]*)(px|cm|mm|Q|in|ppc|pt|ex|em|rem)").unwrap();
}
let cap = FONT_VALUE.captures(&value_with_unit);
let cap = FONT_VALUE.captures(value_with_unit);
if let Some(cap) = cap {
if cap.len() == 3 {
let multiplier = match &cap[2] { // guess based on 12pt font to convert to ems
Expand Down

0 comments on commit bacfb8c

Please sign in to comment.