Skip to content

Commit

Permalink
cleanup interface (#162)
Browse files Browse the repository at this point in the history
  • Loading branch information
wboayue authored Nov 8, 2024
1 parent d905b39 commit 05ab7a2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
3 changes: 1 addition & 2 deletions examples/contract_details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ fn main() -> anyhow::Result<()> {
println!("connection_time: {:?}", client.connection_time());
println!("next_order_id: {}", client.next_order_id());

let mut contract = Contract::stock("AAPL");
contract.currency = "USD".to_string();
let contract = Contract::stock("MSFT");

let results = client.contract_details(&contract)?;
for contract in results {
Expand Down
4 changes: 2 additions & 2 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,8 @@ impl Client {
/// println!("contract: {:?}", contract_detail);
/// }
/// ```
pub fn contract_details(&self, contract: &Contract) -> Result<impl Iterator<Item = contracts::ContractDetails>, Error> {
Ok(contracts::contract_details(self, contract)?.into_iter())
pub fn contract_details(&self, contract: &Contract) -> Result<Vec<contracts::ContractDetails>, Error> {
Ok(contracts::contract_details(self, contract)?)
}

/// Get current [FamilyCode]s for all accessible accounts.
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fn request_stock_contract_details() {

assert!(results.is_ok(), "failed to encode request: {:?}", results.err());

let contracts: Vec<ContractDetails> = results.unwrap().collect();
let contracts: Vec<ContractDetails> = results.unwrap();
assert_eq!(2, contracts.len());

assert_eq!(contracts[0].contract.exchange, "SMART");
Expand Down

0 comments on commit 05ab7a2

Please sign in to comment.