Contains a false->identifier mapping which is tricky in the AST.

Code view:

A painting is a person's account of this edit as text, recorded independently of the node mapping - a rendering often has several equally defensible answers where the mapping has one. Deletions and insertions carry no position on the opposite side in a painting, so that panel draws no caret for them.

Before

1//! Toggler style
2
3#![allow(clippy::module_name_repetitions)]
4
5use iced::Color;
6use iced::widget::toggler::{Catalog, Status, Style};
7
8use crate::StyleType;
9use crate::gui::styles::style_constants::BORDER_WIDTH;
10
11#[derive(Default)]
…lines 12–24 unchanged (13 lines)
25 ..colors.secondary
26 }
27 } else {
28 ext.buttons_color
29 };
30 Style {
31 background: bg_color,
32 background_border_width: BORDER_WIDTH,
33 background_border_color: bg_color,
34 foreground: colors.primary,
35 foreground_border_width: BORDER_WIDTH,
36 foreground_border_color: if is_active {
37 colors.secondary
38 } else {
39 Color::TRANSPARENT
40 },
41 }
42 }
43
44 #[allow(clippy::unused_self)]
45 fn hovered(&self, style: &StyleType, is_active: bool) -> Style {
46 let colors = style.get_palette();
47 let ext = style.get_extension();
48 let bg_color = if is_active {
49 Color {
50 a: ext.alpha_chart_badge,
51 ..colors.secondary
52 }
53 } else {
54 ext.buttons_color
55 };
56 Style {
57 background: bg_color,
58 background_border_width: BORDER_WIDTH,
59 background_border_color: colors.secondary,
60 foreground: colors.primary,
61 foreground_border_width: BORDER_WIDTH,
62 foreground_border_color: if is_active {
63 colors.secondary
64 } else {
65 Color::TRANSPARENT
66 },
67 }
68 }
69}
70
71impl Catalog for StyleType {
72 type Class<'a> = TogglerType;
73
74 fn default<'a>() -> Self::Class<'a> {
75 Self::Class::default()
76 }
77
78 fn style(&self, class: &Self::Class<'_>, status: Status) -> Style {
79 match status {
80 Status::Active { is_toggled } => class.active(self, is_toggled),
81 Status::Hovered { is_toggled } => class.hovered(self, is_toggled),
82 Status::Disabled => class.active(self, false),
83 }
84 }
85}
86

After

1//! Toggler style
2
3#![allow(clippy::module_name_repetitions)]
4
5use iced::widget::toggler::{Catalog, Status, Style};
6use iced::{Background, Color};
7
8use crate::StyleType;
9use crate::gui::styles::style_constants::BORDER_WIDTH;
10
11#[derive(Default)]
12pub enum TogglerType {
…lines 13–24 unchanged (12 lines)
25 ..colors.secondary
26 }
27 } else {
28 ext.buttons_color
29 };
30 Style {
31 background: Background::Color(bg_color),
32 background_border_width: BORDER_WIDTH,
33 background_border_color: bg_color,
34 foreground: Background::Color(colors.primary),
35 foreground_border_width: BORDER_WIDTH,
36 foreground_border_color: if is_active {
37 colors.secondary
38 } else {
39 Color::TRANSPARENT
40 },
41 text_color: None,
42 border_radius: None,
43 padding_ratio: 0.0,
44 }
45 }
46
47 #[allow(clippy::unused_self)]
48 fn hovered(&self, style: &StyleType, is_active: bool) -> Style {
49 let colors = style.get_palette();
…lines 50–53 unchanged (4 lines)
54 ..colors.secondary
55 }
56 } else {
57 ext.buttons_color
58 };
59 Style {
60 background: Background::Color(bg_color),
61 background_border_width: BORDER_WIDTH,
62 background_border_color: colors.secondary,
63 foreground: Background::Color(colors.primary),
64 foreground_border_width: BORDER_WIDTH,
65 foreground_border_color: if is_active {
66 colors.secondary
67 } else {
68 Color::TRANSPARENT
69 },
70 text_color: None,
71 border_radius: None,
72 padding_ratio: 0.0,
73 }
74 }
75}
76
77impl Catalog for StyleType {
78 type Class<'a> = TogglerType;
79
80 fn default<'a>() -> Self::Class<'a> {
81 Self::Class::default()
82 }
83
84 fn style(&self, class: &Self::Class<'_>, status: Status) -> Style {
85 match status {
86 Status::Active { is_toggled } => class.active(self, is_toggled),
87 Status::Hovered { is_toggled } => class.hovered(self, is_toggled),
88 Status::Disabled { is_toggled } => class.active(self, is_toggled),
89 }
90 }
91}
92

