mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Some lint fixes for newer Rust
This commit is contained in:
parent
2a52639cd3
commit
6b3b545a9a
6 changed files with 16 additions and 14 deletions
|
@ -146,10 +146,7 @@ impl ExtractedCloze<'_> {
|
||||||
|
|
||||||
/// If cloze starts with image-occlusion:, return the text following that.
|
/// If cloze starts with image-occlusion:, return the text following that.
|
||||||
fn image_occlusion(&self) -> Option<&str> {
|
fn image_occlusion(&self) -> Option<&str> {
|
||||||
let Some(first_node) = self.nodes.first() else {
|
let TextOrCloze::Text(text) = self.nodes.first()? else {
|
||||||
return None;
|
|
||||||
};
|
|
||||||
let TextOrCloze::Text(text) = first_node else {
|
|
||||||
return None;
|
return None;
|
||||||
};
|
};
|
||||||
text.strip_prefix("image-occlusion:")
|
text.strip_prefix("image-occlusion:")
|
||||||
|
|
|
@ -55,7 +55,11 @@ pub enum BoolKey {
|
||||||
/// This is a workaround for old clients that used ints to represent boolean
|
/// This is a workaround for old clients that used ints to represent boolean
|
||||||
/// values. For new config items, prefer using a bool directly.
|
/// values. For new config items, prefer using a bool directly.
|
||||||
#[derive(Deserialize, Default)]
|
#[derive(Deserialize, Default)]
|
||||||
struct BoolLike(#[serde(deserialize_with = "deserialize_bool_from_anything")] bool);
|
struct BoolLike(
|
||||||
|
#[serde(deserialize_with = "deserialize_bool_from_anything")]
|
||||||
|
#[allow(dead_code)]
|
||||||
|
bool,
|
||||||
|
);
|
||||||
|
|
||||||
impl Collection {
|
impl Collection {
|
||||||
pub fn get_config_bool(&self, key: BoolKey) -> bool {
|
pub fn get_config_bool(&self, key: BoolKey) -> bool {
|
||||||
|
|
|
@ -97,10 +97,12 @@ impl Collection {
|
||||||
let idxs = nt.get_io_field_indexes()?;
|
let idxs = nt.get_io_field_indexes()?;
|
||||||
|
|
||||||
cloze_note.occlusions = parse_image_occlusions(fields[idxs.occlusions as usize].as_str());
|
cloze_note.occlusions = parse_image_occlusions(fields[idxs.occlusions as usize].as_str());
|
||||||
cloze_note.header = fields[idxs.header as usize].clone();
|
cloze_note.header.clone_from(&fields[idxs.header as usize]);
|
||||||
cloze_note.back_extra = fields[idxs.back_extra as usize].clone();
|
cloze_note
|
||||||
|
.back_extra
|
||||||
|
.clone_from(&fields[idxs.back_extra as usize]);
|
||||||
cloze_note.image_data = "".into();
|
cloze_note.image_data = "".into();
|
||||||
cloze_note.tags = note.tags.clone();
|
cloze_note.tags.clone_from(¬e.tags);
|
||||||
|
|
||||||
let image_file_name = &fields[idxs.image as usize];
|
let image_file_name = &fields[idxs.image as usize];
|
||||||
let src = self
|
let src = self
|
||||||
|
|
|
@ -157,7 +157,7 @@ impl Deck {
|
||||||
fn update_normal_with_other(normal: &mut NormalDeck, other: &NormalDeck) {
|
fn update_normal_with_other(normal: &mut NormalDeck, other: &NormalDeck) {
|
||||||
if !other.description.is_empty() {
|
if !other.description.is_empty() {
|
||||||
normal.markdown_description = other.markdown_description;
|
normal.markdown_description = other.markdown_description;
|
||||||
normal.description = other.description.clone();
|
normal.description.clone_from(&other.description);
|
||||||
}
|
}
|
||||||
if other.config_id != 1 {
|
if other.config_id != 1 {
|
||||||
normal.config_id = other.config_id;
|
normal.config_id = other.config_id;
|
||||||
|
|
|
@ -663,7 +663,7 @@ mod test {
|
||||||
// match the python implementation for now
|
// match the python implementation for now
|
||||||
assert_eq!(anki_base91(0), "");
|
assert_eq!(anki_base91(0), "");
|
||||||
assert_eq!(anki_base91(1), "b");
|
assert_eq!(anki_base91(1), "b");
|
||||||
assert_eq!(anki_base91(u64::max_value()), "Rj&Z5m[>Zp");
|
assert_eq!(anki_base91(u64::MAX), "Rj&Z5m[>Zp");
|
||||||
assert_eq!(anki_base91(1234567890), "saAKk");
|
assert_eq!(anki_base91(1234567890), "saAKk");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,8 +71,7 @@ impl Collection {
|
||||||
.is_ok()
|
.is_ok()
|
||||||
},
|
},
|
||||||
)?
|
)?
|
||||||
.max(0.75)
|
.clamp(0.75, 0.95) as f32)
|
||||||
.min(0.95) as f32)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_optimal_retention_parameters(
|
pub fn get_optimal_retention_parameters(
|
||||||
|
@ -226,10 +225,10 @@ impl Collection {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn median_secs(group: &Vec<u32>) -> f64 {
|
fn median_secs(group: &[u32]) -> f64 {
|
||||||
let length = group.len();
|
let length = group.len();
|
||||||
if length > 0 {
|
if length > 0 {
|
||||||
let mut group_vec = group.clone();
|
let mut group_vec = group.to_vec();
|
||||||
group_vec.sort_unstable();
|
group_vec.sort_unstable();
|
||||||
let median_millis = if length % 2 == 0 {
|
let median_millis = if length % 2 == 0 {
|
||||||
let mid = length / 2;
|
let mid = length / 2;
|
||||||
|
|
Loading…
Reference in a new issue