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

source

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);
source

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

pub fn empty(offset: TextSize) -> TextRange

Create a zero-length range at the specified offset (offset..offset).

§Examples
let point: TextSize;
let range = TextRange::empty(point);
assert!(range.is_empty());
assert_eq!(range, TextRange::new(point, point));
source

pub fn up_to(end: TextSize) -> TextRange

Create a range up to the given end (..end).

§Examples
let point: TextSize;
let range = TextRange::up_to(point);

assert_eq!(range.len(), point);
assert_eq!(range, TextRange::new(0.into(), point));
assert_eq!(range, TextRange::at(0.into(), point));
source§

impl TextRange

Identity methods.

source

pub const fn start(self) -> TextSize

The start point of this range.

source

pub const fn end(self) -> TextSize

The end point of this range.

source

pub const fn len(self) -> TextSize

The size of this range.

source

pub const fn is_empty(self) -> bool

Check if this range is empty.

source§

impl TextRange

Manipulation methods.

source

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));
source

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));
source

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));
source

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())),
);
source

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()),
);
source

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()),
)
source

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.

source

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.

source

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);
source

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)));
source

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)));
source

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)));
source

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 Add<&TextSize> for TextRange

§

type Output = TextRange

The resulting type after applying the + operator.
source§

fn add(self, other: &TextSize) -> TextRange

Performs the + operation. Read more
source§

impl<T> Add<T> for &TextRange
where TextRange: Add<T, Output = TextRange>,

§

type Output = TextRange

The resulting type after applying the + operator.
source§

fn add(self, other: T) -> TextRange

Performs the + operation. Read more
source§

impl Add<TextSize> for TextRange

§

type Output = TextRange

The resulting type after applying the + operator.
source§

fn add(self, offset: TextSize) -> TextRange

Performs the + operation. Read more
source§

impl<A> AddAssign<A> for TextRange
where TextRange: Add<A, Output = TextRange>,

source§

fn add_assign(&mut self, rhs: A)

Performs the += operation. Read more
source§

impl Clone for TextRange

source§

fn clone(&self) -> TextRange

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for TextRange

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl Default for TextRange

source§

fn default() -> TextRange

Returns the “default value” for a type. Read more
source§

impl Fold<TextRange> for LinearLocator<'_>

§

type TargetU = SourceRange

§

type Error = Infallible

§

type UserContext = SourceLocation

source§

fn will_map_user(&mut self, user: &TextRange) -> Self::UserContext

source§

fn map_user( &mut self, user: TextRange, start: Self::UserContext ) -> Result<Self::TargetU, Self::Error>

source§

fn fold_expr_dict( &mut self, node: ExprDict<TextRange> ) -> Result<ExprDict<Self::TargetU>, Self::Error>

source§

fn fold_expr_if_exp( &mut self, node: ExprIfExp<TextRange> ) -> Result<ExprIfExp<Self::TargetU>, Self::Error>

source§

fn fold_stmt_class_def( &mut self, node: StmtClassDef<TextRange> ) -> Result<StmtClassDef<Self::TargetU>, Self::Error>

source§

fn fold_stmt_function_def( &mut self, node: StmtFunctionDef<TextRange> ) -> Result<StmtFunctionDef<Self::TargetU>, Self::Error>

source§

fn fold_stmt_async_function_def( &mut self, node: StmtAsyncFunctionDef<TextRange> ) -> Result<StmtAsyncFunctionDef<Self::TargetU>, Self::Error>

source§

fn fold_expr_joined_str( &mut self, node: ExprJoinedStr<TextRange> ) -> Result<ExprJoinedStr<Self::TargetU>, Self::Error>

source§

fn fold_expr_call( &mut self, node: ExprCall<TextRange> ) -> Result<ExprCall<Self::TargetU>, Self::Error>

source§

fn will_map_user_cfg( &mut self, _user: &EmptyRange<U> ) -> EmptyRange<Self::TargetU>

source§

fn map_user_cfg( &mut self, _user: EmptyRange<U>, _context: EmptyRange<Self::TargetU> ) -> Result<EmptyRange<Self::TargetU>, Self::Error>

source§

fn fold<X: Foldable<U, Self::TargetU>>( &mut self, node: X ) -> Result<X::Mapped, Self::Error>

source§

fn fold_mod(&mut self, node: Mod<U>) -> Result<Mod<Self::TargetU>, Self::Error>

source§

fn fold_mod_module( &mut self, node: ModModule<U> ) -> Result<ModModule<Self::TargetU>, Self::Error>

