use proc_macro2::TokenStream;
use serde::{Deserialize, Serialize};
use crate::python_ast::{CodeGen, CodeGenContext, ExprType, Node, PythonOptions, SymbolTableScopes};
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct Starred {
pub value: Box<ExprType>,
pub ctx: Option<String>,
pub lineno: Option<usize>,
pub col_offset: Option<usize>,
pub end_lineno: Option<usize>,
pub end_col_offset: Option<usize>,
}
impl Node for Starred {
fn lineno(&self) -> Option<usize> {
self.lineno
}
fn col_offset(&self) -> Option<usize> {
self.col_offset
}
fn end_lineno(&self) -> Option<usize> {
self.end_lineno
}
fn end_col_offset(&self) -> Option<usize> {
self.end_col_offset
}
}
impl CodeGen for Starred {
type Context = CodeGenContext;
type Options = PythonOptions;
type SymbolTable = SymbolTableScopes;
fn find_symbols(self, symbols: Self::SymbolTable) -> Self::SymbolTable {
(*self.value).clone().find_symbols(symbols)
}
fn to_rust(self, _ctx: Self::Context, _options: Self::Options, _symbols: Self::SymbolTable) -> Result<TokenStream, Box<dyn std::error::Error>> {
Err("starred unpacking (`*expr`) is not supported yet: it would \
silently pass the collection as a single value instead of \
spreading its elements. Spell the elements out explicitly."
.to_string()
.into())
}
}
#[cfg(python_ast_upstream_tests)]
mod tests {
}