diff --git a/evcxr/src/cargo_metadata.rs b/evcxr/src/cargo_metadata.rs index 0180cc0..2b44713 100644 --- a/evcxr/src/cargo_metadata.rs +++ b/evcxr/src/cargo_metadata.rs @@ -81,7 +81,8 @@ mod tests { library_names_from_metadata( Path::new("/home/foo/project"), include_str!("testdata/sample_metadata.json") - ).unwrap(), + ) + .unwrap(), vec!["direct1", "direct2"] ); } diff --git a/evcxr/src/errors.rs b/evcxr/src/errors.rs index 33f6fd2..656ce9f 100644 --- a/evcxr/src/errors.rs +++ b/evcxr/src/errors.rs @@ -162,7 +162,8 @@ impl CompilationError { return None; } child["message"].as_str().map(|s| s.to_owned()) - }).collect() + }) + .collect() } else { vec![] } diff --git a/evcxr/src/eval_context.rs b/evcxr/src/eval_context.rs index 05e85b6..375cf01 100644 --- a/evcxr/src/eval_context.rs +++ b/evcxr/src/eval_context.rs @@ -237,7 +237,8 @@ impl EvalContext { CodeBlock::new() .generated( "evcxr_internal_runtime::send_text_plain(&format!(\"{:?}\",\n", - ).user_code(stmt_code) + ) + .user_code(stmt_code) .generated("));"), ); } @@ -565,7 +566,8 @@ impl EvalContext { // into the closure. .generated( "let mut evcxr_variable_store = evcxr_internal_runtime::VariableStore::new();", - ).add_all(user_code) + ) + .add_all(user_code) .add_all(self.store_variable_statements(&VariableMoveState::MovedIntoCatchUnwind)) .add_all(self.store_variable_statements(&VariableMoveState::CopiedIntoCatchUnwind)) // Return our local variable store from the closure to be merged back into the diff --git a/evcxr/src/item.rs b/evcxr/src/item.rs index 71a5958..332a243 100644 --- a/evcxr/src/item.rs +++ b/evcxr/src/item.rs @@ -37,12 +37,13 @@ pub(crate) fn is_item_public(item: &syn::Item) -> bool { syn::Item::Union(i) => is_public(&i.vis), syn::Item::Trait(i) => is_public(&i.vis), syn::Item::Impl(i) => { - i.trait_.is_some() || i.items.iter().all(|i2| match i2 { - syn::ImplItem::Const(i) => is_public(&i.vis), - syn::ImplItem::Method(i) => is_public(&i.vis), - syn::ImplItem::Type(i) => is_public(&i.vis), - _ => true, - }) + i.trait_.is_some() + || i.items.iter().all(|i2| match i2 { + syn::ImplItem::Const(i) => is_public(&i.vis), + syn::ImplItem::Method(i) => is_public(&i.vis), + syn::ImplItem::Type(i) => is_public(&i.vis), + _ => true, + }) } _ => true, } diff --git a/evcxr/src/module.rs b/evcxr/src/module.rs index a8d9a2e..fb22b1f 100644 --- a/evcxr/src/module.rs +++ b/evcxr/src/module.rs @@ -131,7 +131,8 @@ impl Module { } None }) - }).collect(); + }) + .collect(); if errors.is_empty() { if let Some(error) = non_json_error { bail!(Error::JustMessage(error.to_owned())); @@ -158,7 +159,8 @@ impl Module { &mut loaded_module_deps, "{} = {{ path = \"../{}\" }}", m.crate_name, m.crate_name - ).unwrap(); + ) + .unwrap(); } let crate_imports = eval_context.format_cargo_deps(); format!( diff --git a/evcxr/tests/integration_tests.rs b/evcxr/tests/integration_tests.rs index e4fe909..71ef0e5 100644 --- a/evcxr/tests/integration_tests.rs +++ b/evcxr/tests/integration_tests.rs @@ -162,17 +162,17 @@ fn function_panics() { fn tls_implementing_drop() { let mut e = new_context(); eval!(e, pub struct Foo {} - impl Drop for Foo { - fn drop(&mut self) { - println!("Dropping Foo"); - } - } - pub fn init_foo() { - thread_local! { - pub static FOO: Foo = Foo {}; - } - FOO.with(|f| ()) - }); + impl Drop for Foo { + fn drop(&mut self) { + println!("Dropping Foo"); + } + } + pub fn init_foo() { + thread_local! { + pub static FOO: Foo = Foo {}; + } + FOO.with(|f| ()) + }); eval!(e, init_foo();); } diff --git a/evcxr_jupyter/src/core.rs b/evcxr_jupyter/src/core.rs index 851431a..5acc5ec 100644 --- a/evcxr_jupyter/src/core.rs +++ b/evcxr_jupyter/src/core.rs @@ -157,10 +157,11 @@ impl Server { execution_count += 1; message .new_message("execute_input") - .with_content(object!{ + .with_content(object! { "execution_count" => execution_count, "code" => code - }).send(&mut *self.iopub.lock().unwrap())?; + }) + .send(&mut *self.iopub.lock().unwrap())?; let reply = match context.execute(code) { Ok(output) => { if !output.is_empty() { @@ -183,11 +184,12 @@ impl Server { } message .new_message("execute_result") - .with_content(object!{ + .with_content(object! { "execution_count" => execution_count, "data" => data, "metadata" => HashMap::new(), - }).send(&mut *self.iopub.lock().unwrap())?; + }) + .send(&mut *self.iopub.lock().unwrap())?; if let Some(duration) = output.timing { // TODO replace by duration.as_millis() when stable let ms = @@ -202,21 +204,22 @@ impl Server { ); message .new_message("execute_result") - .with_content(object!{ + .with_content(object! { "execution_count" => execution_count, "data" => data, "metadata" => HashMap::new(), - }).send(&mut *self.iopub.lock().unwrap())?; + }) + .send(&mut *self.iopub.lock().unwrap())?; } } - message.new_reply().with_content(object!{ + message.new_reply().with_content(object! { "status" => "ok", "execution_count" => execution_count }) } Err(errors) => { self.emit_errors(&errors, &message)?; - message.new_reply().with_content(object!{ + message.new_reply().with_content(object! { "status" => "error", "execution_count" => execution_count, }) @@ -239,11 +242,11 @@ impl Server { // Jupiter Lab doesn't use the kernel until it received "idle" for kernel_info_request message .new_message("status") - .with_content(object!{"execution_state" => "busy"}) + .with_content(object! {"execution_state" => "busy"}) .send(&mut *self.iopub.lock().unwrap())?; let idle = message .new_message("status") - .with_content(object!{"execution_state" => "idle"}); + .with_content(object! {"execution_state" => "idle"}); if message.message_type() == "kernel_info_request" { message .new_reply() @@ -252,7 +255,7 @@ impl Server { } else if message.message_type() == "is_complete_request" { message .new_reply() - .with_content(object!{"status" => "complete"}) + .with_content(object! {"status" => "complete"}) .send(&mut connection)?; } else if message.message_type() == "execute_request" { execution_channel.send(message)?; @@ -306,10 +309,11 @@ impl Server { } if let Some(message) = message { if let Err(error) = message - .with_content(object!{ + .with_content(object! { "name" => output_name, "text" => format!("{}\n", line), - }).send(&mut *self.iopub.lock().unwrap()) + }) + .send(&mut *self.iopub.lock().unwrap()) { eprintln!("{}", error); } @@ -353,21 +357,23 @@ impl Server { traceback.push(error.message()); parent_message .new_message("error") - .with_content(object!{ + .with_content(object! { "ename" => "Error", "evalue" => error.message(), "traceback" => traceback, - }).send(&mut *self.iopub.lock().unwrap())?; + }) + .send(&mut *self.iopub.lock().unwrap())?; } else { parent_message .new_message("error") - .with_content(object!{ + .with_content(object! { "ename" => "Error", "evalue" => error.message(), "traceback" => array![ message ], - }).send(&mut *self.iopub.lock().unwrap())?; + }) + .send(&mut *self.iopub.lock().unwrap())?; } } } @@ -375,11 +381,12 @@ impl Server { let displayed_error = format!("{}", error); parent_message .new_message("error") - .with_content(object!{ + .with_content(object! { "ename" => "Error", "evalue" => displayed_error.clone(), "traceback" => array![displayed_error], - }).send(&mut *self.iopub.lock().unwrap())?; + }) + .send(&mut *self.iopub.lock().unwrap())?; } } Ok(()) @@ -398,7 +405,7 @@ fn bind_socket( /// See [Kernel info documentation](https://jupyter-client.readthedocs.io/en/stable/messaging.html#kernel-info) fn kernel_info() -> JsonValue { - object!{ + object! { "protocol_version" => "5.3", "implementation" => env!("CARGO_PKG_NAME"), "implementation_version" => env!("CARGO_PKG_VERSION"), diff --git a/evcxr_jupyter/src/install.rs b/evcxr_jupyter/src/install.rs index 1ad679d..313efc5 100644 --- a/evcxr_jupyter/src/install.rs +++ b/evcxr_jupyter/src/install.rs @@ -29,7 +29,7 @@ pub(crate) fn install() -> Result<(), Error> { let current_exe = current_exe_path .to_str() .ok_or_else(|| format_err!("current exe path isn't valid UTF-8"))?; - let kernel_json = object!{ + let kernel_json = object! { "argv" => array![current_exe, "--control_file", "{connection_file}"], "display_name" => "Rust", "language" => "rust", diff --git a/evcxr_jupyter/tests/integration_tests.rs b/evcxr_jupyter/tests/integration_tests.rs index 65d0105..446071e 100644 --- a/evcxr_jupyter/tests/integration_tests.rs +++ b/evcxr_jupyter/tests/integration_tests.rs @@ -29,7 +29,8 @@ fn test_binary_execution() { .parent() .unwrap() .join("evcxr_jupyter"), - ).arg("--help") + ) + .arg("--help") .env_remove("LD_LIBRARY_PATH") .output() .unwrap(); diff --git a/evcxr_repl/tests/integration_tests.rs b/evcxr_repl/tests/integration_tests.rs index e0e6ed5..7545275 100644 --- a/evcxr_repl/tests/integration_tests.rs +++ b/evcxr_repl/tests/integration_tests.rs @@ -29,7 +29,8 @@ fn test_binary_execution() { .parent() .unwrap() .join("evcxr"), - ).arg("--help") + ) + .arg("--help") .env_remove("LD_LIBRARY_PATH") .output() .unwrap();