source§

fn fold_mod_interactive( &mut self, node: ModInteractive<U> ) -> Result<ModInteractive<Self::TargetU>, Self::Error>

source§

fn fold_mod_expression( &mut self, node: ModExpression<U> ) -> Result<ModExpression<Self::TargetU>, Self::Error>

source§

fn fold_mod_function_type( &mut self, node: ModFunctionType<U> ) -> Result<ModFunctionType<Self::TargetU>, Self::Error>

source§

fn fold_stmt( &mut self, node: Stmt<U> ) -> Result<Stmt<Self::TargetU>, Self::Error>

source§

fn fold_stmt_return( &mut self, node: StmtReturn<U> ) -> Result<StmtReturn<Self::TargetU>, Self::Error>

source§

fn fold_stmt_delete( &mut self, node: StmtDelete<U> ) -> Result<StmtDelete<Self::TargetU>, Self::Error>

source§

fn fold_stmt_assign( &mut self, node: StmtAssign<U> ) -> Result<StmtAssign<Self::TargetU>, Self::Error>

source§

fn fold_stmt_type_alias( &mut self, node: StmtTypeAlias<U> ) -> Result<StmtTypeAlias<Self::TargetU>, Self::Error>

source§

fn fold_stmt_aug_assign( &mut self, node: StmtAugAssign<U> ) -> Result<StmtAugAssign<Self::TargetU>, Self::Error>

source§

fn fold_stmt_ann_assign( &mut self, node: StmtAnnAssign<U> ) -> Result<StmtAnnAssign<Self::TargetU>, Self::Error>

source§

fn fold_stmt_for( &mut self, node: StmtFor<U> ) -> Result<StmtFor<Self::TargetU>, Self::Error>

source§

fn fold_stmt_async_for( &mut self, node: StmtAsyncFor<U> ) -> Result<StmtAsyncFor<Self::TargetU>, Self::Error>

source§

fn fold_stmt_while( &mut self, node: StmtWhile<U> ) -> Result<StmtWhile<Self::TargetU>, Self::Error>

source§

fn fold_stmt_if( &mut self, node: StmtIf<U> ) -> Result<StmtIf<Self::TargetU>, Self::Error>

source§

fn fold_stmt_with( &mut self, node: StmtWith<U> ) -> Result<StmtWith<Self::TargetU>, Self::Error>

source§

fn fold_stmt_async_with( &mut self, node: StmtAsyncWith<U> ) -> Result<StmtAsyncWith<Self::TargetU>, Self::Error>

source§

fn fold_stmt_match( &mut self, node: StmtMatch<U> ) -> Result<StmtMatch<Self::TargetU>, Self::Error>

source§

fn fold_stmt_raise( &mut self, node: StmtRaise<U> ) -> Result<StmtRaise<Self::TargetU>, Self::Error>

source§

fn fold_stmt_try( &mut self, node: StmtTry<U> ) -> Result<StmtTry<Self::TargetU>, Self::Error>

source§

fn fold_stmt_try_star( &mut self, node: StmtTryStar<U> ) -> Result<StmtTryStar<Self::TargetU>, Self::Error>

source§

fn fold_stmt_assert( &mut self, node: StmtAssert<U> ) -> Result<StmtAssert<Self::TargetU>, Self::Error>

source§

fn fold_stmt_import( &mut self, node: StmtImport<U> ) -> Result<StmtImport<Self::TargetU>, Self::Error>

source§

fn fold_stmt_import_from( &mut self, node: StmtImportFrom<U> ) -> Result<StmtImportFrom<Self::TargetU>, Self::Error>

source§

fn fold_stmt_global( &mut self, node: StmtGlobal<U> ) -> Result<StmtGlobal<Self::TargetU>, Self::Error>

source§

fn fold_stmt_nonlocal( &mut self, node: StmtNonlocal<U> ) -> Result<StmtNonlocal<Self::TargetU>, Self::Error>

source§

fn fold_stmt_expr( &mut self, node: StmtExpr<U> ) -> Result<StmtExpr<Self::TargetU>, Self::Error>

source§

fn fold_stmt_pass( &mut self, node: StmtPass<U> ) -> Result<StmtPass<Self::TargetU>, Self::Error>

source§

fn fold_stmt_break( &mut self, node: StmtBreak<U> ) -> Result<StmtBreak<Self::TargetU>, Self::Error>

source§

fn fold_stmt_continue( &mut self, node: StmtContinue<U> ) -> Result<StmtContinue<Self::TargetU>, Self::Error>

