From 4bee550a94655f621f2d2af24bee7546fb9a1947 Mon Sep 17 00:00:00 2001 From: Christoffer SOOP Date: Sat, 28 Dec 2024 14:36:45 +0100 Subject: [PATCH] #9 keyword and card iteration --- src/hdu/header/mod.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/hdu/header/mod.rs b/src/hdu/header/mod.rs index 00f2e20..af9bf06 100644 --- a/src/hdu/header/mod.rs +++ b/src/hdu/header/mod.rs @@ -7,7 +7,10 @@ use serde::Serialize; pub mod extension; -use std::collections::HashMap; +use std::collections::hash_map::Keys; +use std::collections::{ + hash_map::Iter, HashMap +}; use std::io::Read; use crate::card::*; @@ -256,6 +259,18 @@ where }) }) } + + pub fn keywords(&self) -> Keys { + self.cards.keys() + } + + pub fn cards(&self) -> impl Iterator + use<'_, X> { + self.cards.iter() + .map(|(kw,v)| { + Card { kw: kw.to_owned(), v: v.to_owned() } + }) + } + } fn parse_pcount_card(card: &[u8; 80]) -> Result {