mirror of https://github.com/kdl-org/kdl-rs.git
ran `cargo clippy --fix -- -Wclippy::use_self`
This commit is contained in:
parent
439aa63bfc
commit
f37f77abed
|
|
@ -210,7 +210,7 @@ impl KdlDocument {
|
||||||
|
|
||||||
/// Length of this document when rendered as a string.
|
/// Length of this document when rendered as a string.
|
||||||
pub fn len(&self) -> usize {
|
pub fn len(&self) -> usize {
|
||||||
format!("{}", self).len()
|
format!("{self}").len()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns true if this document is completely empty (including whitespace)
|
/// Returns true if this document is completely empty (including whitespace)
|
||||||
|
|
@ -347,7 +347,7 @@ impl KdlDocument {
|
||||||
pub fn parse(s: &str) -> Result<Self, KdlError> {
|
pub fn parse(s: &str) -> Result<Self, KdlError> {
|
||||||
#[cfg(not(feature = "v1-fallback"))]
|
#[cfg(not(feature = "v1-fallback"))]
|
||||||
{
|
{
|
||||||
KdlDocument::parse_v2(s)
|
Self::parse_v2(s)
|
||||||
}
|
}
|
||||||
#[cfg(feature = "v1-fallback")]
|
#[cfg(feature = "v1-fallback")]
|
||||||
{
|
{
|
||||||
|
|
@ -522,7 +522,7 @@ impl std::str::FromStr for KdlDocument {
|
||||||
type Err = KdlError;
|
type Err = KdlError;
|
||||||
|
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||||
KdlDocument::parse(s)
|
Self::parse(s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -539,13 +539,13 @@ impl KdlDocument {
|
||||||
indent: usize,
|
indent: usize,
|
||||||
) -> std::fmt::Result {
|
) -> std::fmt::Result {
|
||||||
if let Some(KdlDocumentFormat { leading, .. }) = self.format() {
|
if let Some(KdlDocumentFormat { leading, .. }) = self.format() {
|
||||||
write!(f, "{}", leading)?;
|
write!(f, "{leading}")?;
|
||||||
}
|
}
|
||||||
for node in &self.nodes {
|
for node in &self.nodes {
|
||||||
node.stringify(f, indent)?;
|
node.stringify(f, indent)?;
|
||||||
}
|
}
|
||||||
if let Some(KdlDocumentFormat { trailing, .. }) = self.format() {
|
if let Some(KdlDocumentFormat { trailing, .. }) = self.format() {
|
||||||
write!(f, "{}", trailing)?;
|
write!(f, "{trailing}")?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
28
src/entry.rs
28
src/entry.rs
|
|
@ -41,7 +41,7 @@ impl std::hash::Hash for KdlEntry {
|
||||||
impl KdlEntry {
|
impl KdlEntry {
|
||||||
/// Creates a new Argument (positional) KdlEntry.
|
/// Creates a new Argument (positional) KdlEntry.
|
||||||
pub fn new(value: impl Into<KdlValue>) -> Self {
|
pub fn new(value: impl Into<KdlValue>) -> Self {
|
||||||
KdlEntry {
|
Self {
|
||||||
ty: None,
|
ty: None,
|
||||||
value: value.into(),
|
value: value.into(),
|
||||||
name: None,
|
name: None,
|
||||||
|
|
@ -129,7 +129,7 @@ impl KdlEntry {
|
||||||
|
|
||||||
/// Creates a new Property (key/value) KdlEntry.
|
/// Creates a new Property (key/value) KdlEntry.
|
||||||
pub fn new_prop(key: impl Into<KdlIdentifier>, value: impl Into<KdlValue>) -> Self {
|
pub fn new_prop(key: impl Into<KdlIdentifier>, value: impl Into<KdlValue>) -> Self {
|
||||||
KdlEntry {
|
Self {
|
||||||
ty: None,
|
ty: None,
|
||||||
value: value.into(),
|
value: value.into(),
|
||||||
name: Some(key.into()),
|
name: Some(key.into()),
|
||||||
|
|
@ -153,7 +153,7 @@ impl KdlEntry {
|
||||||
|
|
||||||
/// Length of this entry when rendered as a string.
|
/// Length of this entry when rendered as a string.
|
||||||
pub fn len(&self) -> usize {
|
pub fn len(&self) -> usize {
|
||||||
format!("{}", self).len()
|
format!("{self}").len()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns true if this entry is completely empty (including whitespace).
|
/// Returns true if this entry is completely empty (including whitespace).
|
||||||
|
|
@ -404,17 +404,17 @@ impl From<kdlv1::KdlEntry> for KdlEntry {
|
||||||
impl Display for KdlEntry {
|
impl Display for KdlEntry {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
if let Some(KdlEntryFormat { leading, .. }) = &self.format {
|
if let Some(KdlEntryFormat { leading, .. }) = &self.format {
|
||||||
write!(f, "{}", leading)?;
|
write!(f, "{leading}")?;
|
||||||
}
|
}
|
||||||
if let Some(name) = &self.name {
|
if let Some(name) = &self.name {
|
||||||
write!(f, "{}", name)?;
|
write!(f, "{name}")?;
|
||||||
if let Some(KdlEntryFormat {
|
if let Some(KdlEntryFormat {
|
||||||
after_key,
|
after_key,
|
||||||
after_eq,
|
after_eq,
|
||||||
..
|
..
|
||||||
}) = &self.format
|
}) = &self.format
|
||||||
{
|
{
|
||||||
write!(f, "{}={}", after_key, after_eq)?;
|
write!(f, "{after_key}={after_eq}")?;
|
||||||
} else {
|
} else {
|
||||||
write!(f, "=")?;
|
write!(f, "=")?;
|
||||||
}
|
}
|
||||||
|
|
@ -422,11 +422,11 @@ impl Display for KdlEntry {
|
||||||
if let Some(ty) = &self.ty {
|
if let Some(ty) = &self.ty {
|
||||||
write!(f, "(")?;
|
write!(f, "(")?;
|
||||||
if let Some(KdlEntryFormat { before_ty_name, .. }) = &self.format {
|
if let Some(KdlEntryFormat { before_ty_name, .. }) = &self.format {
|
||||||
write!(f, "{}", before_ty_name)?;
|
write!(f, "{before_ty_name}")?;
|
||||||
}
|
}
|
||||||
write!(f, "{}", ty)?;
|
write!(f, "{ty}")?;
|
||||||
if let Some(KdlEntryFormat { after_ty_name, .. }) = &self.format {
|
if let Some(KdlEntryFormat { after_ty_name, .. }) = &self.format {
|
||||||
write!(f, "{}", after_ty_name)?;
|
write!(f, "{after_ty_name}")?;
|
||||||
}
|
}
|
||||||
write!(f, ")")?;
|
write!(f, ")")?;
|
||||||
}
|
}
|
||||||
|
|
@ -436,12 +436,12 @@ impl Display for KdlEntry {
|
||||||
..
|
..
|
||||||
}) = &self.format
|
}) = &self.format
|
||||||
{
|
{
|
||||||
write!(f, "{}{}", after_ty, value_repr)?;
|
write!(f, "{after_ty}{value_repr}")?;
|
||||||
} else {
|
} else {
|
||||||
write!(f, "{}", self.value)?;
|
write!(f, "{}", self.value)?;
|
||||||
}
|
}
|
||||||
if let Some(KdlEntryFormat { trailing, .. }) = &self.format {
|
if let Some(KdlEntryFormat { trailing, .. }) = &self.format {
|
||||||
write!(f, "{}", trailing)?;
|
write!(f, "{trailing}")?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
@ -452,7 +452,7 @@ where
|
||||||
T: Into<KdlValue>,
|
T: Into<KdlValue>,
|
||||||
{
|
{
|
||||||
fn from(value: T) -> Self {
|
fn from(value: T) -> Self {
|
||||||
KdlEntry::new(value)
|
Self::new(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -462,7 +462,7 @@ where
|
||||||
V: Into<KdlValue>,
|
V: Into<KdlValue>,
|
||||||
{
|
{
|
||||||
fn from((key, value): (K, V)) -> Self {
|
fn from((key, value): (K, V)) -> Self {
|
||||||
KdlEntry::new_prop(key, value)
|
Self::new_prop(key, value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -470,7 +470,7 @@ impl FromStr for KdlEntry {
|
||||||
type Err = KdlError;
|
type Err = KdlError;
|
||||||
|
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||||
KdlEntry::parse(s)
|
Self::parse(s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -122,7 +122,7 @@ pub(crate) fn autoformat_leading(leading: &mut String, config: &FormatConfig<'_>
|
||||||
for _ in 0..config.indent_level {
|
for _ in 0..config.indent_level {
|
||||||
result.push_str(config.indent);
|
result.push_str(config.indent);
|
||||||
}
|
}
|
||||||
writeln!(result, "{}", trimmed).unwrap();
|
writeln!(result, "{trimmed}").unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ impl KdlIdentifier {
|
||||||
|
|
||||||
/// Length of this identifier when rendered as a string.
|
/// Length of this identifier when rendered as a string.
|
||||||
pub fn len(&self) -> usize {
|
pub fn len(&self) -> usize {
|
||||||
format!("{}", self).len()
|
format!("{self}").len()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns true if this identifier is completely empty.
|
/// Returns true if this identifier is completely empty.
|
||||||
|
|
@ -129,7 +129,7 @@ impl From<kdlv1::KdlIdentifier> for KdlIdentifier {
|
||||||
impl Display for KdlIdentifier {
|
impl Display for KdlIdentifier {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
if let Some(repr) = &self.repr {
|
if let Some(repr) = &self.repr {
|
||||||
write!(f, "{}", repr)
|
write!(f, "{repr}")
|
||||||
} else {
|
} else {
|
||||||
write!(f, "{}", KdlValue::String(self.value().into()))
|
write!(f, "{}", KdlValue::String(self.value().into()))
|
||||||
}
|
}
|
||||||
|
|
@ -138,7 +138,7 @@ impl Display for KdlIdentifier {
|
||||||
|
|
||||||
impl From<&str> for KdlIdentifier {
|
impl From<&str> for KdlIdentifier {
|
||||||
fn from(value: &str) -> Self {
|
fn from(value: &str) -> Self {
|
||||||
KdlIdentifier {
|
Self {
|
||||||
value: value.to_string(),
|
value: value.to_string(),
|
||||||
repr: None,
|
repr: None,
|
||||||
#[cfg(feature = "span")]
|
#[cfg(feature = "span")]
|
||||||
|
|
@ -149,7 +149,7 @@ impl From<&str> for KdlIdentifier {
|
||||||
|
|
||||||
impl From<String> for KdlIdentifier {
|
impl From<String> for KdlIdentifier {
|
||||||
fn from(value: String) -> Self {
|
fn from(value: String) -> Self {
|
||||||
KdlIdentifier {
|
Self {
|
||||||
value,
|
value,
|
||||||
repr: None,
|
repr: None,
|
||||||
#[cfg(feature = "span")]
|
#[cfg(feature = "span")]
|
||||||
|
|
@ -168,7 +168,7 @@ impl FromStr for KdlIdentifier {
|
||||||
type Err = KdlError;
|
type Err = KdlError;
|
||||||
|
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||||
KdlIdentifier::parse(s)
|
Self::parse(s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
18
src/node.rs
18
src/node.rs
|
|
@ -626,8 +626,7 @@ impl KdlNode {
|
||||||
}
|
}
|
||||||
if idx > current_idx {
|
if idx > current_idx {
|
||||||
panic!(
|
panic!(
|
||||||
"Insertion index (is {}) should be <= len (is {})",
|
"Insertion index (is {idx}) should be <= len (is {current_idx})"
|
||||||
idx, current_idx
|
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
self.entries.push(entry);
|
self.entries.push(entry);
|
||||||
|
|
@ -720,8 +719,7 @@ impl KdlNode {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
panic!(
|
panic!(
|
||||||
"removal index (is {}) should be < number of index entries (is {})",
|
"removal index (is {idx}) should be < number of index entries (is {current_idx})"
|
||||||
idx, current_idx
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -766,19 +764,19 @@ pub enum NodeKey {
|
||||||
|
|
||||||
impl From<&str> for NodeKey {
|
impl From<&str> for NodeKey {
|
||||||
fn from(key: &str) -> Self {
|
fn from(key: &str) -> Self {
|
||||||
NodeKey::Key(key.into())
|
Self::Key(key.into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<String> for NodeKey {
|
impl From<String> for NodeKey {
|
||||||
fn from(key: String) -> Self {
|
fn from(key: String) -> Self {
|
||||||
NodeKey::Key(key.into())
|
Self::Key(key.into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<usize> for NodeKey {
|
impl From<usize> for NodeKey {
|
||||||
fn from(key: usize) -> Self {
|
fn from(key: usize) -> Self {
|
||||||
NodeKey::Index(key)
|
Self::Index(key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -834,12 +832,12 @@ impl KdlNode {
|
||||||
indent: usize,
|
indent: usize,
|
||||||
) -> std::fmt::Result {
|
) -> std::fmt::Result {
|
||||||
if let Some(KdlNodeFormat { leading, .. }) = self.format() {
|
if let Some(KdlNodeFormat { leading, .. }) = self.format() {
|
||||||
write!(f, "{}", leading)?;
|
write!(f, "{leading}")?;
|
||||||
} else {
|
} else {
|
||||||
write!(f, "{:indent$}", "", indent = indent)?;
|
write!(f, "{:indent$}", "", indent = indent)?;
|
||||||
}
|
}
|
||||||
if let Some(ty) = &self.ty {
|
if let Some(ty) = &self.ty {
|
||||||
write!(f, "({})", ty)?;
|
write!(f, "({ty})")?;
|
||||||
}
|
}
|
||||||
write!(f, "{}", self.name)?;
|
write!(f, "{}", self.name)?;
|
||||||
let mut space_before_children = true;
|
let mut space_before_children = true;
|
||||||
|
|
@ -847,7 +845,7 @@ impl KdlNode {
|
||||||
if entry.format().is_none() {
|
if entry.format().is_none() {
|
||||||
write!(f, " ")?;
|
write!(f, " ")?;
|
||||||
}
|
}
|
||||||
write!(f, "{}", entry)?;
|
write!(f, "{entry}")?;
|
||||||
space_before_children = entry.format().is_none();
|
space_before_children = entry.format().is_none();
|
||||||
}
|
}
|
||||||
if let Some(children) = &self.children {
|
if let Some(children) = &self.children {
|
||||||
|
|
|
||||||
|
|
@ -140,7 +140,7 @@ impl<I: Stream> AddContext<I, KdlParseContext> for KdlParseError {
|
||||||
|
|
||||||
impl<'a> FromExternalError<Input<'a>, ParseIntError> for KdlParseError {
|
impl<'a> FromExternalError<Input<'a>, ParseIntError> for KdlParseError {
|
||||||
fn from_external_error(_: &Input<'a>, _kind: ErrorKind, e: ParseIntError) -> Self {
|
fn from_external_error(_: &Input<'a>, _kind: ErrorKind, e: ParseIntError) -> Self {
|
||||||
KdlParseError {
|
Self {
|
||||||
span: None,
|
span: None,
|
||||||
message: Some(format!("{e}")),
|
message: Some(format!("{e}")),
|
||||||
label: Some("invalid integer".into()),
|
label: Some("invalid integer".into()),
|
||||||
|
|
@ -152,7 +152,7 @@ impl<'a> FromExternalError<Input<'a>, ParseIntError> for KdlParseError {
|
||||||
|
|
||||||
impl<'a> FromExternalError<Input<'a>, ParseFloatError> for KdlParseError {
|
impl<'a> FromExternalError<Input<'a>, ParseFloatError> for KdlParseError {
|
||||||
fn from_external_error(_input: &Input<'a>, _kind: ErrorKind, e: ParseFloatError) -> Self {
|
fn from_external_error(_input: &Input<'a>, _kind: ErrorKind, e: ParseFloatError) -> Self {
|
||||||
KdlParseError {
|
Self {
|
||||||
span: None,
|
span: None,
|
||||||
label: Some("invalid float".into()),
|
label: Some("invalid float".into()),
|
||||||
help: None,
|
help: None,
|
||||||
|
|
@ -170,7 +170,7 @@ impl<'a> FromExternalError<Input<'a>, NegativeUnsignedError> for KdlParseError {
|
||||||
_kind: ErrorKind,
|
_kind: ErrorKind,
|
||||||
_e: NegativeUnsignedError,
|
_e: NegativeUnsignedError,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
KdlParseError {
|
Self {
|
||||||
span: None,
|
span: None,
|
||||||
message: Some("Tried to parse a negative number as an unsigned integer".into()),
|
message: Some("Tried to parse a negative number as an unsigned integer".into()),
|
||||||
label: Some("negative unsigned int".into()),
|
label: Some("negative unsigned int".into()),
|
||||||
|
|
|
||||||
32
src/value.rs
32
src/value.rs
|
|
@ -62,9 +62,9 @@ impl PartialEq for KdlValue {
|
||||||
impl std::hash::Hash for KdlValue {
|
impl std::hash::Hash for KdlValue {
|
||||||
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
|
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
|
||||||
match self {
|
match self {
|
||||||
KdlValue::String(val) => val.hash(state),
|
Self::String(val) => val.hash(state),
|
||||||
KdlValue::Integer(val) => val.hash(state),
|
Self::Integer(val) => val.hash(state),
|
||||||
KdlValue::Float(val) => {
|
Self::Float(val) => {
|
||||||
let val = if val == &f64::INFINITY {
|
let val = if val == &f64::INFINITY {
|
||||||
f64::MAX
|
f64::MAX
|
||||||
} else if val == &f64::NEG_INFINITY {
|
} else if val == &f64::NEG_INFINITY {
|
||||||
|
|
@ -79,8 +79,8 @@ impl std::hash::Hash for KdlValue {
|
||||||
(val.trunc() as i128).hash(state);
|
(val.trunc() as i128).hash(state);
|
||||||
(val.fract() as i128).hash(state);
|
(val.fract() as i128).hash(state);
|
||||||
}
|
}
|
||||||
KdlValue::Bool(val) => val.hash(state),
|
Self::Bool(val) => val.hash(state),
|
||||||
KdlValue::Null => core::mem::discriminant(self).hash(state),
|
Self::Null => core::mem::discriminant(self).hash(state),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -154,7 +154,7 @@ impl Display for KdlValue {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
Self::String(_) => self.write_string(f),
|
Self::String(_) => self.write_string(f),
|
||||||
Self::Integer(value) => write!(f, "{:?}", value),
|
Self::Integer(value) => write!(f, "{value:?}"),
|
||||||
Self::Float(value) => write!(
|
Self::Float(value) => write!(
|
||||||
f,
|
f,
|
||||||
"{}",
|
"{}",
|
||||||
|
|
@ -168,7 +168,7 @@ impl Display for KdlValue {
|
||||||
format!("{:?}", *value)
|
format!("{:?}", *value)
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
Self::Bool(value) => write!(f, "#{}", value),
|
Self::Bool(value) => write!(f, "#{value}"),
|
||||||
Self::Null => write!(f, "#null"),
|
Self::Null => write!(f, "#null"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -204,13 +204,13 @@ impl KdlValue {
|
||||||
write!(f, "\"")?;
|
write!(f, "\"")?;
|
||||||
for char in string.chars() {
|
for char in string.chars() {
|
||||||
match char {
|
match char {
|
||||||
'\\' | '"' => write!(f, "\\{}", char)?,
|
'\\' | '"' => write!(f, "\\{char}")?,
|
||||||
'\n' => write!(f, "\\n")?,
|
'\n' => write!(f, "\\n")?,
|
||||||
'\r' => write!(f, "\\r")?,
|
'\r' => write!(f, "\\r")?,
|
||||||
'\t' => write!(f, "\\t")?,
|
'\t' => write!(f, "\\t")?,
|
||||||
'\u{08}' => write!(f, "\\b")?,
|
'\u{08}' => write!(f, "\\b")?,
|
||||||
'\u{0C}' => write!(f, "\\f")?,
|
'\u{0C}' => write!(f, "\\f")?,
|
||||||
_ => write!(f, "{}", char)?,
|
_ => write!(f, "{char}")?,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
write!(f, "\"")?;
|
write!(f, "\"")?;
|
||||||
|
|
@ -221,42 +221,42 @@ impl KdlValue {
|
||||||
|
|
||||||
impl From<i128> for KdlValue {
|
impl From<i128> for KdlValue {
|
||||||
fn from(value: i128) -> Self {
|
fn from(value: i128) -> Self {
|
||||||
KdlValue::Integer(value)
|
Self::Integer(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<f64> for KdlValue {
|
impl From<f64> for KdlValue {
|
||||||
fn from(value: f64) -> Self {
|
fn from(value: f64) -> Self {
|
||||||
KdlValue::Float(value)
|
Self::Float(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<&str> for KdlValue {
|
impl From<&str> for KdlValue {
|
||||||
fn from(value: &str) -> Self {
|
fn from(value: &str) -> Self {
|
||||||
KdlValue::String(value.to_string())
|
Self::String(value.to_string())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<String> for KdlValue {
|
impl From<String> for KdlValue {
|
||||||
fn from(value: String) -> Self {
|
fn from(value: String) -> Self {
|
||||||
KdlValue::String(value)
|
Self::String(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<bool> for KdlValue {
|
impl From<bool> for KdlValue {
|
||||||
fn from(value: bool) -> Self {
|
fn from(value: bool) -> Self {
|
||||||
KdlValue::Bool(value)
|
Self::Bool(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> From<Option<T>> for KdlValue
|
impl<T> From<Option<T>> for KdlValue
|
||||||
where
|
where
|
||||||
T: Into<KdlValue>,
|
T: Into<Self>,
|
||||||
{
|
{
|
||||||
fn from(value: Option<T>) -> Self {
|
fn from(value: Option<T>) -> Self {
|
||||||
match value {
|
match value {
|
||||||
Some(value) => value.into(),
|
Some(value) => value.into(),
|
||||||
None => KdlValue::Null,
|
None => Self::Null,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue