feat: use dyn

This commit is contained in:
2020-11-29 10:39:37 +08:00
parent 3f6a6b6013
commit 35bd53b304

View File

@@ -17,8 +17,8 @@ impl CommandImpl {
information!("Verbose count: {}", verbose_count);
information!(r#"Print using command line:
commit-msg usage"#);
let a = CommitMsgCheckRegex::new_default();
let b = CommitMsgCheckQuickJs::new_from_js(r##"
let a = Box::new(CommitMsgCheckRegex::new_default()) as Box<dyn CommitMsgCheck>;
let b = Box::new(CommitMsgCheckQuickJs::new_from_js(r##"
function check(a) {
return false;
}
@@ -26,7 +26,7 @@ commit-msg usage"#);
function hint() {
return "hello";
}
"##).expect("err");
"##).expect("err")) as Box<dyn CommitMsgCheck>;
if !a.check("a") {
a.print_hint();