feat: Like `Option`, add `take` API to allow ownership transfer
This will be useful when mutably walking an expression tree and reusing existing allocations.pull/24376/head
parent
7cb3048035
commit
5987bc1ea2
|
@ -23,8 +23,8 @@ use nom::character::complete::{alpha1, alphanumeric1};
|
|||
use nom::combinator::{map, not, recognize};
|
||||
use nom::multi::many0_count;
|
||||
use nom::sequence::{pair, preceded};
|
||||
use std::fmt;
|
||||
use std::fmt::{Display, Formatter, Write};
|
||||
use std::{fmt, mem};
|
||||
|
||||
/// Parse an unquoted InfluxQL identifier.
|
||||
pub(crate) fn unquoted_identifier(i: &str) -> ParseResult<&str, &str> {
|
||||
|
@ -54,6 +54,11 @@ impl Identifier {
|
|||
pub fn requires_quotes(&self) -> bool {
|
||||
nom::sequence::terminated(unquoted_identifier, nom::combinator::eof)(&self.0).is_err()
|
||||
}
|
||||
|
||||
/// Takes the string value out of the identifier, leaving a default string value in its place.
|
||||
pub fn take(&mut self) -> String {
|
||||
mem::take(&mut self.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for Identifier {
|
||||
|
|
Loading…
Reference in New Issue