Allow renaming exported functions into JS (#525)

Support the `js_name` attribute on exports as well as imports to allow exporting
types as camelCase instead of snake_case, for example.

Closes #221
This commit is contained in:
Alex Crichton
2018-07-20 12:01:28 -05:00
committed by GitHub
parent 61ef250dca
commit 9753f9150b
6 changed files with 103 additions and 6 deletions

View File

@ -20,6 +20,7 @@ pub struct Export {
pub constructor: Option<String>,
pub function: Function,
pub comments: Vec<String>,
pub rust_name: Ident,
}
#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq))]

View File

@ -297,7 +297,7 @@ impl ToTokens for ast::Export {
0
};
let name = &self.function.name;
let name = &self.rust_name;
let receiver = match self.method_self {
Some(ast::MethodSelf::ByValue) => {
let class = self.class.as_ref().unwrap();