@@ -71,6 +71,13 @@ impl FStringPrefix {
71
71
}
72
72
}
73
73
74
+ pub const fn text_len ( self ) -> TextSize {
75
+ match self {
76
+ Self :: Regular => TextSize :: new ( 1 ) ,
77
+ Self :: Raw { .. } => TextSize :: new ( 2 ) ,
78
+ }
79
+ }
80
+
74
81
/// Return true if this prefix indicates a "raw f-string",
75
82
/// e.g. `rf"{bar}"` or `Rf"{bar}"`
76
83
pub const fn is_raw ( self ) -> bool {
@@ -105,6 +112,13 @@ impl ByteStringPrefix {
105
112
}
106
113
}
107
114
115
+ pub const fn text_len ( self ) -> TextSize {
116
+ match self {
117
+ Self :: Regular => TextSize :: new ( 1 ) ,
118
+ Self :: Raw { .. } => TextSize :: new ( 2 ) ,
119
+ }
120
+ }
121
+
108
122
/// Return true if this prefix indicates a "raw bytestring",
109
123
/// e.g. `rb"foo"` or `Rb"foo"`
110
124
pub const fn is_raw ( self ) -> bool {
@@ -150,6 +164,14 @@ impl AnyStringPrefix {
150
164
}
151
165
}
152
166
167
+ pub const fn text_len ( self ) -> TextSize {
168
+ match self {
169
+ Self :: Regular ( regular_prefix) => regular_prefix. text_len ( ) ,
170
+ Self :: Bytes ( bytestring_prefix) => bytestring_prefix. text_len ( ) ,
171
+ Self :: Format ( fstring_prefix) => fstring_prefix. text_len ( ) ,
172
+ }
173
+ }
174
+
153
175
pub const fn is_raw ( self ) -> bool {
154
176
match self {
155
177
Self :: Regular ( regular_prefix) => regular_prefix. is_raw ( ) ,
0 commit comments