Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ For an example with using Serde deserialization, please refer to [serde_integrat


```rust
use influxdb::{Client, Query, Timestamp, ReadQuery};
use influxdb::{Client, Timestamp, ReadQuery};
use influxdb::InfluxDbWriteable;
use chrono::{DateTime, Utc};

Expand Down Expand Up @@ -93,17 +93,18 @@ async fn main() {
}.into_query("weather"),
);

let write_result = client
.query(weather_readings)
.await;
assert!(write_result.is_ok(), "Write result was not okay");
if let Err(e) = client.query(weather_readings).await {
println!("Error writing result: {e}");
return;
}

// Let's see if the data we wrote is there
let read_query = ReadQuery::new("SELECT * FROM weather");

let read_result = client.query(read_query).await;
assert!(read_result.is_ok(), "Read result was not ok");
println!("{}", read_result.unwrap());
match client.query(read_query).await {
Ok(read_result) => println!("{}", read_result),
Err(e) => println!("Error reading result: {e}"),
}
}
```

Expand Down Expand Up @@ -167,7 +168,7 @@ To communicate with InfluxDB, you can choose the HTTP backend to be used configu
@ 2020 Gero Gerke and [contributors].

[contributors]: https://github.com/influxdb-rs/influxdb-rust/graphs/contributors
[__cargo_doc2readme_dependencies_info]: ggGkYW0BYXSEG64av5CnNoNoGw8lPMr2b0MoG44uU0T70vGSG7osgcbjN7SoYXKEG8qCijK3OhAgG9r5dMb74ZyFGy-UgqMKZw5_G6wZmUfHdMJDYWSBgmhpbmZsdXhkYmUwLjcuMQ
[__cargo_doc2readme_dependencies_info]: ggGkYW0BYXSEG64av5CnNoNoGw8lPMr2b0MoG44uU0T70vGSG7osgcbjN7SoYXKEG_D2JHss1jsUG6eXkB7MmDoIG9miwB7MgvlwG_-cxCbQ3T7bYWSBgmhpbmZsdXhkYmUwLjcuMQ
[__link0]: https://github.com/influxdb-rs/influxdb-rust/blob/main/CONTRIBUTING.md
[__link1]: https://github.com/influxdb-rs/influxdb-rust/blob/main/CODE_OF_CONDUCT.md
[__link10]: https://curl.se/libcurl/
Expand Down
17 changes: 9 additions & 8 deletions influxdb/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
//! For an example with using Serde deserialization, please refer to [serde_integration](crate::integrations::serde_integration)
//!
//! ```rust,no_run
//! use influxdb::{Client, Query, Timestamp, ReadQuery};
//! use influxdb::{Client, Timestamp, ReadQuery};
//! use influxdb::InfluxDbWriteable;
//! use chrono::{DateTime, Utc};
//!
Expand Down Expand Up @@ -56,17 +56,18 @@
//! }.into_query("weather"),
//! );
//!
//! let write_result = client
//! .query(weather_readings)
//! .await;
//! assert!(write_result.is_ok(), "Write result was not okay");
//! if let Err(e) = client.query(weather_readings).await {
//! println!("Error writing result: {e}");
//! return;
//! }
Copy link
Collaborator

@msrd0 msrd0 Nov 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use .expect()? I mean we don't actually run this particular doc test, but if we did, it would fail using assert/expect/panic/... but not when using println and return

//!
//! // Let's see if the data we wrote is there
//! let read_query = ReadQuery::new("SELECT * FROM weather");
//!
//! let read_result = client.query(read_query).await;
//! assert!(read_result.is_ok(), "Read result was not ok");
//! println!("{}", read_result.unwrap());
//! match client.query(read_query).await {
//! Ok(read_result) => println!("{}", read_result),
//! Err(e) => println!("Error reading result: {e}"),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use .expect()?

//! }
//! }
//! ```
//!
Expand Down