diff --git a/src/quotes.rs b/src/quotes.rs index 2034bb8..19099f8 100644 --- a/src/quotes.rs +++ b/src/quotes.rs @@ -1,9 +1,8 @@ -use std::{collections::HashMap, fmt}; +use std::collections::HashMap; +use std::fmt; -use serde::{ - de::{self, Deserializer, MapAccess, SeqAccess, Visitor}, - Deserialize, Serialize, -}; +use serde::de::{self, Deserializer, MapAccess, SeqAccess, Visitor}; +use serde::{Deserialize, Serialize}; use super::YahooError; @@ -104,6 +103,7 @@ impl YResponse { } Ok(vec![]) } + /// This method retrieves information about the dividends that have /// been recorded during the considered time period. /// @@ -223,9 +223,12 @@ impl<'de> Deserialize<'de> for TradingPeriods { where V: SeqAccess<'de>, { - let regular: Vec = seq - .next_element()? - .ok_or_else(|| de::Error::invalid_length(0, &self))?; + let mut regular: Vec = Vec::new(); + + while let Ok(Some(mut e)) = seq.next_element::>() { + regular.append(&mut e); + } + Ok(TradingPeriods { pre: None, regular: Some(vec![regular]),