source§

fn fold_expr( &mut self, node: Expr<U> ) -> Result<Expr<Self::TargetU>, Self::Error>

source§

fn fold_expr_bool_op( &mut self, node: ExprBoolOp<U> ) -> Result<ExprBoolOp<Self::TargetU>, Self::Error>

source§

fn fold_expr_named_expr( &mut self, node: ExprNamedExpr<U> ) -> Result<ExprNamedExpr<Self::TargetU>, Self::Error>

source§

fn fold_expr_bin_op( &mut self, node: ExprBinOp<U> ) -> Result<ExprBinOp<Self::TargetU>, Self::Error>

source§

fn fold_expr_unary_op( &mut self, node: ExprUnaryOp<U> ) -> Result<ExprUnaryOp<Self::TargetU>, Self::Error>

source§

fn fold_expr_lambda( &mut self, node: ExprLambda<U> ) -> Result<ExprLambda<Self::TargetU>, Self::Error>

source§

fn fold_expr_set( &mut self, node: ExprSet<U> ) -> Result<ExprSet<Self::TargetU>, Self::Error>

source§

fn fold_expr_list_comp( &mut self, node: ExprListComp<U> ) -> Result<ExprListComp<Self::TargetU>, Self::Error>

source§

fn fold_expr_set_comp( &mut self, node: ExprSetComp<U> ) -> Result<ExprSetComp<Self::TargetU>, Self::Error>

source§

fn fold_expr_dict_comp( &mut self, node: ExprDictComp<U> ) -> Result<ExprDictComp<Self::TargetU>, Self::Error>

source§

fn fold_expr_generator_exp( &mut self, node: ExprGeneratorExp<U> ) -> Result<ExprGeneratorExp<Self::TargetU>, Self::Error>

source§

fn fold_expr_await( &mut self, node: ExprAwait<U> ) -> Result<ExprAwait<Self::TargetU>, Self::Error>

source§

fn fold_expr_yield( &mut self, node: ExprYield<U> ) -> Result<ExprYield<Self::TargetU>, Self::Error>

source§

fn fold_expr_yield_from( &mut self, node: ExprYieldFrom<U> ) -> Result<ExprYieldFrom<Self::TargetU>, Self::Error>

source§

fn fold_expr_compare( &mut self, node: ExprCompare<U> ) -> Result<ExprCompare<Self::TargetU>, Self::Error>

source§

fn fold_expr_formatted_value( &mut self, node: ExprFormattedValue<U> ) -> Result<ExprFormattedValue<Self::TargetU>, Self::Error>

source§

fn fold_expr_constant( &mut self, node: ExprConstant<U> ) -> Result<ExprConstant<Self::TargetU>, Self::Error>

source§

fn fold_expr_attribute( &mut self, node: ExprAttribute<U> ) -> Result<ExprAttribute<Self::TargetU>, Self::Error>

source§

fn fold_expr_subscript( &mut self, node: ExprSubscript<U> ) -> Result<ExprSubscript<Self::TargetU>, Self::Error>

source§

fn fold_expr_starred( &mut self, node: ExprStarred<U> ) -> Result<ExprStarred<Self::TargetU>, Self::Error>

source§

fn fold_expr_name( &mut self, node: ExprName<U> ) -> Result<ExprName<Self::TargetU>, Self::Error>

source§

fn fold_expr_list( &mut self, node: ExprList<U> ) -> Result<ExprList<Self::TargetU>, Self::Error>

source§

fn fold_expr_tuple( &mut self, node: ExprTuple<U> ) -> Result<ExprTuple<Self::TargetU>, Self::Error>

source§

fn fold_expr_slice( &mut self, node: ExprSlice<U> ) -> Result<ExprSlice<Self::TargetU>, Self::Error>

source§

fn fold_expr_context( &mut self, node: ExprContext ) -> Result<ExprContext, Self::Error>

source§

fn fold_boolop(&mut self, node: BoolOp) -> Result<BoolOp, Self::Error>

source§

fn fold_operator(&mut self, node: Operator) -> Result<Operator, Self::Error>

source§

fn fold_unaryop(&mut self, node: UnaryOp) -> Result<UnaryOp, Self::Error>

source§

fn fold_cmpop(&mut self, node: CmpOp) -> Result<CmpOp, Self::Error>

source§

fn fold_comprehension( &mut self, node: Comprehension<U> ) -> Result<Comprehension<Self::TargetU>, Self::Error>

source§

