Skip to content

Commit 1d66e78

Browse files
IntoIterator for &mut ReportAttachments (#128)
* . * inner_mut also * Get rid of an unsafe block --------- Co-authored-by: Tethys Svensson <freaken@freaken.dk>
1 parent 5f6584e commit 1d66e78

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/report_attachment/owned.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,15 @@ impl<A: Sized, T> ReportAttachment<A, T> {
215215
pub fn inner(&self) -> &A {
216216
self.as_ref().inner()
217217
}
218+
219+
/// Returns a mutable reference to the inner attachment.
220+
///
221+
/// This method is only available when the attachment type is a specific
222+
/// type, and not [`Dynamic`].
223+
#[must_use]
224+
pub fn inner_mut(&mut self) -> &mut A {
225+
self.as_mut().into_inner_mut()
226+
}
218227
}
219228

220229
impl<A: ?Sized, T> ReportAttachment<A, T> {

src/report_attachments/owned.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use alloc::vec::Vec;
22

33
use crate::{
44
markers::{Dynamic, Local, SendSync},
5-
report_attachment::{ReportAttachment, ReportAttachmentRef},
5+
report_attachment::{ReportAttachment, ReportAttachmentMut, ReportAttachmentRef},
66
report_attachments::{
77
ReportAttachmentsIntoIter, ReportAttachmentsIter, ReportAttachmentsIterMut,
88
},
@@ -603,6 +603,15 @@ impl<'a, T> IntoIterator for &'a ReportAttachments<T> {
603603
}
604604
}
605605

606+
impl<'a, T> IntoIterator for &'a mut ReportAttachments<T> {
607+
type IntoIter = ReportAttachmentsIterMut<'a>;
608+
type Item = ReportAttachmentMut<'a, Dynamic>;
609+
610+
fn into_iter(self) -> Self::IntoIter {
611+
self.iter_mut()
612+
}
613+
}
614+
606615
impl<A: ?Sized, T> Extend<ReportAttachment<A, T>> for ReportAttachments<T> {
607616
fn extend<I: IntoIterator<Item = ReportAttachment<A, T>>>(&mut self, iter: I) {
608617
for report in iter {

0 commit comments

Comments
 (0)