-
Notifications
You must be signed in to change notification settings - Fork 4
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
add print macros #7
Conversation
Signed-off-by: Yoshua Wuyts <[email protected]>
Signed-off-by: Yoshua Wuyts <[email protected]>
Signed-off-by: Yoshua Wuyts <[email protected]>
@yoshuawuyts Could you add tests? As the document uses async-std's macro, it does not work as this crate's test. |
Signed-off-by: Yoshua Wuyts <[email protected]>
@taiki-e I'm not sure how to go about the testing stdout output here. We could do some process spawning + capture, but it doesn't feel great. Do you have any suggestions? |
Or well, we could check if things compile which may be good enough. I'll add those tests (: |
I tried adding: use std::error::Error;
#[test]
fn print_works() {
futures::executor::block_on(async {
async_macros::print!("hello {}", "world").await;
async_macros::println!("hello {}", "world").await;
async_macros::eprint!("hello {}", "world").await;
async_macros::eprintln!("hello {}", "world").await;
});
} But it fails because |
Signed-off-by: Yoshua Wuyts <[email protected]>
Signed-off-by: Yoshua Wuyts <[email protected]>
Is it possible to use git dependencies in dev-dependencies? It blocks |
macro_rules! print { | ||
($($arg:tt)*) => ( | ||
async { | ||
use ::async_std::prelude::*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this PR is good. This will make it difficult to reexport these macros.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe my understanding of scoping is off here; but doesn't this include the prelude only within the async
block?
The goal of this crate is to provide re-exports for async-std's submodules, because we can't define the macros inside the crate itself. I think as long as we cover that use case we should be okay?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is enough for that purpose.
(I was thinking about the restriction that $crate
cannot be used. But given proc-macro always has this limitation, we probably don't need to worry.)
Signed-off-by: Yoshua Wuyts <[email protected]>
Oh, sorry. I said |
Signed-off-by: Yoshua Wuyts <[email protected]>
since async-rs/async-std#328 is closed, does this also close? |
Yeah, I think so! |
Adds the print macros from
async-std
here so we can re-export them from submodules. Thanks!