settings: Remove auxiliary Content types where possible (#16744)
Release Notes: - N/A
This commit is contained in:
parent
8f28445612
commit
ccf6f27b8f
49 changed files with 843 additions and 696 deletions
|
@ -6,8 +6,10 @@ use schemars::JsonSchema;
|
|||
use serde::{Deserialize, Serialize};
|
||||
use settings::{Settings, SettingsSources};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Clone, Debug, Default, Serialize, Deserialize, JsonSchema)]
|
||||
#[serde(default)]
|
||||
pub struct JupyterSettings {
|
||||
/// Default kernels to select for each language.
|
||||
pub kernel_selections: HashMap<String, String>,
|
||||
}
|
||||
|
||||
|
@ -20,26 +22,10 @@ impl JupyterSettings {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Serialize, Deserialize, JsonSchema, Debug)]
|
||||
pub struct JupyterSettingsContent {
|
||||
/// Default kernels to select for each language.
|
||||
///
|
||||
/// Default: `{}`
|
||||
pub kernel_selections: Option<HashMap<String, String>>,
|
||||
}
|
||||
|
||||
impl Default for JupyterSettingsContent {
|
||||
fn default() -> Self {
|
||||
JupyterSettingsContent {
|
||||
kernel_selections: Some(HashMap::new()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Settings for JupyterSettings {
|
||||
const KEY: Option<&'static str> = Some("jupyter");
|
||||
|
||||
type FileContent = JupyterSettingsContent;
|
||||
type FileContent = Self;
|
||||
|
||||
fn load(
|
||||
sources: SettingsSources<Self::FileContent>,
|
||||
|
@ -51,10 +37,8 @@ impl Settings for JupyterSettings {
|
|||
let mut settings = JupyterSettings::default();
|
||||
|
||||
for value in sources.defaults_and_customizations() {
|
||||
if let Some(source) = &value.kernel_selections {
|
||||
for (k, v) in source {
|
||||
settings.kernel_selections.insert(k.clone(), v.clone());
|
||||
}
|
||||
for (k, v) in &value.kernel_selections {
|
||||
settings.kernel_selections.insert(k.clone(), v.clone());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue