diff options
author | Jeff Waugh <jdub@bethesignal.org> | 2016-10-08 04:29:18 +1100 |
---|---|---|
committer | Jeff Waugh <jdub@bethesignal.org> | 2016-10-08 04:29:18 +1100 |
commit | 8d59ffc07d64601453b8181269f71deab94ca5a3 (patch) | |
tree | 3c5a193eadbb92a12c9cbb08dd08a97f4787bceb | |
parent | 061c5a98d40b9e0bc6ebc8bf0c8329a2ecd2001b (diff) |
Avoid spurious allocations, thanks to @emilio
-rwxr-xr-x | src/lib.rs | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -26,6 +26,7 @@ mod codegen { include!(concat!(env!("OUT_DIR"), "/codegen.rs")); } +use std::borrow::Borrow; use std::io::{self, Write}; use std::fs::OpenOptions; use std::path::Path; @@ -71,18 +72,18 @@ impl Builder { self } - pub fn whitelisted_type<T: Into<String>>(mut self, arg: T) -> Builder { - self.options.whitelisted_types.insert(&arg.into()); + pub fn whitelisted_type<T: Borrow<str>>(mut self, arg: T) -> Builder { + self.options.whitelisted_types.insert(&arg); self } - pub fn whitelisted_function<T: Into<String>>(mut self, arg: T) -> Builder { - self.options.whitelisted_functions.insert(&arg.into()); + pub fn whitelisted_function<T: Borrow<str>>(mut self, arg: T) -> Builder { + self.options.whitelisted_functions.insert(&arg); self } - pub fn whitelisted_var<T: Into<String>>(mut self, arg: T) -> Builder { - self.options.whitelisted_vars.insert(&arg.into()); + pub fn whitelisted_var<T: Borrow<str>>(mut self, arg: T) -> Builder { + self.options.whitelisted_vars.insert(&arg); self } |