fn fold_excepthandler( &mut self, node: ExceptHandler<U> ) -> Result<ExceptHandler<Self::TargetU>, Self::Error>

source§

fn fold_excepthandler_except_handler( &mut self, node: ExceptHandlerExceptHandler<U> ) -> Result<ExceptHandlerExceptHandler<Self::TargetU>, Self::Error>

source§

fn fold_arguments( &mut self, node: Arguments<U> ) -> Result<Arguments<Self::TargetU>, Self::Error>

source§

fn fold_arg(&mut self, node: Arg<U>) -> Result<Arg<Self::TargetU>, Self::Error>

source§

fn fold_keyword( &mut self, node: Keyword<U> ) -> Result<Keyword<Self::TargetU>, Self::Error>

source§

fn fold_alias( &mut self, node: Alias<U> ) -> Result<Alias<Self::TargetU>, Self::Error>

source§

fn fold_withitem( &mut self, node: WithItem<U> ) -> Result<WithItem<Self::TargetU>, Self::Error>

source§

fn fold_match_case( &mut self, node: MatchCase<U> ) -> Result<MatchCase<Self::TargetU>, Self::Error>

source§

fn fold_pattern( &mut self, node: Pattern<U> ) -> Result<Pattern<Self::TargetU>, Self::Error>

source§

fn fold_pattern_match_value( &mut self, node: PatternMatchValue<U> ) -> Result<PatternMatchValue<Self::TargetU>, Self::Error>

source§

fn fold_pattern_match_singleton( &mut self, node: PatternMatchSingleton<U> ) -> Result<PatternMatchSingleton<Self::TargetU>, Self::Error>

source§

fn fold_pattern_match_sequence( &mut self, node: PatternMatchSequence<U> ) -> Result<PatternMatchSequence<Self::TargetU>, Self::Error>

source§

fn fold_pattern_match_mapping( &mut self, node: PatternMatchMapping<U> ) -> Result<PatternMatchMapping<Self::TargetU>, Self::Error>

source§

fn fold_pattern_match_class( &mut self, node: PatternMatchClass<U> ) -> Result<PatternMatchClass<Self::TargetU>, Self::Error>

source§

fn fold_pattern_match_star( &mut self, node: PatternMatchStar<U> ) -> Result<PatternMatchStar<Self::TargetU>, Self::Error>

source§

fn fold_pattern_match_as( &mut self, node: PatternMatchAs<U> ) -> Result<PatternMatchAs<Self::TargetU>, Self::Error>

source§

fn fold_pattern_match_or( &mut self, node: PatternMatchOr<U> ) -> Result<PatternMatchOr<Self::TargetU>, Self::Error>

source§

fn fold_type_ignore( &mut self, node: TypeIgnore<U> ) -> Result<TypeIgnore<Self::TargetU>, Self::Error>

source§

fn fold_type_ignore_type_ignore( &mut self, node: TypeIgnoreTypeIgnore<U> ) -> Result<TypeIgnoreTypeIgnore<Self::TargetU>, Self::Error>

source§

fn fold_type_param( &mut self, node: TypeParam<U> ) -> Result<TypeParam<Self::TargetU>, Self::Error>

source§

fn fold_type_param_type_var( &mut self, node: TypeParamTypeVar<U> ) -> Result<TypeParamTypeVar<Self::TargetU>, Self::Error>

source§

fn fold_type_param_param_spec( &mut self, node: TypeParamParamSpec<U> ) -> Result<TypeParamParamSpec<Self::TargetU>, Self::Error>

source§

fn fold_type_param_type_var_tuple( &mut self, node: TypeParamTypeVarTuple<U> ) -> Result<TypeParamTypeVarTuple<Self::TargetU>, Self::Error>

source§

fn fold_arg_with_default( &mut self, node: ArgWithDefault<U> ) -> Result<ArgWithDefault<Self::TargetU>, Self::Error>

source§

impl Fold<TextRange> for RandomLocator<'_>

§

type TargetU = SourceRange

§

type Error = Infallible

§

type UserContext = SourceLocation

source§

fn will_map_user(&mut self, user: &TextRange) -> Self::UserContext

source§

fn map_user( &mut self, user: TextRange, start: Self::UserContext ) -> Result<Self::TargetU, Self::Error>

source§

fn will_map_user_cfg( &mut self, _user: &EmptyRange<U> ) -> EmptyRange<Self::TargetU>

source§

fn map_user_cfg( &mut self, _user: EmptyRange<U>, _context: EmptyRange<Self::TargetU> ) -> Result<EmptyRange<Self::TargetU>, Self::Error>

