Skip to content

core: make the public fmt API completely safe. #19506

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

Merged
merged 3 commits into from
Dec 8, 2014
Merged

Conversation

eddyb
Copy link
Member

@eddyb eddyb commented Dec 3, 2014

No description provided.

@eddyb
Copy link
Member Author

eddyb commented Dec 3, 2014

The usecase I have for this is a macro like:

#![feature(macro_rules)]

macro_rules! format_lite {
    ($($piece:expr)#+ $(,$arg:expr)+) => {
        ::std::fmt::format(&::std::fmt::Arguments::new(&[$($piece),*],
            &[$(::std::fmt::argument(::std::fmt::Show::fmt, &$arg)),*]))
    }
}

fn main() {
    std::io::println(&*format_lite!("foo"#"bar", 5u));
}

@alexcrichton
Copy link
Member

I'm not 100% certain that the check of if self.formatter as uint == Argument::show_uint as uint { means that this is actually safe, so I'd like to mull this over a bit longer.

@bors bors closed this Dec 8, 2014
@bors bors merged commit 15ca630 into rust-lang:master Dec 8, 2014
@eddyb eddyb deleted the fmt-polish branch December 8, 2014 12:56
@brson
Copy link
Contributor

brson commented Dec 12, 2014

These appear to be breaking changes.

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.

4 participants