From efd0eadafe458cff88a6a82c6b3c2775c08db2f9 Mon Sep 17 00:00:00 2001 From: Todd Mortimer Date: Sat, 31 Jul 2021 19:26:48 -0400 Subject: [PATCH] Implement get() for Fetch and Name --- src/types/fetch.rs | 5 +++++ src/types/name.rs | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/types/fetch.rs b/src/types/fetch.rs index 9d497dc..8ea6370 100644 --- a/src/types/fetch.rs +++ b/src/types/fetch.rs @@ -81,6 +81,11 @@ impl Fetches { pub fn is_empty(&self) -> bool { self.borrow_fetches().is_empty() } + + /// Get the element at the given index + pub fn get(&self, index: usize) -> Option<&Fetch<'_>> { + self.borrow_fetches().get(index) + } } /// An IMAP [`FETCH` response](https://tools.ietf.org/html/rfc3501#section-7.4.2) that contains diff --git a/src/types/name.rs b/src/types/name.rs index 915cc93..e9808fd 100644 --- a/src/types/name.rs +++ b/src/types/name.rs @@ -58,6 +58,11 @@ impl Names { pub fn is_empty(&self) -> bool { self.borrow_names().is_empty() } + + /// Get the element at the given index + pub fn get(&self, index: usize) -> Option<&Name<'_>> { + self.borrow_names().get(index) + } } /// A name that matches a `LIST` or `LSUB` command.