source§

fn fold<X: Foldable<U, Self::TargetU>>( &mut self, node: X ) -> Result<X::Mapped, Self::Error>

source§

fn fold_mod(&mut self, node: Mod<U>) -> Result<Mod<Self::TargetU>, Self::Error>

source§

fn fold_mod_module( &mut self, node: ModModule<U> ) -> Result<ModModule<Self::TargetU>, Self::Error>

source§

fn fold_mod_interactive( &mut self, node: ModInteractive<U> ) -> Result<ModInteractive<Self::TargetU>, Self::Error>

source§

fn fold_mod_expression( &mut self, node: ModExpression<U> ) -> Result<ModExpression<Self::TargetU>, Self::Error>

source§

fn fold_mod_function_type( &mut self, node: ModFunctionType<U> ) -> Result<ModFunctionType<Self::TargetU>, Self::Error>

source§

fn fold_stmt( &mut self, node: Stmt<U> ) -> Result<Stmt<Self::TargetU>, Self::Error>

source§

fn fold_stmt_function_def( &mut self, node: StmtFunctionDef<U> ) -> Result<StmtFunctionDef<Self::TargetU>, Self::Error>

source§

fn fold_stmt_async_function_def( &mut self, node: StmtAsyncFunctionDef<U> ) -> Result<StmtAsyncFunctionDef<Self::TargetU>, Self::Error>

source§

fn fold_stmt_class_def( &mut self, node: StmtClassDef<U> ) -> Result<StmtClassDef<Self::TargetU>, Self::Error>

source§

fn fold_stmt_return( &mut self, node: StmtReturn<U> ) -> Result<StmtReturn<Self::TargetU>, Self::Error>

source§

fn fold_stmt_delete( &mut self, node: StmtDelete<U> ) -> Result<StmtDelete<Self::TargetU>, Self::Error>

source§

fn fold_stmt_assign( &mut self, node: StmtAssign<U> ) -> Result<StmtAssign<Self::TargetU>, Self::Error>

source§

fn fold_stmt_type_alias( &mut self, node: StmtTypeAlias<U> ) -> Result<StmtTypeAlias<Self::TargetU>, Self::Error>

source§

fn fold_stmt_aug_assign( &mut self, node: StmtAugAssign<U> ) -> Result<StmtAugAssign<Self::TargetU>, Self::Error>

source§

fn fold_stmt_ann_assign( &mut self, node: StmtAnnAssign<U> ) -> Result<StmtAnnAssign<Self::TargetU>, Self::Error>

source§

fn fold_stmt_for( &mut self, node: StmtFor<U> ) -> Result<StmtFor<Self::TargetU>, Self::Error>

source§

fn fold_stmt_async_for( &mut self, node: StmtAsyncFor<U> ) -> Result<StmtAsyncFor<Self::TargetU>, Self::Error>

source§

fn fold_stmt_while( &mut self, node: StmtWhile<U> ) -> Result<StmtWhile<Self::TargetU>, Self::Error>

source§

fn fold_stmt_if( &mut self, node: StmtIf<U> ) -> Result<StmtIf<Self::TargetU>, Self::Error>

source§

fn fold_stmt_with( &mut self, node: StmtWith<U> ) -> Result<StmtWith<Self::TargetU>, Self::Error>

source§

fn fold_stmt_async_with( &mut self, node: StmtAsyncWith<U> ) -> Result<StmtAsyncWith<Self::TargetU>, Self::Error>

source§

fn fold_stmt_match( &mut self, node: StmtMatch<U> ) -> Result<StmtMatch<Self::TargetU>, Self::Error>

source§

fn fold_stmt_raise( &mut self, node: StmtRaise<U> ) -> Result<StmtRaise<Self::TargetU>, Self::Error>

source§

fn fold_stmt_try( &mut self, node: StmtTry<U> ) -> Result<StmtTry<Self::TargetU>, Self::Error>

source§

fn fold_stmt_try_star( &mut self, node: StmtTryStar<U> ) -> Result<StmtTryStar<Self::TargetU>, Self::Error>

source§

fn fold_stmt_assert( &mut self, node: StmtAssert<U> ) -> Result<StmtAssert<Self::TargetU>, Self::Error>

source§

fn fold_stmt_import( &mut self, node: StmtImport<U> ) -> Result<StmtImport<Self::TargetU>, Self::Error>

source§

fn fold_stmt_import_from( &mut self, node: StmtImportFrom<U> ) -> Result<StmtImportFrom<Self::TargetU>, Self::Error>

