-
-
Notifications
You must be signed in to change notification settings - Fork 13
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
docs: Update outdated README and check all code examples automatically #393
Comments
Hello @coalooball! Thanks for submitting an issue! That's what happens when code is not automatically checked... :-) The examples are outdated and need to be fixed. In the meantime: Could you try the examples from https://docs.rs/imap-codec/latest/imap_codec/ and see if they work for you? |
Alternatively, you might find these examples (https://github.com/duesee/imap-codec/tree/main/imap-codec/examples) helpful, too. |
We could use https://doc.rust-lang.org/rustdoc/write-documentation/documentation-tests.html#include-items-only-when-collecting-doctests (see how to include README) to test the example in the README. |
Hello @duesee! Thanks for your prompt response. I tried the examples from the two links you provided. I was able to run all the examples in this link (https://github.com/duesee/imap-codec/tree/main/imap-codec/examples). However, I encountered compilation errors when trying the examples from this link (https://docs.rs/imap-codec/latest/imap_codec/). I need to execute the use imap_codec::{decode::Decoder, GreetingCodec};
use imap_types::response::{Code, Greeting, GreetingKind};
use imap_types::core::Text;
fn main() {
let (remaining, greeting) = GreetingCodec::default()
.decode(b"* OK [ALERT] Hello, World!\r\n<remaining>")
.unwrap();
assert_eq!(
greeting,
Greeting {
kind: GreetingKind::Ok,
code: Some(Code::Alert),
text: Text::try_from("Hello, World!").unwrap(),
}
);
assert_eq!(remaining, &b"<remaining>"[..])
} I think it's worth reminding everyone to use By the way, my Cargo version is as follows: cargo --version
cargo 1.75.0-nightly (6fa6fdc76 2023-10-10) |
Thanks for your valuable input! I agree. Currently, Thus, I completely agree that the examples should mention to As you already fixed it... are you in a position to make a PR? :-) I can do it, too, but as you already figured this all out, you should take the credit! |
We could make two PRs: One fixing the outdated README (and making it so that it is automatically checked) -- I can do this PR quickly -- and one improving the examples -- possibly you? :-) |
imap_codec::codec::Decode
, imap_codec::codec::Encode
I made a PR :-) This commit 953ce6b will ensure that all examples in the READMEs are tested. So, hopefully, nothing can get out-of-sync anymore! |
Reopened: Missed one README :P |
Thank you very much for the CREDIT :) In addition, I think |
I think at some point we re-exported |
Hello! I just downloaded imap-codec using
cargo add imap-codec
, and I want to run the examples from https://crates.io/crates/imap-codec, but I'm getting a bunch of errors.Here are the error messages:
Here is my source code(from https://crates.io/crates/imap-codec) and Cargo.toml(generated by
cargo add imap-codec
) file:The text was updated successfully, but these errors were encountered: