Merge pull request #556 from dtolnay/functional

Include <functional> when deriving Hash impl shim
This commit is contained in:
David Tolnay 2020-12-09 23:11:19 -08:00 committed by GitHub
commit e5ea14e049
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 0 deletions

View File

@ -27,6 +27,7 @@ pub struct Includes<'a> {
pub cstdint: bool,
pub cstring: bool,
pub exception: bool,
pub functional: bool,
pub initializer_list: bool,
pub iterator: bool,
pub memory: bool,
@ -77,6 +78,7 @@ pub(super) fn write(out: &mut OutFile) {
cstdint,
cstring,
exception,
functional,
initializer_list,
iterator,
memory,
@ -107,6 +109,9 @@ pub(super) fn write(out: &mut OutFile) {
if exception {
writeln!(out, "#include <exception>");
}
if functional {
writeln!(out, "#include <functional>");
}
if initializer_list {
writeln!(out, "#include <initializer_list>");
}

View File

@ -158,6 +158,7 @@ fn write_std_specializations(out: &mut OutFile, apis: &[Api]) {
if let Api::Struct(strct) = api {
if derive::contains(&strct.derives, Trait::Hash) {
out.next_section();
out.include.functional = true;
let qualified = strct.name.to_fully_qualified();
writeln!(out, "template <> struct hash<{}> {{", qualified);
writeln!(