source§

fn fold_stmt_global( &mut self, node: StmtGlobal<U> ) -> Result<StmtGlobal<Self::TargetU>, Self::Error>

source§

fn fold_stmt_nonlocal( &mut self, node: StmtNonlocal<U> ) -> Result<StmtNonlocal<Self::TargetU>, Self::Error>

source§

fn fold_stmt_expr( &mut self, node: StmtExpr<U> ) -> Result<StmtExpr<Self::TargetU>, Self::Error>

source§

fn fold_stmt_pass( &mut self, node: StmtPass<U> ) -> Result<StmtPass<Self::TargetU>, Self::Error>

source§

fn fold_stmt_break( &mut self, node: StmtBreak<U> ) -> Result<StmtBreak<Self::TargetU>, Self::Error>

source§

fn fold_stmt_continue( &mut self, node: StmtContinue<U> ) -> Result<StmtContinue<Self::TargetU>, Self::Error>

source§

fn fold_expr( &mut self, node: Expr<U> ) -> Result<Expr<Self::TargetU>, Self::Error>

source§

fn fold_expr_bool_op( &mut self, node: ExprBoolOp<U> ) -> Result<ExprBoolOp<Self::TargetU>, Self::Error>

source§

fn fold_expr_named_expr( &mut self, node: ExprNamedExpr<U> ) -> Result<ExprNamedExpr<Self::TargetU>, Self::Error>

source§

fn fold_expr_bin_op( &mut self, node: ExprBinOp<U> ) -> Result<ExprBinOp<Self::TargetU>, Self::Error>

source§

fn fold_expr_unary_op( &mut self, node: ExprUnaryOp<U> ) -> Result<ExprUnaryOp<Self::TargetU>, Self::Error>

source§

fn fold_expr_lambda( &mut self, node: ExprLambda<U> ) -> Result<ExprLambda<Self::TargetU>, Self::Error>

source§

fn fold_expr_if_exp( &mut self, node: ExprIfExp<U> ) -> Result<ExprIfExp<Self::TargetU>, Self::Error>

source§

fn fold_expr_dict( &mut self, node: ExprDict<U> ) -> Result<ExprDict<Self::TargetU>, Self::Error>

source§

fn fold_expr_set( &mut self, node: ExprSet<U> ) -> Result<ExprSet<Self::TargetU>, Self::Error>

source§

fn fold_expr_list_comp( &mut self, node: ExprListComp<U> ) -> Result<ExprListComp<Self::TargetU>, Self::Error>

source§

fn fold_expr_set_comp( &mut self, node: ExprSetComp<U> ) -> Result<ExprSetComp<Self::TargetU>, Self::Error>

source§

fn fold_expr_dict_comp( &mut self, node: ExprDictComp<U> ) -> Result<ExprDictComp<Self::TargetU>, Self::Error>

source§

fn fold_expr_generator_exp( &mut self, node: ExprGeneratorExp<U> ) -> Result<ExprGeneratorExp<Self::TargetU>, Self::Error>

source§

fn fold_expr_await( &mut self, node: ExprAwait<U> ) -> Result<ExprAwait<Self::TargetU>, Self::Error>

source§

fn fold_expr_yield( &mut self, node: ExprYield<U> ) -> Result<ExprYield<Self::TargetU>, Self::Error>

source§

fn fold_expr_yield_from( &mut self, node: ExprYieldFrom<U> ) -> Result<ExprYieldFrom<Self::TargetU>, Self::Error>

source§

fn fold_expr_compare( &mut self, node: ExprCompare<U> ) -> Result<ExprCompare<Self::TargetU>, Self::Error>

source§

fn fold_expr_call( &mut self, node: ExprCall<U> ) -> Result<ExprCall<Self::TargetU>, Self::Error>

source§

fn fold_expr_formatted_value( &mut self, node: ExprFormattedValue<U> ) -> Result<ExprFormattedValue<Self::TargetU>, Self::Error>

source§

fn fold_expr_joined_str( &mut self, node: ExprJoinedStr<U> ) -> Result<ExprJoinedStr<Self::TargetU>, Self::Error>

source§

fn fold_expr_constant( &mut self, node: ExprConstant<U> ) -> Result<ExprConstant<Self::TargetU>, Self::Error>

source§

fn fold_expr_attribute( &mut self, node: ExprAttribute<U> ) -> Result<ExprAttribute<Self::TargetU>, Self::Error>

source§