Before

source_file
line_comment
// "//"
inner_doc_comment_marker
! "!"
doc_comment " Toggler style\n"
inner_attribute_item
# "#"
! "!"
[ "["
attribute
identifier "allow"
token_tree
( "("
identifier "clippy"
:: "::"
identifier "module_name_repetitions"
) ")"
] "]"
use_declaration
use "use"
scoped_identifier
identifier "iced"
:: "::"
identifier "Color"
; ";"
use_declaration
use "use"
scoped_use_list
scoped_identifier
scoped_identifier
identifier "iced"
:: "::"
identifier "widget"
:: "::"
identifier "toggler"
:: "::"
use_list
{ "{"
identifier "Catalog"
, ","
identifier "Status"
, ","
identifier "Style"
} "}"
; ";"
use_declaration
use "use"
scoped_identifier
crate "crate"
:: "::"
identifier "StyleType"
; ";"
use_declaration
use "use"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
crate "crate"
:: "::"
identifier "gui"
:: "::"
identifier "styles"
:: "::"
identifier "style_constants"
:: "::"
identifier "BORDER_WIDTH"
; ";"
attribute_item
# "#"
[ "["
attribute
identifier "derive"
token_tree
( "("
identifier "Default"
) ")"
] "]"
enum_item
visibility_modifier
pub "pub"
enum "enum"
type_identifier "TogglerType"
enum_variant_list
{ "{"
attribute_item
# "#"
[ "["
attribute
identifier "default"
] "]"
enum_variant
identifier "Standard"
, ","
} "}"
impl_item
impl "impl"
type_identifier "TogglerType"
declaration_list
{ "{"
attribute_item
# "#"
[ "["
attribute
identifier "allow"
token_tree
( "("
identifier "clippy"
:: "::"
identifier "unused_self"
) ")"
] "]"
function_item
fn "fn"
identifier "active"
parameters
( "("
self_parameter
& "&"
self "self"
, ","
parameter
identifier "style"
: ":"
reference_type
& "&"
type_identifier "StyleType"
, ","
parameter
identifier "is_active"
: ":"
primitive_type "bool"
) ")"
-> "->"
type_identifier "Style"
block
{ "{"
let_declaration
let "let"
identifier "colors"
= "="
call_expression
field_expression
identifier "style"
. "."
field_identifier "get_palette"
arguments
( "("
) ")"
; ";"
let_declaration
let "let"
identifier "ext"
= "="
call_expression
field_expression
identifier "style"
. "."
field_identifier "get_extension"
arguments
( "("
) ")"
; ";"
let_declaration (+39 nodes collapsed)
struct_expression
type_identifier "Style"
field_initializer_list
{ "{"
field_initializer
field_identifier "background"
: ":"
identifier "bg_color"
, ","
field_initializer
field_identifier "background_border_width"
: ":"
identifier "BORDER_WIDTH"
, ","
field_initializer
field_identifier "background_border_color"
: ":"
identifier "bg_color"
, ","
field_initializer
field_identifier "foreground"
: ":"
field_expression
identifier "colors"
. "."
field_identifier "primary"
, ","
field_initializer
field_identifier "foreground_border_width"
: ":"
identifier "BORDER_WIDTH"
, ","
field_initializer (+22 nodes collapsed)
, ","
} "}"
} "}"
attribute_item
# "#"
[ "["
attribute
identifier "allow"
token_tree
( "("
identifier "clippy"
:: "::"
identifier "unused_self"
) ")"
] "]"
function_item
fn "fn"
identifier "hovered"
parameters
( "("
self_parameter
& "&"
self "self"
, ","
parameter
identifier "style"
: ":"
reference_type
& "&"
type_identifier "StyleType"
, ","
parameter
identifier "is_active"
: ":"
primitive_type "bool"
) ")"
-> "->"
type_identifier "Style"
block
{ "{"
let_declaration
let "let"
identifier "colors"
= "="
call_expression
field_expression
identifier "style"
. "."
field_identifier "get_palette"
arguments
( "("
) ")"
; ";"
let_declaration
let "let"
identifier "ext"
= "="
call_expression
field_expression
identifier "style"
. "."
field_identifier "get_extension"
arguments
( "("
) ")"
; ";"
let_declaration (+39 nodes collapsed)
struct_expression
type_identifier "Style"
field_initializer_list
{ "{"
field_initializer
field_identifier "background"
: ":"
identifier "bg_color"
, ","
field_initializer
field_identifier "background_border_width"
: ":"
identifier "BORDER_WIDTH"
, ","
field_initializer
field_identifier "background_border_color"
: ":"
field_expression
identifier "colors"
. "."
field_identifier "secondary"
, ","
field_initializer
field_identifier "foreground"
: ":"
field_expression
identifier "colors"
. "."
field_identifier "primary"
, ","
field_initializer
field_identifier "foreground_border_width"
: ":"
identifier "BORDER_WIDTH"
, ","
field_initializer (+22 nodes collapsed)
, ","
} "}"
} "}"
} "}"
impl_item
impl "impl"
type_identifier "Catalog"
for "for"
type_identifier "StyleType"
declaration_list
{ "{"
type_item
type "type"
type_identifier "Class"
type_parameters
< "<"
lifetime_parameter
lifetime
' "'"
identifier "a"
> ">"
= "="
type_identifier "TogglerType"
; ";"
function_item (+39 nodes collapsed)
function_item
fn "fn"
identifier "style"
parameters (+28 nodes collapsed)
-> "->"
type_identifier "Style"
block
{ "{"
expression_statement
match_expression
match "match"
identifier "status"
match_block
{ "{"
match_arm (+24 nodes collapsed)
match_arm (+24 nodes collapsed)
match_arm
match_pattern
scoped_identifier
identifier "Status"
:: "::"
identifier "Disabled"
=> "=>"
call_expression
field_expression
identifier "class"
. "."
field_identifier "active"
arguments
( "("
self "self"
, ","
boolean_literal
false "false"
) ")"
, ","
} "}"
} "}"
} "}"

