Update to Rust 1.75
This commit is contained in:
parent
646ba41cf8
commit
3982e0c8fe
|
@ -146,7 +146,7 @@ impl ExtractedCloze<'_> {
|
|||
|
||||
/// If cloze starts with image-occlusion:, return the text following that.
|
||||
fn image_occlusion(&self) -> Option<&str> {
|
||||
let Some(first_node) = self.nodes.get(0) else {
|
||||
let Some(first_node) = self.nodes.first() else {
|
||||
return None;
|
||||
};
|
||||
let TextOrCloze::Text(text) = first_node else {
|
||||
|
|
|
@ -460,7 +460,7 @@ fn ensure_first_field_is_mapped(
|
|||
fn maybe_set_fallback_columns(metadata: &mut CsvMetadata) -> Result<()> {
|
||||
if metadata.column_labels.is_empty() {
|
||||
metadata.column_labels =
|
||||
vec![String::new(); metadata.preview.get(0).map_or(0, |row| row.vals.len())];
|
||||
vec![String::new(); metadata.preview.first().map_or(0, |row| row.vals.len())];
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -483,7 +483,7 @@ impl DuplicateUpdateResult {
|
|||
impl NoteContext<'_> {
|
||||
fn is_guid_dupe(&self) -> bool {
|
||||
self.dupes
|
||||
.get(0)
|
||||
.first()
|
||||
.map_or(false, |d| d.note.guid == self.note.guid)
|
||||
}
|
||||
|
||||
|
@ -570,11 +570,11 @@ impl ForeignNote {
|
|||
}
|
||||
|
||||
fn first_field_is_the_empty_string(&self) -> bool {
|
||||
matches!(self.fields.get(0), Some(Some(s)) if s.is_empty())
|
||||
matches!(self.fields.first(), Some(Some(s)) if s.is_empty())
|
||||
}
|
||||
|
||||
fn first_field_is_unempty(&self) -> bool {
|
||||
matches!(self.fields.get(0), Some(Some(s)) if !s.is_empty())
|
||||
matches!(self.fields.first(), Some(Some(s)) if !s.is_empty())
|
||||
}
|
||||
|
||||
fn normalize_fields(&mut self, normalize_text: bool) {
|
||||
|
@ -595,7 +595,7 @@ impl ForeignNote {
|
|||
|
||||
fn first_field_stripped(&self) -> Option<Cow<str>> {
|
||||
self.fields
|
||||
.get(0)
|
||||
.first()
|
||||
.and_then(|s| s.as_ref())
|
||||
.map(|field| strip_html_preserving_media_filenames(field.as_str()))
|
||||
}
|
||||
|
|
|
@ -564,7 +564,7 @@ impl Collection {
|
|||
/// notetypes, check if there is a cloze in a non-cloze field or if there's
|
||||
/// no cloze at all. For other notetypes, just check if there's a cloze.
|
||||
pub fn note_fields_check(&mut self, note: &Note) -> Result<NoteFieldsState> {
|
||||
Ok(if let Some(text) = note.fields.get(0) {
|
||||
Ok(if let Some(text) = note.fields.first() {
|
||||
let field1 = if self.get_config_bool(BoolKey::NormalizeNoteText) {
|
||||
normalize_to_nfc(text)
|
||||
} else {
|
||||
|
|
|
@ -132,7 +132,7 @@ impl Notetype {
|
|||
/// always return the first and only template.
|
||||
pub fn get_template(&self, card_ord: u16) -> Result<&CardTemplate> {
|
||||
let template = if self.config.kind() == NotetypeKind::Cloze {
|
||||
self.templates.get(0)
|
||||
self.templates.first()
|
||||
} else {
|
||||
self.templates.get(card_ord as usize)
|
||||
};
|
||||
|
@ -553,7 +553,7 @@ impl Notetype {
|
|||
fields: HashMap<String, Option<String>>,
|
||||
parsed: &mut [(Option<ParsedTemplate>, Option<ParsedTemplate>)],
|
||||
) {
|
||||
let first_remaining_field_name = &self.fields.get(0).unwrap().name;
|
||||
let first_remaining_field_name = &self.fields.first().unwrap().name;
|
||||
let is_cloze = self.is_cloze();
|
||||
for (idx, (q_opt, a_opt)) in parsed.iter_mut().enumerate() {
|
||||
if let Some(q) = q_opt {
|
||||
|
@ -616,7 +616,7 @@ impl Notetype {
|
|||
pub(crate) fn cloze_fields(&self) -> HashSet<usize> {
|
||||
if !self.is_cloze() {
|
||||
HashSet::new()
|
||||
} else if let Some((Some(front), _)) = self.parsed_templates().get(0) {
|
||||
} else if let Some((Some(front), _)) = self.parsed_templates().first() {
|
||||
front
|
||||
.all_referenced_cloze_field_names()
|
||||
.iter()
|
||||
|
@ -647,7 +647,7 @@ fn missing_cloze_filter(
|
|||
parsed_templates: &[(Option<ParsedTemplate>, Option<ParsedTemplate>)],
|
||||
) -> bool {
|
||||
parsed_templates
|
||||
.get(0)
|
||||
.first()
|
||||
.map_or(true, |t| !has_cloze(&t.0) || !has_cloze(&t.1))
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ impl Collection {
|
|||
.or_invalid("no such notetype")?;
|
||||
let template = match nt.config.kind() {
|
||||
NotetypeKind::Normal => nt.templates.get(card.template_idx as usize),
|
||||
NotetypeKind::Cloze => nt.templates.get(0),
|
||||
NotetypeKind::Cloze => nt.templates.first(),
|
||||
}
|
||||
.or_invalid("missing template")?;
|
||||
|
||||
|
|
|
@ -92,12 +92,11 @@ impl Collection {
|
|||
original_interval: u32,
|
||||
usn: Usn,
|
||||
) -> Result<()> {
|
||||
let ease_factor = u32::try_from(
|
||||
let ease_factor = u32::from(
|
||||
card.memory_state
|
||||
.map(|s| ((s.difficulty_shifted() * 1000.) as u16))
|
||||
.unwrap_or(card.ease_factor),
|
||||
)
|
||||
.unwrap_or_default();
|
||||
);
|
||||
let entry = RevlogEntry {
|
||||
id: RevlogId::new(),
|
||||
cid: card.id,
|
||||
|
|
|
@ -299,6 +299,15 @@ impl Collection {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<NewCardInsertOrder> for NewCardDueOrder {
|
||||
fn from(o: NewCardInsertOrder) -> Self {
|
||||
match o {
|
||||
NewCardInsertOrder::Due => NewCardDueOrder::NoteId,
|
||||
NewCardInsertOrder::Random => NewCardDueOrder::Random,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
|
@ -374,12 +383,3 @@ mod test {
|
|||
assert_eq!((card.due, card.reps, card.lapses), (1, 0, 0));
|
||||
}
|
||||
}
|
||||
|
||||
impl From<NewCardInsertOrder> for NewCardDueOrder {
|
||||
fn from(o: NewCardInsertOrder) -> Self {
|
||||
match o {
|
||||
NewCardInsertOrder::Due => NewCardDueOrder::NoteId,
|
||||
NewCardInsertOrder::Random => NewCardDueOrder::Random,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ pub(crate) struct BuryMode {
|
|||
impl Collection {
|
||||
pub fn get_next_card(&mut self) -> Result<Option<QueuedCard>> {
|
||||
self.get_queued_cards(1, false)
|
||||
.map(|queued| queued.cards.get(0).cloned())
|
||||
.map(|queued| queued.cards.first().cloned())
|
||||
}
|
||||
|
||||
pub fn get_queued_cards(
|
||||
|
|
|
@ -647,7 +647,7 @@ pub fn render_card(
|
|||
context.frontside = if context.partial_for_python {
|
||||
Some("")
|
||||
} else {
|
||||
let Some(RenderedNode::Text { text }) = &qnodes.get(0) else {
|
||||
let Some(RenderedNode::Text { text }) = &qnodes.first() else {
|
||||
invalid_input!("should not happen: first node not text");
|
||||
};
|
||||
Some(text)
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
[toolchain]
|
||||
# older versions may fail to compile; newer versions may fail the clippy tests
|
||||
channel = "1.74"
|
||||
channel = "1.75"
|
||||
|
|
Loading…
Reference in New Issue