Skip to content

Commit 63e83ed

Browse files
committed
apply clippy suggestion
1 parent 249c8dd commit 63e83ed

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

‎examples/toy.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use core::mem;
33

44
fn main() -> Result<(), String> {
55
// Create the JIT instance, which manages all generated functions and data.
6-
let mut jit = jit::JIT::new();
6+
let mut jit = jit::JIT::default();
77
println!("the answer is: {}", run_foo(&mut jit)?);
88
println!(
99
"recursive_fib(10) = {}",

‎src/jit.rs‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@ pub struct JIT {
2424
module: SimpleJITModule,
2525
}
2626

27-
impl JIT {
28-
/// Create a new `JIT` instance.
29-
pub fn new() -> Self {
27+
impl Default for JIT {
28+
fn default() -> Self {
3029
let builder = SimpleJITBuilder::new(cranelift_module::default_libcall_names());
3130
let module = SimpleJITModule::new(builder);
3231
Self {
@@ -36,7 +35,9 @@ impl JIT {
3635
module,
3736
}
3837
}
38+
}
3939

40+
impl JIT {
4041
/// Compile a string in the toy language into machine code.
4142
pub fn compile(&mut self, input: &str) -> Result<*const u8, String> {
4243
// First, parse the string, producing AST nodes.

0 commit comments

Comments
 (0)