fn fold_expr_subscript( &mut self, node: ExprSubscript<U> ) -> Result<ExprSubscript<Self::TargetU>, Self::Error>

source§

fn fold_expr_starred( &mut self, node: ExprStarred<U> ) -> Result<ExprStarred<Self::TargetU>, Self::Error>

source§

fn fold_expr_name( &mut self, node: ExprName<U> ) -> Result<ExprName<Self::TargetU>, Self::Error>

source§

fn fold_expr_list( &mut self, node: ExprList<U> ) -> Result<ExprList<Self::TargetU>, Self::Error>

source§

fn fold_expr_tuple( &mut self, node: ExprTuple<U> ) -> Result<ExprTuple<Self::TargetU>, Self::Error>

source§

fn fold_expr_slice( &mut self, node: ExprSlice<U> ) -> Result<ExprSlice<Self::TargetU>, Self::Error>

source§

fn fold_expr_context( &mut self, node: ExprContext ) -> Result<ExprContext, Self::Error>

source§

fn fold_boolop(&mut self, node: BoolOp) -> Result<BoolOp, Self::Error>

source§

fn fold_operator(&mut self, node: Operator) -> Result<Operator, Self::Error>

source§

fn fold_unaryop(&mut self, node: UnaryOp) -> Result<UnaryOp, Self::Error>

source§

fn fold_cmpop(&mut self, node: CmpOp) -> Result<CmpOp, Self::Error>

source§

fn fold_comprehension( &mut self, node: Comprehension<U> ) -> Result<Comprehension<Self::TargetU>, Self::Error>

source§

fn fold_excepthandler( &mut self, node: ExceptHandler<U> ) -> Result<ExceptHandler<Self::TargetU>, Self::Error>

source§

fn fold_excepthandler_except_handler( &mut self, node: ExceptHandlerExceptHandler<U> ) -> Result<ExceptHandlerExceptHandler<Self::TargetU>, Self::Error>

source§

fn fold_arguments( &mut self, node: Arguments<U> ) -> Result<Arguments<Self::TargetU>, Self::Error>

source§

fn fold_arg(&mut self, node: Arg<U>) -> Result<Arg<Self::TargetU>, Self::Error>

source§

fn fold_keyword( &mut self, node: Keyword<U> ) -> Result<Keyword<Self::TargetU>, Self::Error>

source§

fn fold_alias( &mut self, node: Alias<U> ) -> Result<Alias<Self::TargetU>, Self::Error>

source§

fn fold_withitem( &mut self, node: WithItem<U> ) -> Result<WithItem<Self::TargetU>, Self::Error>

source§

fn fold_match_case( &mut self, node: MatchCase<U> ) -> Result<MatchCase<Self::TargetU>, Self::Error>

source§

fn fold_pattern( &mut self, node: Pattern<U> ) -> Result<Pattern<Self::TargetU>, Self::Error>

source§

fn fold_pattern_match_value( &mut self, node: PatternMatchValue<U> ) -> Result<PatternMatchValue<Self::TargetU>, Self::Error>

source§

fn fold_pattern_match_singleton( &mut self, node: PatternMatchSingleton<U> ) -> Result<PatternMatchSingleton<Self::TargetU>, Self::Error>

source§

fn fold_pattern_match_sequence( &mut self, node: PatternMatchSequence<U> ) -> Result<PatternMatchSequence<Self::TargetU>, Self::Error>

source§

fn fold_pattern_match_mapping( &mut self, node: PatternMatchMapping<U> ) -> Result<PatternMatchMapping<Self::TargetU>, Self::Error>

source§

fn fold_pattern_match_class( &mut self, node: PatternMatchClass<U> ) -> Result<PatternMatchClass<Self::TargetU>, Self::Error>

source§

fn fold_pattern_match_star( &mut self, node: PatternMatchStar<U> ) -> Result<PatternMatchStar<Self::TargetU>, Self::Error>

source§

fn fold_pattern_match_as( &mut self, node: PatternMatchAs<U> ) -> Result<PatternMatchAs<Self::TargetU>, Self::Error>

source§

fn fold_pattern_match_or( &mut self, node: PatternMatchOr<U> ) -> Result<PatternMatchOr<Self::TargetU>, Self::Error>

source§

fn fold_type_ignore( &mut self, node: TypeIgnore<U> ) -> Result<TypeIgnore<Self::TargetU>, Self::Error>

source§

fn fold_type_ignore_type_ignore( &mut self, node: TypeIgnoreTypeIgnore<U> ) -> Result<TypeIgnoreTypeIgnore<Self::TargetU>, Self::Error>

