More enum work (#3212)

This commit is contained in:
Jeong YunWon 2023-02-26 01:40:16 +09:00 committed by GitHub
parent 248590224a
commit 84e96cdcd9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 93 additions and 224 deletions

View file

@ -4,7 +4,7 @@ use ruff_text_size::TextRange;
use crate::context::ASTFormatContext;
use crate::core::types::Range;
use crate::trivia::{Relationship, Trivia, TriviaKind};
use crate::trivia::{Trivia, TriviaKind};
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub struct Literal {
@ -36,7 +36,7 @@ pub struct LeadingComments<'a> {
impl Format<ASTFormatContext<'_>> for LeadingComments<'_> {
fn fmt(&self, f: &mut Formatter<ASTFormatContext<'_>>) -> FormatResult<()> {
for comment in self.comments {
if matches!(comment.relationship, Relationship::Leading) {
if comment.relationship.is_leading() {
if let TriviaKind::OwnLineComment(range) = comment.kind {
write!(f, [hard_line_break()])?;
write!(f, [literal(range)])?;
@ -60,7 +60,7 @@ pub struct TrailingComments<'a> {
impl Format<ASTFormatContext<'_>> for TrailingComments<'_> {
fn fmt(&self, f: &mut Formatter<ASTFormatContext<'_>>) -> FormatResult<()> {
for comment in self.comments {
if matches!(comment.relationship, Relationship::Trailing) {
if comment.relationship.is_trailing() {
if let TriviaKind::OwnLineComment(range) = comment.kind {
write!(f, [hard_line_break()])?;
write!(f, [literal(range)])?;