diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8c337f418..20c256654 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,7 +24,7 @@ jobs: name: Lint Rust runs-on: ubuntu-latest env: - RUSTUP_TOOLCHAIN: 1.74.1 + RUSTUP_TOOLCHAIN: 1.75.0 steps: - uses: actions/checkout@v3 - name: Install rustfmt and clippy @@ -76,11 +76,11 @@ jobs: matrix: include: - os: ubuntu-latest - rust: 1.74.1 + rust: 1.75.0 - os: windows-latest - rust: 1.74.1 + rust: 1.75.0 - os: macos-latest - rust: 1.74.1 + rust: 1.75.0 # Minimum Supported Rust Version = 1.70.0 - os: ubuntu-latest diff --git a/deltachat-jsonrpc/src/api/types/chat.rs b/deltachat-jsonrpc/src/api/types/chat.rs index 8603c202e..233e29a87 100644 --- a/deltachat-jsonrpc/src/api/types/chat.rs +++ b/deltachat-jsonrpc/src/api/types/chat.rs @@ -85,7 +85,7 @@ impl FullChat { let can_send = chat.can_send(context).await?; let was_seen_recently = if chat.get_type() == Chattype::Single { - match contact_ids.get(0) { + match contact_ids.first() { Some(contact) => Contact::get_by_id(context, *contact) .await .context("failed to load contact for was_seen_recently")? diff --git a/deltachat-jsonrpc/src/api/types/chat_list.rs b/deltachat-jsonrpc/src/api/types/chat_list.rs index b47f7a728..4b39a17be 100644 --- a/deltachat-jsonrpc/src/api/types/chat_list.rs +++ b/deltachat-jsonrpc/src/api/types/chat_list.rs @@ -102,7 +102,7 @@ pub(crate) async fn get_chat_list_item_by_id( let self_in_group = chat_contacts.contains(&ContactId::SELF); let (dm_chat_contact, was_seen_recently) = if chat.get_type() == Chattype::Single { - let contact = chat_contacts.get(0); + let contact = chat_contacts.first(); let was_seen_recently = match contact { Some(contact) => Contact::get_by_id(ctx, *contact) .await diff --git a/src/accounts.rs b/src/accounts.rs index 8e0dd0a2a..e0d39c952 100644 --- a/src/accounts.rs +++ b/src/accounts.rs @@ -546,8 +546,12 @@ impl Config { } if self.inner.selected_account == id { // reset selected account - self.inner.selected_account = - self.inner.accounts.get(0).map(|e| e.id).unwrap_or_default(); + self.inner.selected_account = self + .inner + .accounts + .first() + .map(|e| e.id) + .unwrap_or_default(); } } diff --git a/src/contact.rs b/src/contact.rs index d390feca9..f4a2702e2 100644 --- a/src/contact.rs +++ b/src/contact.rs @@ -1885,12 +1885,12 @@ mod tests { // Search by name. let contacts = Contact::get_all(&context.ctx, 0, Some("bob")).await?; assert_eq!(contacts.len(), 1); - assert_eq!(contacts.get(0), Some(&id)); + assert_eq!(contacts.first(), Some(&id)); // Search by address. let contacts = Contact::get_all(&context.ctx, 0, Some("user")).await?; assert_eq!(contacts.len(), 1); - assert_eq!(contacts.get(0), Some(&id)); + assert_eq!(contacts.first(), Some(&id)); let contacts = Contact::get_all(&context.ctx, 0, Some("alice")).await?; assert_eq!(contacts.len(), 0); @@ -1917,7 +1917,7 @@ mod tests { // Search by display name (same as manually set name). let contacts = Contact::get_all(&context.ctx, 0, Some("someone")).await?; assert_eq!(contacts.len(), 1); - assert_eq!(contacts.get(0), Some(&id)); + assert_eq!(contacts.first(), Some(&id)); Ok(()) } diff --git a/src/context.rs b/src/context.rs index 57ecff7a3..ebadb60bf 100644 --- a/src/context.rs +++ b/src/context.rs @@ -1370,7 +1370,7 @@ mod tests { assert_eq!(res.len(), 2); // Message added later is returned first. - assert_eq!(res.get(0), Some(&msg2.id)); + assert_eq!(res.first(), Some(&msg2.id)); assert_eq!(res.get(1), Some(&msg1.id)); // Global search with longer text does not find any message. @@ -1587,7 +1587,7 @@ mod tests { let bob_next_msg_ids = bob.get_next_msgs().await?; assert_eq!(bob_next_msg_ids.len(), 1); - assert_eq!(bob_next_msg_ids.get(0), Some(&received_msg.id)); + assert_eq!(bob_next_msg_ids.first(), Some(&received_msg.id)); bob.set_config_u32(Config::LastMsgId, received_msg.id.to_u32()) .await?; @@ -1596,7 +1596,7 @@ mod tests { // Next messages include self-sent messages. let alice_next_msg_ids = alice.get_next_msgs().await?; assert_eq!(alice_next_msg_ids.len(), 1); - assert_eq!(alice_next_msg_ids.get(0), Some(&sent_msg.sender_msg_id)); + assert_eq!(alice_next_msg_ids.first(), Some(&sent_msg.sender_msg_id)); alice .set_config_u32(Config::LastMsgId, sent_msg.sender_msg_id.to_u32()) diff --git a/src/imex/transfer.rs b/src/imex/transfer.rs index 545bd94bd..398fb1d9f 100644 --- a/src/imex/transfer.rs +++ b/src/imex/transfer.rs @@ -638,7 +638,7 @@ mod tests { let self_chat = ctx1.get_self_chat().await; let msgs = get_chat_msgs(&ctx1, self_chat.id).await.unwrap(); assert_eq!(msgs.len(), 2); - let msgid = match msgs.get(0).unwrap() { + let msgid = match msgs.first().unwrap() { ChatItem::Message { msg_id } => msg_id, _ => panic!("wrong chat item"), }; diff --git a/src/location.rs b/src/location.rs index 455997813..79c96958f 100644 --- a/src/location.rs +++ b/src/location.rs @@ -954,7 +954,7 @@ Content-Disposition: attachment; filename="location.kml" assert!(msg.chat_id == bob_chat_id); assert_eq!(msg.msg_ids.len(), 1); - let bob_msg = Message::load_from_db(&bob, *msg.msg_ids.get(0).unwrap()).await?; + let bob_msg = Message::load_from_db(&bob, *msg.msg_ids.first().unwrap()).await?; assert_eq!(bob_msg.chat_id, bob_chat_id); assert_eq!(bob_msg.viewtype, Viewtype::Image); diff --git a/src/mimeparser.rs b/src/mimeparser.rs index 0d1acef8f..90c2384c9 100644 --- a/src/mimeparser.rs +++ b/src/mimeparser.rs @@ -914,7 +914,7 @@ impl MimeMessage { skip the rest. (see for background information why we use encrypted+signed) */ - if let Some(first) = mail.subparts.get(0) { + if let Some(first) = mail.subparts.first() { any_part_added = self .parse_mime_recursive(context, first, is_related) .await?; @@ -970,7 +970,7 @@ impl MimeMessage { } } Some(_) => { - if let Some(first) = mail.subparts.get(0) { + if let Some(first) = mail.subparts.first() { any_part_added = self .parse_mime_recursive(context, first, is_related) .await?; diff --git a/src/reaction.rs b/src/reaction.rs index 2b8e22020..2fec8a0e8 100644 --- a/src/reaction.rs +++ b/src/reaction.rs @@ -425,7 +425,7 @@ Content-Disposition: reaction\n\ let contacts = reactions.contacts(); assert_eq!(contacts.len(), 1); - assert_eq!(contacts.get(0), Some(&bob_id)); + assert_eq!(contacts.first(), Some(&bob_id)); let bob_reaction = reactions.get(bob_id); assert_eq!(bob_reaction.is_empty(), false); assert_eq!(bob_reaction.emojis(), vec!["👍"]); @@ -526,7 +526,7 @@ Here's my footer -- bob@example.net" assert_eq!(reactions.to_string(), "👍1"); let contacts = reactions.contacts(); assert_eq!(contacts.len(), 1); - let bob_id = contacts.get(0).unwrap(); + let bob_id = contacts.first().unwrap(); let bob_reaction = reactions.get(*bob_id); assert_eq!(bob_reaction.is_empty(), false); assert_eq!(bob_reaction.emojis(), vec!["👍"]); @@ -578,13 +578,13 @@ Here's my footer -- bob@example.net" ) .await? .unwrap(); - let alice_msg_id = *alice_received_message.msg_ids.get(0).unwrap(); + let alice_msg_id = *alice_received_message.msg_ids.first().unwrap(); // Bob downloads own message on the other device. let bob_received_message = receive_imf(&bob, msg_full.as_bytes(), false) .await? .unwrap(); - let bob_msg_id = *bob_received_message.msg_ids.get(0).unwrap(); + let bob_msg_id = *bob_received_message.msg_ids.first().unwrap(); // Bob reacts to own message. send_reaction(&bob, bob_msg_id, "👍").await.unwrap(); diff --git a/src/receive_imf.rs b/src/receive_imf.rs index bd72ff61e..30e0ba5dd 100644 --- a/src/receive_imf.rs +++ b/src/receive_imf.rs @@ -315,7 +315,7 @@ pub(crate) async fn receive_imf_inner( mime_parser.decryption_info.peerstate = Peerstate::from_addr(context, contact.get_addr()).await?; } else { - let to_id = to_ids.get(0).copied().unwrap_or_default(); + let to_id = to_ids.first().copied().unwrap_or_default(); // handshake may mark contacts as verified and must be processed before chats are created res = observe_securejoin_on_other_device(context, &mime_parser, to_id) .await @@ -919,7 +919,7 @@ async fn add_parts( // the mail is on the IMAP server, probably it is also delivered. // We cannot recreate other states (read, error). state = MessageState::OutDelivered; - to_id = to_ids.get(0).copied().unwrap_or_default(); + to_id = to_ids.first().copied().unwrap_or_default(); let self_sent = from_id == ContactId::SELF && to_ids.len() == 1 && to_ids.contains(&ContactId::SELF); diff --git a/src/sync.rs b/src/sync.rs index 4162f57e5..64873298b 100644 --- a/src/sync.rs +++ b/src/sync.rs @@ -447,7 +447,7 @@ mod tests { )?; assert_eq!(sync_items.items.len(), 1); let SyncDataOrUnknown::SyncData(AlterChat { id, action }) = - &sync_items.items.get(0).unwrap().data + &sync_items.items.first().unwrap().data else { bail!("bad item"); }; @@ -491,7 +491,7 @@ mod tests { assert_eq!(sync_items.items.len(), 1); if let SyncDataOrUnknown::SyncData(AddQrToken(token)) = - &sync_items.items.get(0).unwrap().data + &sync_items.items.first().unwrap().data { assert_eq!(token.invitenumber, "in"); assert_eq!(token.auth, "yip"); diff --git a/src/webxdc.rs b/src/webxdc.rs index e107c8782..12a51ed53 100644 --- a/src/webxdc.rs +++ b/src/webxdc.rs @@ -1241,7 +1241,7 @@ mod tests { ) .await? .unwrap(); - assert_eq!(*received_msg.msg_ids.get(0).unwrap(), bob_instance.id); + assert_eq!(*received_msg.msg_ids.first().unwrap(), bob_instance.id); let bob_instance = bob.get_last_msg().await; assert_eq!(bob_instance.viewtype, Viewtype::Webxdc); assert_eq!(bob_instance.download_state, DownloadState::Done);