Struct rustpython_ast::text_size::TextRange
source · pub struct TextRange { /* private fields */ }
Expand description
A range in text, represented as a pair of TextSize
.
It is a logic error for start
to be greater than end
.
Implementations§
source§impl TextRange
impl TextRange
sourcepub const fn new(start: TextSize, end: TextSize) -> TextRange
pub const fn new(start: TextSize, end: TextSize) -> TextRange
Creates a new TextRange
with the given start
and end
(start..end
).
§Panics
Panics if end < start
.
§Examples
let start = TextSize::from(5);
let end = TextSize::from(10);
let range = TextRange::new(start, end);
assert_eq!(range.start(), start);
assert_eq!(range.end(), end);
assert_eq!(range.len(), end - start);
sourcepub fn at(offset: TextSize, len: TextSize) -> TextRange
pub fn at(offset: TextSize, len: TextSize) -> TextRange
Create a new TextRange
with the given offset
and len
(offset..offset + len
).
§Examples
let text = "0123456789";
let offset = TextSize::from(2);
let length = TextSize::from(5);
let range = TextRange::at(offset, length);
assert_eq!(range, TextRange::new(offset, offset + length));
assert_eq!(&text[range], "23456")
source§impl TextRange
impl TextRange
Manipulation methods.
sourcepub fn contains(self, offset: TextSize) -> bool
pub fn contains(self, offset: TextSize) -> bool
Check if this range contains an offset.
The end index is considered excluded.
§Examples
let (start, end): (TextSize, TextSize);
let range = TextRange::new(start, end);
assert!(range.contains(start));
assert!(!range.contains(end));
sourcepub fn contains_inclusive(self, offset: TextSize) -> bool
pub fn contains_inclusive(self, offset: TextSize) -> bool
Check if this range contains an offset.
The end index is considered included.
§Examples
let (start, end): (TextSize, TextSize);
let range = TextRange::new(start, end);
assert!(range.contains_inclusive(start));
assert!(range.contains_inclusive(end));
sourcepub fn contains_range(self, other: TextRange) -> bool
pub fn contains_range(self, other: TextRange) -> bool
Check if this range completely contains another range.
§Examples
let larger = TextRange::new(0.into(), 20.into());
let smaller = TextRange::new(5.into(), 15.into());
assert!(larger.contains_range(smaller));
assert!(!smaller.contains_range(larger));
// a range always contains itself
assert!(larger.contains_range(larger));
assert!(smaller.contains_range(smaller));
sourcepub fn intersect(self, other: TextRange) -> Option<TextRange>
pub fn intersect(self, other: TextRange) -> Option<TextRange>
The range covered by both ranges, if it exists. If the ranges touch but do not overlap, the output range is empty.
§Examples
assert_eq!(
TextRange::intersect(
TextRange::new(0.into(), 10.into()),
TextRange::new(5.into(), 15.into()),
),
Some(TextRange::new(5.into(), 10.into())),
);
sourcepub fn cover(self, other: TextRange) -> TextRange
pub fn cover(self, other: TextRange) -> TextRange
Extends the range to cover other
as well.
§Examples
assert_eq!(
TextRange::cover(
TextRange::new(0.into(), 5.into()),
TextRange::new(15.into(), 20.into()),
),
TextRange::new(0.into(), 20.into()),
);
sourcepub fn cover_offset(self, offset: TextSize) -> TextRange
pub fn cover_offset(self, offset: TextSize) -> TextRange
Extends the range to cover other
offsets as well.
§Examples
assert_eq!(
TextRange::empty(0.into()).cover_offset(20.into()),
TextRange::new(0.into(), 20.into()),
)
sourcepub fn checked_add(self, offset: TextSize) -> Option<TextRange>
pub fn checked_add(self, offset: TextSize) -> Option<TextRange>
Add an offset to this range.
Note that this is not appropriate for changing where a TextRange
is
within some string; rather, it is for changing the reference anchor
that the TextRange
is measured against.
The unchecked version (Add::add
) will always panic on overflow,
in contrast to primitive integers, which check in debug mode only.
sourcepub fn checked_sub(self, offset: TextSize) -> Option<TextRange>
pub fn checked_sub(self, offset: TextSize) -> Option<TextRange>
Subtract an offset from this range.
Note that this is not appropriate for changing where a TextRange
is
within some string; rather, it is for changing the reference anchor
that the TextRange
is measured against.
The unchecked version (Sub::sub
) will always panic on overflow,
in contrast to primitive integers, which check in debug mode only.
sourcepub fn ordering(self, other: TextRange) -> Ordering
pub fn ordering(self, other: TextRange) -> Ordering
Relative order of the two ranges (overlapping ranges are considered equal).
This is useful when, for example, binary searching an array of disjoint ranges.
§Examples
let a = TextRange::new(0.into(), 3.into());
let b = TextRange::new(4.into(), 5.into());
assert_eq!(a.ordering(b), Ordering::Less);
let a = TextRange::new(0.into(), 3.into());
let b = TextRange::new(3.into(), 5.into());
assert_eq!(a.ordering(b), Ordering::Less);
let a = TextRange::new(0.into(), 3.into());
let b = TextRange::new(2.into(), 5.into());
assert_eq!(a.ordering(b), Ordering::Equal);
let a = TextRange::new(0.into(), 3.into());
let b = TextRange::new(2.into(), 2.into());
assert_eq!(a.ordering(b), Ordering::Equal);
let a = TextRange::new(2.into(), 3.into());
let b = TextRange::new(2.into(), 2.into());
assert_eq!(a.ordering(b), Ordering::Greater);
sourcepub fn sub_start(&self, amount: TextSize) -> TextRange
pub fn sub_start(&self, amount: TextSize) -> TextRange
Subtracts an offset from the start position.
§Panics
If start - amount
is less than zero.
§Examples
use rustpython_parser_vendored::text_size::{TextRange, TextSize};
let range = TextRange::new(TextSize::from(5), TextSize::from(10));
assert_eq!(range.sub_start(TextSize::from(2)), TextRange::new(TextSize::from(3), TextSize::from(10)));
sourcepub fn add_start(&self, amount: TextSize) -> TextRange
pub fn add_start(&self, amount: TextSize) -> TextRange
Adds an offset to the start position.
§Panics
If start + amount > end
§Examples
use rustpython_parser_vendored::text_size::{TextRange, TextSize};
let range = TextRange::new(TextSize::from(5), TextSize::from(10));
assert_eq!(range.add_start(TextSize::from(3)), TextRange::new(TextSize::from(8), TextSize::from(10)));
sourcepub fn sub_end(&self, amount: TextSize) -> TextRange
pub fn sub_end(&self, amount: TextSize) -> TextRange
Subtracts an offset from the end position.
§Panics
If end - amount < 0
or end - amount < start
§Examples
use rustpython_parser_vendored::text_size::{TextRange, TextSize};
let range = TextRange::new(TextSize::from(5), TextSize::from(10));
assert_eq!(range.sub_end(TextSize::from(2)), TextRange::new(TextSize::from(5), TextSize::from(8)));
sourcepub fn add_end(&self, amount: TextSize) -> TextRange
pub fn add_end(&self, amount: TextSize) -> TextRange
Adds an offset to the end position.
§Panics
If end + amount > u32::MAX
§Examples
use rustpython_parser_vendored::text_size::{TextRange, TextSize};
let range = TextRange::new(TextSize::from(5), TextSize::from(10));
assert_eq!(range.add_end(TextSize::from(2)), TextRange::new(TextSize::from(5), TextSize::from(12)));
Trait Implementations§
source§impl<A> AddAssign<A> for TextRange
impl<A> AddAssign<A> for TextRange
source§fn add_assign(&mut self, rhs: A)
fn add_assign(&mut self, rhs: A)
+=
operation. Read moresource§impl Fold<TextRange> for LinearLocator<'_>
impl Fold<TextRange> for LinearLocator<'_>
type TargetU = SourceRange
type Error = Infallible
type UserContext = SourceLocation
fn will_map_user(&mut self, user: &TextRange) -> Self::UserContext
fn map_user( &mut self, user: TextRange, start: Self::UserContext, ) -> Result<Self::TargetU, Self::Error>
fn fold_expr_dict( &mut self, node: ExprDict<TextRange>, ) -> Result<ExprDict<Self::TargetU>, Self::Error>
fn fold_expr_if_exp( &mut self, node: ExprIfExp<TextRange>, ) -> Result<ExprIfExp<Self::TargetU>, Self::Error>
fn fold_stmt_class_def( &mut self, node: StmtClassDef<TextRange>, ) -> Result<StmtClassDef<Self::TargetU>, Self::Error>
fn fold_stmt_function_def( &mut self, node: StmtFunctionDef<TextRange>, ) -> Result<StmtFunctionDef<Self::TargetU>, Self::Error>
fn fold_stmt_async_function_def( &mut self, node: StmtAsyncFunctionDef<TextRange>, ) -> Result<StmtAsyncFunctionDef<Self::TargetU>, Self::Error>
fn fold_expr_joined_str( &mut self, node: ExprJoinedStr<TextRange>, ) -> Result<ExprJoinedStr<Self::TargetU>, Self::Error>
fn fold_expr_call( &mut self, node: ExprCall<TextRange>, ) -> Result<ExprCall<Self::TargetU>, Self::Error>
fn will_map_user_cfg( &mut self, _user: &EmptyRange<U>, ) -> EmptyRange<Self::TargetU>
fn map_user_cfg( &mut self, _user: EmptyRange<U>, _context: EmptyRange<Self::TargetU>, ) -> Result<EmptyRange<Self::TargetU>, Self::Error>
fn fold<X: Foldable<U, Self::TargetU>>( &mut self, node: X, ) -> Result<X::Mapped, Self::Error>
fn fold_mod(&mut self, node: Mod<U>) -> Result<Mod<Self::TargetU>, Self::Error>
fn fold_mod_module( &mut self, node: ModModule<U>, ) -> Result<ModModule<Self::TargetU>, Self::Error>
fn fold_mod_interactive( &mut self, node: ModInteractive<U>, ) -> Result<ModInteractive<Self::TargetU>, Self::Error>
fn fold_mod_expression( &mut self, node: ModExpression<U>, ) -> Result<ModExpression<Self::TargetU>, Self::Error>
fn fold_mod_function_type( &mut self, node: ModFunctionType<U>, ) -> Result<ModFunctionType<Self::TargetU>, Self::Error>
fn fold_stmt( &mut self, node: Stmt<U>, ) -> Result<Stmt<Self::TargetU>, Self::Error>
fn fold_stmt_return( &mut self, node: StmtReturn<U>, ) -> Result<StmtReturn<Self::TargetU>, Self::Error>
fn fold_stmt_delete( &mut self, node: StmtDelete<U>, ) -> Result<StmtDelete<Self::TargetU>, Self::Error>
fn fold_stmt_assign( &mut self, node: StmtAssign<U>, ) -> Result<StmtAssign<Self::TargetU>, Self::Error>
fn fold_stmt_type_alias( &mut self, node: StmtTypeAlias<U>, ) -> Result<StmtTypeAlias<Self::TargetU>, Self::Error>
fn fold_stmt_aug_assign( &mut self, node: StmtAugAssign<U>, ) -> Result<StmtAugAssign<Self::TargetU>, Self::Error>
fn fold_stmt_ann_assign( &mut self, node: StmtAnnAssign<U>, ) -> Result<StmtAnnAssign<Self::TargetU>, Self::Error>
fn fold_stmt_for( &mut self, node: StmtFor<U>, ) -> Result<StmtFor<Self::TargetU>, Self::Error>
fn fold_stmt_async_for( &mut self, node: StmtAsyncFor<U>, ) -> Result<StmtAsyncFor<Self::TargetU>, Self::Error>
fn fold_stmt_while( &mut self, node: StmtWhile<U>, ) -> Result<StmtWhile<Self::TargetU>, Self::Error>
fn fold_stmt_if( &mut self, node: StmtIf<U>, ) -> Result<StmtIf<Self::TargetU>, Self::Error>
fn fold_stmt_with( &mut self, node: StmtWith<U>, ) -> Result<StmtWith<Self::TargetU>, Self::Error>
fn fold_stmt_async_with( &mut self, node: StmtAsyncWith<U>, ) -> Result<StmtAsyncWith<Self::TargetU>, Self::Error>
fn fold_stmt_match( &mut self, node: StmtMatch<U>, ) -> Result<StmtMatch<Self::TargetU>, Self::Error>
fn fold_stmt_raise( &mut self, node: StmtRaise<U>, ) -> Result<StmtRaise<Self::TargetU>, Self::Error>
fn fold_stmt_try( &mut self, node: StmtTry<U>, ) -> Result<StmtTry<Self::TargetU>, Self::Error>
fn fold_stmt_try_star( &mut self, node: StmtTryStar<U>, ) -> Result<StmtTryStar<Self::TargetU>, Self::Error>
fn fold_stmt_assert( &mut self, node: StmtAssert<U>, ) -> Result<StmtAssert<Self::TargetU>, Self::Error>
fn fold_stmt_import( &mut self, node: StmtImport<U>, ) -> Result<StmtImport<Self::TargetU>, Self::Error>
fn fold_stmt_import_from( &mut self, node: StmtImportFrom<U>, ) -> Result<StmtImportFrom<Self::TargetU>, Self::Error>
fn fold_stmt_global( &mut self, node: StmtGlobal<U>, ) -> Result<StmtGlobal<Self::TargetU>, Self::Error>
fn fold_stmt_nonlocal( &mut self, node: StmtNonlocal<U>, ) -> Result<StmtNonlocal<Self::TargetU>, Self::Error>
fn fold_stmt_expr( &mut self, node: StmtExpr<U>, ) -> Result<StmtExpr<Self::TargetU>, Self::Error>
fn fold_stmt_pass( &mut self, node: StmtPass<U>, ) -> Result<StmtPass<Self::TargetU>, Self::Error>
fn fold_stmt_break( &mut self, node: StmtBreak<U>, ) -> Result<StmtBreak<Self::TargetU>, Self::Error>
fn fold_stmt_continue( &mut self, node: StmtContinue<U>, ) -> Result<StmtContinue<Self::TargetU>, Self::Error>
fn fold_expr( &mut self, node: Expr<U>, ) -> Result<Expr<Self::TargetU>, Self::Error>
fn fold_expr_bool_op( &mut self, node: ExprBoolOp<U>, ) -> Result<ExprBoolOp<Self::TargetU>, Self::Error>
fn fold_expr_named_expr( &mut self, node: ExprNamedExpr<U>, ) -> Result<ExprNamedExpr<Self::TargetU>, Self::Error>
fn fold_expr_bin_op( &mut self, node: ExprBinOp<U>, ) -> Result<ExprBinOp<Self::TargetU>, Self::Error>
fn fold_expr_unary_op( &mut self, node: ExprUnaryOp<U>, ) -> Result<ExprUnaryOp<Self::TargetU>, Self::Error>
fn fold_expr_lambda( &mut self, node: ExprLambda<U>, ) -> Result<ExprLambda<Self::TargetU>, Self::Error>
fn fold_expr_set( &mut self, node: ExprSet<U>, ) -> Result<ExprSet<Self::TargetU>, Self::Error>
fn fold_expr_list_comp( &mut self, node: ExprListComp<U>, ) -> Result<ExprListComp<Self::TargetU>, Self::Error>
fn fold_expr_set_comp( &mut self, node: ExprSetComp<U>, ) -> Result<ExprSetComp<Self::TargetU>, Self::Error>
fn fold_expr_dict_comp( &mut self, node: ExprDictComp<U>, ) -> Result<ExprDictComp<Self::TargetU>, Self::Error>
fn fold_expr_generator_exp( &mut self, node: ExprGeneratorExp<U>, ) -> Result<ExprGeneratorExp<Self::TargetU>, Self::Error>
fn fold_expr_await( &mut self, node: ExprAwait<U>, ) -> Result<ExprAwait<Self::TargetU>, Self::Error>
fn fold_expr_yield( &mut self, node: ExprYield<U>, ) -> Result<ExprYield<Self::TargetU>, Self::Error>
fn fold_expr_yield_from( &mut self, node: ExprYieldFrom<U>, ) -> Result<ExprYieldFrom<Self::TargetU>, Self::Error>
fn fold_expr_compare( &mut self, node: ExprCompare<U>, ) -> Result<ExprCompare<Self::TargetU>, Self::Error>
fn fold_expr_formatted_value( &mut self, node: ExprFormattedValue<U>, ) -> Result<ExprFormattedValue<Self::TargetU>, Self::Error>
fn fold_expr_constant( &mut self, node: ExprConstant<U>, ) -> Result<ExprConstant<Self::TargetU>, Self::Error>
fn fold_expr_attribute( &mut self, node: ExprAttribute<U>, ) -> Result<ExprAttribute<Self::TargetU>, Self::Error>
fn fold_expr_subscript( &mut self, node: ExprSubscript<U>, ) -> Result<ExprSubscript<Self::TargetU>, Self::Error>
fn fold_expr_starred( &mut self, node: ExprStarred<U>, ) -> Result<ExprStarred<Self::TargetU>, Self::Error>
fn fold_expr_name( &mut self, node: ExprName<U>, ) -> Result<ExprName<Self::TargetU>, Self::Error>
fn fold_expr_list( &mut self, node: ExprList<U>, ) -> Result<ExprList<Self::TargetU>, Self::Error>
fn fold_expr_tuple( &mut self, node: ExprTuple<U>, ) -> Result<ExprTuple<Self::TargetU>, Self::Error>
fn fold_expr_slice( &mut self, node: ExprSlice<U>, ) -> Result<ExprSlice<Self::TargetU>, Self::Error>
fn fold_expr_context( &mut self, node: ExprContext, ) -> Result<ExprContext, Self::Error>
fn fold_boolop(&mut self, node: BoolOp) -> Result<BoolOp, Self::Error>
fn fold_operator(&mut self, node: Operator) -> Result<Operator, Self::Error>
fn fold_unaryop(&mut self, node: UnaryOp) -> Result<UnaryOp, Self::Error>
fn fold_cmpop(&mut self, node: CmpOp) -> Result<CmpOp, Self::Error>
fn fold_comprehension( &mut self, node: Comprehension<U>, ) -> Result<Comprehension<Self::TargetU>, Self::Error>
fn fold_excepthandler( &mut self, node: ExceptHandler<U>, ) -> Result<ExceptHandler<Self::TargetU>, Self::Error>
fn fold_excepthandler_except_handler( &mut self, node: ExceptHandlerExceptHandler<U>, ) -> Result<ExceptHandlerExceptHandler<Self::TargetU>, Self::Error>
fn fold_arguments( &mut self, node: Arguments<U>, ) -> Result<Arguments<Self::TargetU>, Self::Error>
fn fold_arg(&mut self, node: Arg<U>) -> Result<Arg<Self::TargetU>, Self::Error>
fn fold_keyword( &mut self, node: Keyword<U>, ) -> Result<Keyword<Self::TargetU>, Self::Error>
fn fold_alias( &mut self, node: Alias<U>, ) -> Result<Alias<Self::TargetU>, Self::Error>
fn fold_withitem( &mut self, node: WithItem<U>, ) -> Result<WithItem<Self::TargetU>, Self::Error>
fn fold_match_case( &mut self, node: MatchCase<U>, ) -> Result<MatchCase<Self::TargetU>, Self::Error>
fn fold_pattern( &mut self, node: Pattern<U>, ) -> Result<Pattern<Self::TargetU>, Self::Error>
fn fold_pattern_match_value( &mut self, node: PatternMatchValue<U>, ) -> Result<PatternMatchValue<Self::TargetU>, Self::Error>
fn fold_pattern_match_singleton( &mut self, node: PatternMatchSingleton<U>, ) -> Result<PatternMatchSingleton<Self::TargetU>, Self::Error>
fn fold_pattern_match_sequence( &mut self, node: PatternMatchSequence<U>, ) -> Result<PatternMatchSequence<Self::TargetU>, Self::Error>
fn fold_pattern_match_mapping( &mut self, node: PatternMatchMapping<U>, ) -> Result<PatternMatchMapping<Self::TargetU>, Self::Error>
fn fold_pattern_match_class( &mut self, node: PatternMatchClass<U>, ) -> Result<PatternMatchClass<Self::TargetU>, Self::Error>
fn fold_pattern_match_star( &mut self, node: PatternMatchStar<U>, ) -> Result<PatternMatchStar<Self::TargetU>, Self::Error>
fn fold_pattern_match_as( &mut self, node: PatternMatchAs<U>, ) -> Result<PatternMatchAs<Self::TargetU>, Self::Error>
fn fold_pattern_match_or( &mut self, node: PatternMatchOr<U>, ) -> Result<PatternMatchOr<Self::TargetU>, Self::Error>
fn fold_type_ignore( &mut self, node: TypeIgnore<U>, ) -> Result<TypeIgnore<Self::TargetU>, Self::Error>
fn fold_type_ignore_type_ignore( &mut self, node: TypeIgnoreTypeIgnore<U>, ) -> Result<TypeIgnoreTypeIgnore<Self::TargetU>, Self::Error>
fn fold_type_param( &mut self, node: TypeParam<U>, ) -> Result<TypeParam<Self::TargetU>, Self::Error>
fn fold_type_param_type_var( &mut self, node: TypeParamTypeVar<U>, ) -> Result<TypeParamTypeVar<Self::TargetU>, Self::Error>
fn fold_type_param_param_spec( &mut self, node: TypeParamParamSpec<U>, ) -> Result<TypeParamParamSpec<Self::TargetU>, Self::Error>
fn fold_type_param_type_var_tuple( &mut self, node: TypeParamTypeVarTuple<U>, ) -> Result<TypeParamTypeVarTuple<Self::TargetU>, Self::Error>
fn fold_arg_with_default( &mut self, node: ArgWithDefault<U>, ) -> Result<ArgWithDefault<Self::TargetU>, Self::Error>
source§impl Fold<TextRange> for RandomLocator<'_>
impl Fold<TextRange> for RandomLocator<'_>
type TargetU = SourceRange
type Error = Infallible
type UserContext = SourceLocation
fn will_map_user(&mut self, user: &TextRange) -> Self::UserContext
fn map_user( &mut self, user: TextRange, start: Self::UserContext, ) -> Result<Self::TargetU, Self::Error>
fn will_map_user_cfg( &mut self, _user: &EmptyRange<U>, ) -> EmptyRange<Self::TargetU>
fn map_user_cfg( &mut self, _user: EmptyRange<U>, _context: EmptyRange<Self::TargetU>, ) -> Result<EmptyRange<Self::TargetU>, Self::Error>
fn fold<X: Foldable<U, Self::TargetU>>( &mut self, node: X, ) -> Result<X::Mapped, Self::Error>
fn fold_mod(&mut self, node: Mod<U>) -> Result<Mod<Self::TargetU>, Self::Error>
fn fold_mod_module( &mut self, node: ModModule<U>, ) -> Result<ModModule<Self::TargetU>, Self::Error>
fn fold_mod_interactive( &mut self, node: ModInteractive<U>, ) -> Result<ModInteractive<Self::TargetU>, Self::Error>
fn fold_mod_expression( &mut self, node: ModExpression<U>, ) -> Result<ModExpression<Self::TargetU>, Self::Error>
fn fold_mod_function_type( &mut self, node: ModFunctionType<U>, ) -> Result<ModFunctionType<Self::TargetU>, Self::Error>
fn fold_stmt( &mut self, node: Stmt<U>, ) -> Result<Stmt<Self::TargetU>, Self::Error>
fn fold_stmt_function_def( &mut self, node: StmtFunctionDef<U>, ) -> Result<StmtFunctionDef<Self::TargetU>, Self::Error>
fn fold_stmt_async_function_def( &mut self, node: StmtAsyncFunctionDef<U>, ) -> Result<StmtAsyncFunctionDef<Self::TargetU>, Self::Error>
fn fold_stmt_class_def( &mut self, node: StmtClassDef<U>, ) -> Result<StmtClassDef<Self::TargetU>, Self::Error>
fn fold_stmt_return( &mut self, node: StmtReturn<U>, ) -> Result<StmtReturn<Self::TargetU>, Self::Error>
fn fold_stmt_delete( &mut self, node: StmtDelete<U>, ) -> Result<StmtDelete<Self::TargetU>, Self::Error>
fn fold_stmt_assign( &mut self, node: StmtAssign<U>, ) -> Result<StmtAssign<Self::TargetU>, Self::Error>
fn fold_stmt_type_alias( &mut self, node: StmtTypeAlias<U>, ) -> Result<StmtTypeAlias<Self::TargetU>, Self::Error>
fn fold_stmt_aug_assign( &mut self, node: StmtAugAssign<U>, ) -> Result<StmtAugAssign<Self::TargetU>, Self::Error>
fn fold_stmt_ann_assign( &mut self, node: StmtAnnAssign<U>, ) -> Result<StmtAnnAssign<Self::TargetU>, Self::Error>
fn fold_stmt_for( &mut self, node: StmtFor<U>, ) -> Result<StmtFor<Self::TargetU>, Self::Error>
fn fold_stmt_async_for( &mut self, node: StmtAsyncFor<U>, ) -> Result<StmtAsyncFor<Self::TargetU>, Self::Error>
fn fold_stmt_while( &mut self, node: StmtWhile<U>, ) -> Result<StmtWhile<Self::TargetU>, Self::Error>
fn fold_stmt_if( &mut self, node: StmtIf<U>, ) -> Result<StmtIf<Self::TargetU>, Self::Error>
fn fold_stmt_with( &mut self, node: StmtWith<U>, ) -> Result<StmtWith<Self::TargetU>, Self::Error>
fn fold_stmt_async_with( &mut self, node: StmtAsyncWith<U>, ) -> Result<StmtAsyncWith<Self::TargetU>, Self::Error>
fn fold_stmt_match( &mut self, node: StmtMatch<U>, ) -> Result<StmtMatch<Self::TargetU>, Self::Error>
fn fold_stmt_raise( &mut self, node: StmtRaise<U>, ) -> Result<StmtRaise<Self::TargetU>, Self::Error>
fn fold_stmt_try( &mut self, node: StmtTry<U>, ) -> Result<StmtTry<Self::TargetU>, Self::Error>
fn fold_stmt_try_star( &mut self, node: StmtTryStar<U>, ) -> Result<StmtTryStar<Self::TargetU>, Self::Error>
fn fold_stmt_assert( &mut self, node: StmtAssert<U>, ) -> Result<StmtAssert<Self::TargetU>, Self::Error>
fn fold_stmt_import( &mut self, node: StmtImport<U>, ) -> Result<StmtImport<Self::TargetU>, Self::Error>
fn fold_stmt_import_from( &mut self, node: StmtImportFrom<U>, ) -> Result<StmtImportFrom<Self::TargetU>, Self::Error>
fn fold_stmt_global( &mut self, node: StmtGlobal<U>, ) -> Result<StmtGlobal<Self::TargetU>, Self::Error>
fn fold_stmt_nonlocal( &mut self, node: StmtNonlocal<U>, ) -> Result<StmtNonlocal<Self::TargetU>, Self::Error>
fn fold_stmt_expr( &mut self, node: StmtExpr<U>, ) -> Result<StmtExpr<Self::TargetU>, Self::Error>
fn fold_stmt_pass( &mut self, node: StmtPass<U>, ) -> Result<StmtPass<Self::TargetU>, Self::Error>
fn fold_stmt_break( &mut self, node: StmtBreak<U>, ) -> Result<StmtBreak<Self::TargetU>, Self::Error>
fn fold_stmt_continue( &mut self, node: StmtContinue<U>, ) -> Result<StmtContinue<Self::TargetU>, Self::Error>
fn fold_expr( &mut self, node: Expr<U>, ) -> Result<Expr<Self::TargetU>, Self::Error>
fn fold_expr_bool_op( &mut self, node: ExprBoolOp<U>, ) -> Result<ExprBoolOp<Self::TargetU>, Self::Error>
fn fold_expr_named_expr( &mut self, node: ExprNamedExpr<U>, ) -> Result<ExprNamedExpr<Self::TargetU>, Self::Error>
fn fold_expr_bin_op( &mut self, node: ExprBinOp<U>, ) -> Result<ExprBinOp<Self::TargetU>, Self::Error>
fn fold_expr_unary_op( &mut self, node: ExprUnaryOp<U>, ) -> Result<ExprUnaryOp<Self::TargetU>, Self::Error>
fn fold_expr_lambda( &mut self, node: ExprLambda<U>, ) -> Result<ExprLambda<Self::TargetU>, Self::Error>
fn fold_expr_if_exp( &mut self, node: ExprIfExp<U>, ) -> Result<ExprIfExp<Self::TargetU>, Self::Error>
fn fold_expr_dict( &mut self, node: ExprDict<U>, ) -> Result<ExprDict<Self::TargetU>, Self::Error>
fn fold_expr_set( &mut self, node: ExprSet<U>, ) -> Result<ExprSet<Self::TargetU>, Self::Error>
fn fold_expr_list_comp( &mut self, node: ExprListComp<U>, ) -> Result<ExprListComp<Self::TargetU>, Self::Error>
fn fold_expr_set_comp( &mut self, node: ExprSetComp<U>, ) -> Result<ExprSetComp<Self::TargetU>, Self::Error>
fn fold_expr_dict_comp( &mut self, node: ExprDictComp<U>, ) -> Result<ExprDictComp<Self::TargetU>, Self::Error>
fn fold_expr_generator_exp( &mut self, node: ExprGeneratorExp<U>, ) -> Result<ExprGeneratorExp<Self::TargetU>, Self::Error>
fn fold_expr_await( &mut self, node: ExprAwait<U>, ) -> Result<ExprAwait<Self::TargetU>, Self::Error>
fn fold_expr_yield( &mut self, node: ExprYield<U>, ) -> Result<ExprYield<Self::TargetU>, Self::Error>
fn fold_expr_yield_from( &mut self, node: ExprYieldFrom<U>, ) -> Result<ExprYieldFrom<Self::TargetU>, Self::Error>
fn fold_expr_compare( &mut self, node: ExprCompare<U>, ) -> Result<ExprCompare<Self::TargetU>, Self::Error>
fn fold_expr_call( &mut self, node: ExprCall<U>, ) -> Result<ExprCall<Self::TargetU>, Self::Error>
fn fold_expr_formatted_value( &mut self, node: ExprFormattedValue<U>, ) -> Result<ExprFormattedValue<Self::TargetU>, Self::Error>
fn fold_expr_joined_str( &mut self, node: ExprJoinedStr<U>, ) -> Result<ExprJoinedStr<Self::TargetU>, Self::Error>
fn fold_expr_constant( &mut self, node: ExprConstant<U>, ) -> Result<ExprConstant<Self::TargetU>, Self::Error>
fn fold_expr_attribute( &mut self, node: ExprAttribute<U>, ) -> Result<ExprAttribute<Self::TargetU>, Self::Error>
fn fold_expr_subscript( &mut self, node: ExprSubscript<U>, ) -> Result<ExprSubscript<Self::TargetU>, Self::Error>
fn fold_expr_starred( &mut self, node: ExprStarred<U>, ) -> Result<ExprStarred<Self::TargetU>, Self::Error>
fn fold_expr_name( &mut self, node: ExprName<U>, ) -> Result<ExprName<Self::TargetU>, Self::Error>
fn fold_expr_list( &mut self, node: ExprList<U>, ) -> Result<ExprList<Self::TargetU>, Self::Error>
fn fold_expr_tuple( &mut self, node: ExprTuple<U>, ) -> Result<ExprTuple<Self::TargetU>, Self::Error>
fn fold_expr_slice( &mut self, node: ExprSlice<U>, ) -> Result<ExprSlice<Self::TargetU>, Self::Error>
fn fold_expr_context( &mut self, node: ExprContext, ) -> Result<ExprContext, Self::Error>
fn fold_boolop(&mut self, node: BoolOp) -> Result<BoolOp, Self::Error>
fn fold_operator(&mut self, node: Operator) -> Result<Operator, Self::Error>
fn fold_unaryop(&mut self, node: UnaryOp) -> Result<UnaryOp, Self::Error>
fn fold_cmpop(&mut self, node: CmpOp) -> Result<CmpOp, Self::Error>
fn fold_comprehension( &mut self, node: Comprehension<U>, ) -> Result<Comprehension<Self::TargetU>, Self::Error>
fn fold_excepthandler( &mut self, node: ExceptHandler<U>, ) -> Result<ExceptHandler<Self::TargetU>, Self::Error>
fn fold_excepthandler_except_handler( &mut self, node: ExceptHandlerExceptHandler<U>, ) -> Result<ExceptHandlerExceptHandler<Self::TargetU>, Self::Error>
fn fold_arguments( &mut self, node: Arguments<U>, ) -> Result<Arguments<Self::TargetU>, Self::Error>
fn fold_arg(&mut self, node: Arg<U>) -> Result<Arg<Self::TargetU>, Self::Error>
fn fold_keyword( &mut self, node: Keyword<U>, ) -> Result<Keyword<Self::TargetU>, Self::Error>
fn fold_alias( &mut self, node: Alias<U>, ) -> Result<Alias<Self::TargetU>, Self::Error>
fn fold_withitem( &mut self, node: WithItem<U>, ) -> Result<WithItem<Self::TargetU>, Self::Error>
fn fold_match_case( &mut self, node: MatchCase<U>, ) -> Result<MatchCase<Self::TargetU>, Self::Error>
fn fold_pattern( &mut self, node: Pattern<U>, ) -> Result<Pattern<Self::TargetU>, Self::Error>
fn fold_pattern_match_value( &mut self, node: PatternMatchValue<U>, ) -> Result<PatternMatchValue<Self::TargetU>, Self::Error>
fn fold_pattern_match_singleton( &mut self, node: PatternMatchSingleton<U>, ) -> Result<PatternMatchSingleton<Self::TargetU>, Self::Error>
fn fold_pattern_match_sequence( &mut self, node: PatternMatchSequence<U>, ) -> Result<PatternMatchSequence<Self::TargetU>, Self::Error>
fn fold_pattern_match_mapping( &mut self, node: PatternMatchMapping<U>, ) -> Result<PatternMatchMapping<Self::TargetU>, Self::Error>
fn fold_pattern_match_class( &mut self, node: PatternMatchClass<U>, ) -> Result<PatternMatchClass<Self::TargetU>, Self::Error>
fn fold_pattern_match_star( &mut self, node: PatternMatchStar<U>, ) -> Result<PatternMatchStar<Self::TargetU>, Self::Error>
fn fold_pattern_match_as( &mut self, node: PatternMatchAs<U>, ) -> Result<PatternMatchAs<Self::TargetU>, Self::Error>
fn fold_pattern_match_or( &mut self, node: PatternMatchOr<U>, ) -> Result<PatternMatchOr<Self::TargetU>, Self::Error>
fn fold_type_ignore( &mut self, node: TypeIgnore<U>, ) -> Result<TypeIgnore<Self::TargetU>, Self::Error>
fn fold_type_ignore_type_ignore( &mut self, node: TypeIgnoreTypeIgnore<U>, ) -> Result<TypeIgnoreTypeIgnore<Self::TargetU>, Self::Error>
fn fold_type_param( &mut self, node: TypeParam<U>, ) -> Result<TypeParam<Self::TargetU>, Self::Error>
fn fold_type_param_type_var( &mut self, node: TypeParamTypeVar<U>, ) -> Result<TypeParamTypeVar<Self::TargetU>, Self::Error>
fn fold_type_param_param_spec( &mut self, node: TypeParamParamSpec<U>, ) -> Result<TypeParamParamSpec<Self::TargetU>, Self::Error>
fn fold_type_param_type_var_tuple( &mut self, node: TypeParamTypeVarTuple<U>, ) -> Result<TypeParamTypeVarTuple<Self::TargetU>, Self::Error>
fn fold_arg_with_default( &mut self, node: ArgWithDefault<U>, ) -> Result<ArgWithDefault<Self::TargetU>, Self::Error>
source§impl RangeBounds<TextSize> for TextRange
impl RangeBounds<TextSize> for TextRange
source§impl<S> SubAssign<S> for TextRange
impl<S> SubAssign<S> for TextRange
source§fn sub_assign(&mut self, rhs: S)
fn sub_assign(&mut self, rhs: S)
-=
operation. Read moreimpl Copy for TextRange
impl Eq for TextRange
impl StructuralPartialEq for TextRange
Auto Trait Implementations§
impl Freeze for TextRange
impl RefUnwindSafe for TextRange
impl Send for TextRange
impl Sync for TextRange
impl Unpin for TextRange
impl UnwindSafe for TextRange
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more