mirror of
https://github.com/tweag/nickel.git
synced 2024-10-06 16:18:08 +03:00
Create a method "into_label" in Ident to make conversion more explicit than using "into"
This commit is contained in:
parent
fcd72cba0b
commit
36628678d9
@ -50,7 +50,7 @@ pub fn handle_completion(
|
||||
_ => None,
|
||||
})
|
||||
.map(|(ident, _)| CompletionItem {
|
||||
label: ident.into(),
|
||||
label: ident.into_label(),
|
||||
..Default::default()
|
||||
})
|
||||
.collect();
|
||||
|
@ -70,7 +70,7 @@ impl<'de> serde::Deserializer<'de> for RichTerm {
|
||||
Term::Num(v) => visitor.visit_f64(v),
|
||||
Term::Str(v) => visitor.visit_string(v),
|
||||
Term::Enum(v) => visitor.visit_enum(EnumDeserializer {
|
||||
variant: v.into(),
|
||||
variant: v.into_label(),
|
||||
rich_term: None,
|
||||
}),
|
||||
Term::Record(v, _) => visit_record(v, visitor),
|
||||
@ -117,7 +117,7 @@ impl<'de> serde::Deserializer<'de> for RichTerm {
|
||||
V: Visitor<'de>,
|
||||
{
|
||||
let (variant, rich_term) = match unwrap_term(self)? {
|
||||
Term::Enum(ident) => (ident.into(), None),
|
||||
Term::Enum(ident) => (ident.into_label(), None),
|
||||
Term::Record(v, _) => {
|
||||
let mut iter = v.into_iter();
|
||||
let (variant, value) = match iter.next() {
|
||||
@ -135,7 +135,7 @@ impl<'de> serde::Deserializer<'de> for RichTerm {
|
||||
occurred: "Record with multiple keys".to_string(),
|
||||
});
|
||||
}
|
||||
(variant.into(), Some(value))
|
||||
(variant.into_label(), Some(value))
|
||||
}
|
||||
other => {
|
||||
return Err(RustDeserializationError::InvalidType {
|
||||
|
@ -446,7 +446,7 @@ fn process_unary_operation(
|
||||
})
|
||||
}
|
||||
None => Err(EvalError::FieldMissing(
|
||||
id.into(),
|
||||
id.into_label(),
|
||||
String::from("(.)"),
|
||||
RichTerm { term: t, pos },
|
||||
pos_op,
|
||||
|
@ -33,6 +33,10 @@ impl Ident {
|
||||
pub fn label(&self) -> &str {
|
||||
INTERNER.lookup(self.symbol)
|
||||
}
|
||||
|
||||
pub fn into_label(self) -> String {
|
||||
self.label().to_owned()
|
||||
}
|
||||
}
|
||||
|
||||
/// Special character used for generating fresh identifiers. It must be syntactically impossible to
|
||||
@ -82,7 +86,7 @@ where
|
||||
|
||||
impl Into<String> for Ident {
|
||||
fn into(self) -> String {
|
||||
self.as_ref().to_owned()
|
||||
self.into_label()
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user