After

source_file
line_comment
// "//"
inner_doc_comment_marker
! "!"
doc_comment " Toggler style\n"
inner_attribute_item
# "#"
! "!"
[ "["
attribute
identifier "allow"
token_tree
( "("
identifier "clippy"
:: "::"
identifier "module_name_repetitions"
) ")"
] "]"
use_declaration
use "use"
scoped_use_list
scoped_identifier
scoped_identifier
identifier "iced"
:: "::"
identifier "widget"
:: "::"
identifier "toggler"
:: "::"
use_list
{ "{"
identifier "Catalog"
, ","
identifier "Status"
, ","
identifier "Style"
} "}"
; ";"
use_declaration
use "use"
scoped_use_list
identifier "iced"
:: "::"
use_list
{ "{"
identifier "Background"
, ","
identifier "Color"
} "}"
; ";"
use_declaration
use "use"
scoped_identifier
crate "crate"
:: "::"
identifier "StyleType"
; ";"
use_declaration
use "use"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
crate "crate"
:: "::"
identifier "gui"
:: "::"
identifier "styles"
:: "::"
identifier "style_constants"
:: "::"
identifier "BORDER_WIDTH"
; ";"
attribute_item
# "#"
[ "["
attribute
identifier "derive"
token_tree
( "("
identifier "Default"
) ")"
] "]"
enum_item
visibility_modifier
pub "pub"
enum "enum"
type_identifier "TogglerType"
enum_variant_list
{ "{"
attribute_item
# "#"
[ "["
attribute
identifier "default"
] "]"
enum_variant
identifier "Standard"
, ","
} "}"
impl_item
impl "impl"
type_identifier "TogglerType"
declaration_list
{ "{"
attribute_item
# "#"
[ "["
attribute
identifier "allow"
token_tree
( "("
identifier "clippy"
:: "::"
identifier "unused_self"
) ")"
] "]"
function_item
fn "fn"
identifier "active"
parameters
( "("
self_parameter
& "&"
self "self"
, ","
parameter
identifier "style"
: ":"
reference_type
& "&"
type_identifier "StyleType"
, ","
parameter
identifier "is_active"
: ":"
primitive_type "bool"
) ")"
-> "->"
type_identifier "Style"
block
{ "{"
let_declaration
let "let"
identifier "colors"
= "="
call_expression
field_expression
identifier "style"
. "."
field_identifier "get_palette"
arguments
( "("
) ")"
; ";"
let_declaration
let "let"
identifier "ext"
= "="
call_expression
field_expression
identifier "style"
. "."
field_identifier "get_extension"
arguments
( "("
) ")"
; ";"
let_declaration (+39 nodes collapsed)
struct_expression
type_identifier "Style"
field_initializer_list
{ "{"
field_initializer
field_identifier "background"
: ":"
call_expression
scoped_identifier
identifier "Background"
:: "::"
identifier "Color"
arguments
( "("
identifier "bg_color"
) ")"
, ","
field_initializer
field_identifier "background_border_width"
: ":"
identifier "BORDER_WIDTH"
, ","
field_initializer
field_identifier "background_border_color"
: ":"
identifier "bg_color"
, ","
field_initializer
field_identifier "foreground"
: ":"
call_expression
scoped_identifier
identifier "Background"
:: "::"
identifier "Color"
arguments
( "("
field_expression
identifier "colors"
. "."
field_identifier "primary"
) ")"
, ","
field_initializer
field_identifier "foreground_border_width"
: ":"
identifier "BORDER_WIDTH"
, ","
field_initializer (+22 nodes collapsed)
, ","
field_initializer
field_identifier "text_color"
: ":"
identifier "None"
, ","
field_initializer
field_identifier "border_radius"
: ":"
identifier "None"
, ","
field_initializer
field_identifier "padding_ratio"
: ":"
float_literal "0.0"
, ","
} "}"
} "}"
attribute_item
# "#"
[ "["
attribute
identifier "allow"
token_tree
( "("
identifier "clippy"
:: "::"
identifier "unused_self"
) ")"
] "]"
function_item
fn "fn"
identifier "hovered"
parameters
( "("
self_parameter
& "&"
self "self"
, ","
parameter
identifier "style"
: ":"
reference_type
& "&"
type_identifier "StyleType"
, ","
parameter
identifier "is_active"
: ":"
primitive_type "bool"
) ")"
-> "->"
type_identifier "Style"
block
{ "{"
let_declaration
let "let"
identifier "colors"
= "="
call_expression
field_expression
identifier "style"
. "."
field_identifier "get_palette"
arguments
( "("
) ")"
; ";"
let_declaration
let "let"
identifier "ext"
= "="
call_expression
field_expression
identifier "style"
. "."
field_identifier "get_extension"
arguments
( "("
) ")"
; ";"
let_declaration (+39 nodes collapsed)
struct_expression
type_identifier "Style"
field_initializer_list
{ "{"
field_initializer
field_identifier "background"
: ":"
call_expression
scoped_identifier
identifier "Background"
:: "::"
identifier "Color"
arguments
( "("
identifier "bg_color"
) ")"
, ","
field_initializer
field_identifier "background_border_width"
: ":"
identifier "BORDER_WIDTH"
, ","
field_initializer
field_identifier "background_border_color"
: ":"
field_expression
identifier "colors"
. "."
field_identifier "secondary"
, ","
field_initializer
field_identifier "foreground"
: ":"
call_expression
scoped_identifier
identifier "Background"
:: "::"
identifier "Color"
arguments
( "("
field_expression
identifier "colors"
. "."
field_identifier "primary"
) ")"
, ","
field_initializer
field_identifier "foreground_border_width"
: ":"
identifier "BORDER_WIDTH"
, ","
field_initializer (+22 nodes collapsed)
, ","
field_initializer
field_identifier "text_color"
: ":"
identifier "None"
, ","
field_initializer
field_identifier "border_radius"
: ":"
identifier "None"
, ","
field_initializer
field_identifier "padding_ratio"
: ":"
float_literal "0.0"
, ","
} "}"
} "}"
} "}"
impl_item
impl "impl"
type_identifier "Catalog"
for "for"
type_identifier "StyleType"
declaration_list
{ "{"
type_item
type "type"
type_identifier "Class"
type_parameters
< "<"
lifetime_parameter
lifetime
' "'"
identifier "a"
> ">"
= "="
type_identifier "TogglerType"
; ";"
function_item (+39 nodes collapsed)
function_item
fn "fn"
identifier "style"
parameters (+28 nodes collapsed)
-> "->"
type_identifier "Style"
block
{ "{"
expression_statement
match_expression
match "match"
identifier "status"
match_block
{ "{"
match_arm (+24 nodes collapsed)
match_arm (+24 nodes collapsed)
match_arm
match_pattern
struct_pattern
scoped_type_identifier
identifier "Status"
:: "::"
type_identifier "Disabled"
{ "{"
field_pattern
shorthand_field_identifier "is_toggled"
} "}"
=> "=>"
call_expression
field_expression
identifier "class"
. "."
field_identifier "active"
arguments
( "("
self "self"
, ","
identifier "is_toggled"
) ")"
, ","
} "}"
} "}"
} "}"