Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix DeserializeFailed(Error("invalid length 9, expected fewer elements in array", line: 0, column: 0) (Issue #60) #61

Merged
merged 3 commits into from
Jan 16, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions src/quotes.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -104,6 +103,7 @@ impl YResponse {
}
Ok(vec![])
}

/// This method retrieves information about the dividends that have
/// been recorded during the considered time period.
///
Expand Down Expand Up @@ -223,9 +223,12 @@ impl<'de> Deserialize<'de> for TradingPeriods {
where
V: SeqAccess<'de>,
{
let regular: Vec<PeriodInfo> = seq
.next_element()?
.ok_or_else(|| de::Error::invalid_length(0, &self))?;
let mut regular: Vec<PeriodInfo> = Vec::new();

while let Ok(Some(mut e)) = seq.next_element::<Vec<PeriodInfo>>() {
regular.append(&mut e);
}

Ok(TradingPeriods {
pre: None,
regular: Some(vec![regular]),
Expand Down
Loading