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

Improve docs for write!/writeln! macros #28049

Merged
merged 1 commit into from
Oct 10, 2015
Merged

Conversation

steveklabnik
Copy link
Member

No description provided.

@rust-highfive
Copy link
Collaborator

r? @aturon

(rust_highfive has picked a reviewer for you, use r? to override)

@steveklabnik steveklabnik changed the title Doc write Improve docs for write!/writeln! macros Aug 27, 2015
/// See [`std::fmt`][fmt] for more information on format syntax.
///
/// [fmt]: fmt/index.html
/// [write]: io/trait.Write.html
Copy link
Member

Choose a reason for hiding this comment

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

So, we gave up on making rustdoc do crosslinking? Who’s going to check these links do not break in the future?

Copy link
Member Author

Choose a reason for hiding this comment

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

That ship sailed a long time ago.

Copy link
Member Author

Choose a reason for hiding this comment

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

(that doesn't mean we couldn't add it in the future, but there are tons and tons and tons of these manual links all throughout the documentation)

@TimNN
Copy link
Contributor

TimNN commented Aug 31, 2015

Actually I think the new docs are slightly incorrect, because write! will work for any type which has a write_fmt(self, Arguments) in scope, which is not only io::Write:

@steveklabnik
Copy link
Member Author

@TimNN confirmed:

use std::fmt::Arguments;

struct Lol;

impl Lol {
    fn write_fmt(self, _: Arguments) -> std::fmt::Result {
        println!("called format");
        Ok(())
    }
}

fn main() {
    let l = Lol;
    write!(l, "yup").unwrap();
}

So, with that in mind, I'm not entirely sure how to document this, exactly. Seems like a fairly complex requirement...

@aturon
Copy link
Member

aturon commented Oct 8, 2015

@steveklabnik I believe the intent here is to be used as you say, and the stuff with formatting is largely an implementation artifact; I find this confusing every time I look at it.

@alexcrichton, do you think what @steveklabnik has here is a reasonable gloss?

r=me if so :)

@alexcrichton
Copy link
Member

Yeah just because it'd a "duck typed I just call write_fmt" macro I don't think means that it should be documented as such. Perhaps this could just say "typically used with std::{fmt,io}::Write" or something like that to avoid saying "you must implement Write".

(the links are still broken btw)

@steveklabnik
Copy link
Member Author

@alexcrichton they don't look broken to me?
2015-10-09-135247_221x80_scrot

@alexcrichton
Copy link
Member

Aha! I see the syntax has changed now.

@bors: r+ ef9e542

@bors
Copy link
Contributor

bors commented Oct 9, 2015

⌛ Testing commit ef9e542 with merge 439311d...

@bors bors merged commit ef9e542 into rust-lang:master Oct 10, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants