Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
cptpiepmatz committed Sep 13, 2024
1 parent 7365ff5 commit 5d19674
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 28 deletions.
14 changes: 6 additions & 8 deletions crates/nu_plugin_plotters/src/value/chart_2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,12 @@ impl FromValue for Chart2d {
let v = v.into_custom_value()?;
match v.as_any().downcast_ref::<Self>() {
Some(v) => Ok(v.clone()),
None => {
Err(ShellError::CantConvert {
to_type: Self::ty().to_string(),
from_type: v.type_name(),
span,
help: None,
})
}
None => Err(ShellError::CantConvert {
to_type: Self::ty().to_string(),
from_type: v.type_name(),
span,
help: None,
}),
}
}

Expand Down
14 changes: 6 additions & 8 deletions crates/nu_plugin_plotters/src/value/series_2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,12 @@ impl FromValue for Series2d {
let v = v.into_custom_value()?;
match v.as_any().downcast_ref::<Self>() {
Some(v) => Ok(v.clone()),
None => {
Err(ShellError::CantConvert {
to_type: Self::ty().to_string(),
from_type: v.type_name(),
span,
help: None,
})
}
None => Err(ShellError::CantConvert {
to_type: Self::ty().to_string(),
from_type: v.type_name(),
span,
help: None,
}),
}
}

Expand Down
4 changes: 1 addition & 3 deletions src/error.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#[derive(Debug)]
pub enum KernelError {
MissingFormatDecls {
missing: Vec<&'static str>
}
MissingFormatDecls { missing: Vec<&'static str> },
}
9 changes: 6 additions & 3 deletions src/handlers/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ use crate::jupyter::kernel_info::KernelInfo;
use crate::jupyter::messages::iopub::{self, ExecuteResult, IopubBroacast, Status};
use crate::jupyter::messages::multipart::Multipart;
use crate::jupyter::messages::shell::{
ExecuteReply, ExecuteRequest, IsCompleteReply, IsCompleteRequest, ShellReply, ShellReplyOk, ShellRequest
ExecuteReply, ExecuteRequest, IsCompleteReply, IsCompleteRequest, ShellReply, ShellReplyOk,
ShellRequest,
};
use crate::jupyter::messages::{Header, Message, Metadata};
use crate::jupyter::Shutdown;
Expand Down Expand Up @@ -74,7 +75,9 @@ pub async fn handle(mut ctx: HandlerContext, mut shutdown: broadcast::Receiver<S
// take the context out temporarily to allow execution on another thread
ctx = handle_execute_request(ctx, &message, request).await;
}
ShellRequest::IsComplete(request) => handle_is_complete_request(&mut ctx, &message, request).await,
ShellRequest::IsComplete(request) => {
handle_is_complete_request(&mut ctx, &message, request).await
}
}

send_status(&mut ctx, &message, Status::Idle).await;
Expand Down Expand Up @@ -331,7 +334,7 @@ async fn handle_execute_results(
}

async fn handle_is_complete_request(
ctx: &mut HandlerContext,
ctx: &mut HandlerContext,
message: &Message<ShellRequest>,
request: &IsCompleteRequest,
) {
Expand Down
6 changes: 3 additions & 3 deletions src/jupyter/connection_file.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::{fmt::Display, io};
use std::fs;
use std::fmt::Display;
use std::net::Ipv4Addr;
use std::path::Path;
use std::{fs, io};

use serde::{Deserialize, Deserializer};
use thiserror::Error;
Expand All @@ -26,7 +26,7 @@ pub enum ReadConnectionFileError {
#[error("could not read connection file")]
ReadFile(#[from] io::Error),
#[error("could not parse connection file")]
Parse(#[from] serde_json::Error)
Parse(#[from] serde_json::Error),
}

impl ConnectionFile {
Expand Down
10 changes: 7 additions & 3 deletions src/nu/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ fn add_env_context(mut engine_state: EngineState) -> EngineState {
}

let span_offset = engine_state.next_span_start();
engine_state.add_file("Host Environment Variables".into(), toml.into_bytes().into());
engine_state.add_file(
"Host Environment Variables".into(),
toml.into_bytes().into(),
);
for (key, value) in values {
let span = value.span();
let span = Span::new(span.start + span_offset, span.end + span_offset);
Expand All @@ -72,8 +75,9 @@ fn configure_engine_state(mut engine_state: EngineState) -> EngineState {
engine_state.history_enabled = false;
engine_state.is_interactive = false;
engine_state.is_login = false;

// if we cannot access the current dir, we probably also cannot access the subdirectories

// if we cannot access the current dir, we probably also cannot access the
// subdirectories
if let Ok(mut config_dir) = env::current_dir() {
config_dir.push(".nu");
engine_state.set_config_path("config-path", config_dir.join("config.nu"));
Expand Down
1 change: 1 addition & 0 deletions src/nu/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use nu_protocol::debugger::WithoutDebug;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{PipelineData, ShellError, Span, Spanned, Value};
use thiserror::Error;

use crate::error::KernelError;

macro_rules! create_format_decl_ids {
Expand Down

0 comments on commit 5d19674

Please sign in to comment.