nushell/crates/nu-protocol/src/example.rs
Devyn Cairns 3857e368ff
Fix build of nu-protocol without plugin feature enabled (#12323)
# Description

I broke this, I think in #12279, because I forgot a `#[cfg(plugin)]`
2024-03-28 22:39:57 +01:00

32 lines
920 B
Rust

use crate::Value;
#[cfg(feature = "plugin")]
use serde::{Deserialize, Serialize};
#[derive(Debug)]
pub struct Example<'a> {
pub example: &'a str,
pub description: &'a str,
pub result: Option<Value>,
}
// PluginExample is somehow like struct `Example`, but it owned a String for `example`
// and `description` fields, because these information is fetched from plugin, a third party
// binary, nushell have no way to construct it directly.
#[cfg(feature = "plugin")]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PluginExample {
pub example: String,
pub description: String,
pub result: Option<Value>,
}
#[cfg(feature = "plugin")]
impl From<Example<'_>> for PluginExample {
fn from(value: Example) -> Self {
PluginExample {
example: value.example.into(),
description: value.description.into(),
result: value.result,
}
}
}