mirror of
https://github.com/astral-sh/ruff
synced 2026-01-23 06:20:55 -05:00
Implement From conversion for style detector-to-generator (#1678)
This commit is contained in:
@@ -9,7 +9,7 @@ use rustpython_parser::ast::{
|
||||
Operator, Stmt, StmtKind,
|
||||
};
|
||||
|
||||
use crate::source_code_style::{Indentation, LineEnding, Quote};
|
||||
use crate::source_code_style::{Indentation, LineEnding, Quote, SourceCodeStyleDetector};
|
||||
use crate::vendor::{bytes, str};
|
||||
|
||||
mod precedence {
|
||||
@@ -43,6 +43,20 @@ pub struct SourceCodeGenerator<'a> {
|
||||
initial: bool,
|
||||
}
|
||||
|
||||
impl<'a> From<&'a SourceCodeStyleDetector<'a>> for SourceCodeGenerator<'a> {
|
||||
fn from(stylist: &'a SourceCodeStyleDetector<'a>) -> Self {
|
||||
Self {
|
||||
indent: stylist.indentation(),
|
||||
quote: stylist.quote(),
|
||||
line_ending: stylist.line_ending(),
|
||||
buffer: Vec::new(),
|
||||
indent_depth: 0,
|
||||
num_newlines: 0,
|
||||
initial: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> SourceCodeGenerator<'a> {
|
||||
pub fn new(indent: &'a Indentation, quote: &'a Quote, line_ending: &'a LineEnding) -> Self {
|
||||
SourceCodeGenerator {
|
||||
|
||||
Reference in New Issue
Block a user