source§

fn fold_type_param( &mut self, node: TypeParam<U> ) -> Result<TypeParam<Self::TargetU>, Self::Error>

source§

fn fold_type_param_type_var( &mut self, node: TypeParamTypeVar<U> ) -> Result<TypeParamTypeVar<Self::TargetU>, Self::Error>

source§

fn fold_type_param_param_spec( &mut self, node: TypeParamParamSpec<U> ) -> Result<TypeParamParamSpec<Self::TargetU>, Self::Error>

source§

fn fold_type_param_type_var_tuple( &mut self, node: TypeParamTypeVarTuple<U> ) -> Result<TypeParamTypeVarTuple<Self::TargetU>, Self::Error>

source§

fn fold_arg_with_default( &mut self, node: ArgWithDefault<U> ) -> Result<ArgWithDefault<Self::TargetU>, Self::Error>

source§

impl From<Range<TextSize>> for TextRange

source§

fn from(r: Range<TextSize>) -> TextRange

Converts to this type from the input type.
source§

impl Hash for TextRange

source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Index<TextRange> for String

§

type Output = str

The returned type after indexing.
source§

fn index(&self, index: TextRange) -> &str

Performs the indexing (container[index]) operation. Read more
source§

impl Index<TextRange> for str

§

type Output = str

The returned type after indexing.
source§

fn index(&self, index: TextRange) -> &str

Performs the indexing (container[index]) operation. Read more
source§

impl IndexMut<TextRange> for String

source§

fn index_mut(&mut self, index: TextRange) -> &mut str

Performs the mutable indexing (container[index]) operation. Read more
source§

impl IndexMut<TextRange> for str

source§

fn index_mut(&mut self, index: TextRange) -> &mut str

Performs the mutable indexing (container[index]) operation. Read more
source§

impl PartialEq for TextRange

source§

fn eq(&self, other: &TextRange) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl RangeBounds<TextSize> for TextRange

source§

fn start_bound(&self) -> Bound<&TextSize>

Start index bound. Read more
source§

fn end_bound(&self) -> Bound<&TextSize>

End index bound. Read more
1.35.0 · source§

fn contains<U>(&self, item: &U) -> bool
where T: PartialOrd<U>, U: PartialOrd<T> + ?Sized,

Returns true if item is contained in the range. Read more
source§

impl Sub<&TextSize> for TextRange

§

type Output = TextRange

The resulting type after applying the - operator.
source§

fn sub(self, other: &TextSize) -> TextRange

Performs the - operation. Read more
source§

impl<T> Sub<T> for &TextRange
where TextRange: Sub<T, Output = TextRange>,

§

type Output = TextRange

The resulting type after applying the - operator.
source§

fn sub(self, other: T) -> TextRange

Performs the - operation. Read more
source§

impl Sub<TextSize> for TextRange

§

type Output = TextRange

The resulting type after applying the - operator.
source§

fn sub(self, offset: TextSize) -> TextRange

Performs the - operation. Read more
source§

impl<S> SubAssign<S> for TextRange
where TextRange: Sub<S, Output = TextRange>,

source§

fn sub_assign(&mut self, rhs: S)

Performs the -= operation. Read more
source§

impl Copy for TextRange

source§

impl Eq for TextRange

source§

impl StructuralPartialEq for TextRange

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<T, U> ExactFrom<T> for U
where U: TryFrom<T>,

source§

fn exact_from(value: T) -> U

source§

impl<T, U> ExactInto<U> for T
where U: ExactFrom<T>,

source§

fn exact_into(self) -> U

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> OverflowingInto<U> for T
where U: OverflowingFrom<T>,

source§

impl<T, U> RoundingInto<U> for T
where U: RoundingFrom<T>,

source§

impl<T, U> SaturatingInto<U> for T
where U: SaturatingFrom<T>,

source§

impl<T> ToDebugString for T
where T: Debug,

source§

fn to_debug_string(&self) -> String

Returns the String produced by Ts Debug implementation.

§Examples
use malachite_base::strings::ToDebugString;

assert_eq!([1, 2, 3].to_debug_string(), "[1, 2, 3]");
assert_eq!(
    [vec![2, 3], vec![], vec![4]].to_debug_string(),
    "[[2, 3], [], [4]]"
);
assert_eq!(Some(5).to_debug_string(), "Some(5)");
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T, U> WrappingInto<U> for T
where U: WrappingFrom<T>,

source§

fn wrapping_into(self) -> U