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