/
githubmirror
/
sway
Обзор
Документация
Войти
/
githubmirror
/
sway
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
swayfmt/src/utils/mod.rs
68 строк
2 KB
Daniel Frederico Lins Leite
Const generic feature toggle, parser and errors. (#6926)
18 фев 2025, 01:28
Не верифицирован
18 фев 2025, 01:28
d8854fa
Код
Авторство
О чём код?
use crate::formatter::*; use std::fmt::Write; use sway_types::ast::PunctKind; pub(crate) mod language; pub(crate) mod map; pub(crate) trait CurlyBrace { /// Handles brace open scenario. Checks the config for the placement of the brace. /// Modifies the current shape of the formatter. fn open_curly_brace( line: &mut FormattedCode, formatter: &mut Formatter, ) -> Result<(), FormatterError>; /// Handles brace close scenario. /// Currently it simply pushes a `}` and modifies the shape. fn close_curly_brace( line: &mut FormattedCode, formatter: &mut Formatter, ) -> Result<(), FormatterError>; } pub(crate) trait SquareBracket { fn open_square_bracket( line: &mut FormattedCode, formatter: &mut Formatter, ) -> Result<(), FormatterError>; fn close_square_bracket( line: &mut FormattedCode, formatter: &mut Formatter, ) -> Result<(), FormatterError>; } pub(crate) trait Parenthesis { /// Handles open parenthesis scenarios, checking the config for placement /// and modifying the shape of the formatter where necessary. fn open_parenthesis( line: &mut FormattedCode, formatter: &mut Formatter, ) -> Result<(), FormatterError>; /// Handles the closing parenthesis scenario. fn close_parenthesis( line: &mut FormattedCode, formatter: &mut Formatter, ) -> Result<(), FormatterError>; } pub(crate) fn open_angle_bracket(formatted_code: &mut FormattedCode) -> Result<(), FormatterError> { write!(formatted_code, "{}", PunctKind::LessThan.as_char())?; Ok(()) } pub(crate) fn close_angle_bracket( formatted_code: &mut FormattedCode, ) -> Result<(), FormatterError> { write!(formatted_code, "{}", PunctKind::GreaterThan.as_char())?; Ok(()) } pub(crate) fn colon(formatted_code: &mut FormattedCode) -> Result<(), FormatterError> { write!(formatted_code, "{}", PunctKind::Colon.as_char())?; Ok(()) }