Struct onig::Region [−][src]
pub struct Region { /* fields omitted */ }
Represents a set of capture groups found in a search or match.
Methods
impl Region
[src]
impl Region
pub fn new() -> Region
[src]
pub fn new() -> Region
Create a new empty Region
pub fn with_capacity(capacity: usize) -> Region
[src]
pub fn with_capacity(capacity: usize) -> Region
Create a new region with a given capacity. This function allocates
a new region object as in Region::new
and resizes it to
contain at least capacity
regions.
Arguments
capacity
- the number of captures this region should be capable of storing without allocation.
pub fn clone_from_raw(ptr: *const OnigRegion) -> Self
[src]
pub fn clone_from_raw(ptr: *const OnigRegion) -> Self
Clone From Raw
Construct a new region based on an existing raw
*onig_sys::OnigRegion
pointer by copying.
pub fn clear(&mut self)
[src]
pub fn clear(&mut self)
This can be used to clear out a region so it can be used
again. See onig_sys::onig_region_clear
pub fn capacity(&self) -> usize
[src]
pub fn capacity(&self) -> usize
Get the current capacity of the region.
pub fn reserve(&mut self, new_capacity: usize)
[src]
pub fn reserve(&mut self, new_capacity: usize)
Updates the region to contain new_capacity
slots. See
onig_sys::onig_region_resize
for mor
information.
Arguments
new_capacity
- The new number of groups in the region.
pub fn len(&self) -> usize
[src]
pub fn len(&self) -> usize
Get the size of the region. Returns the number of registers in the region.
pub fn pos(&self, pos: usize) -> Option<(usize, usize)>
[src]
pub fn pos(&self, pos: usize) -> Option<(usize, usize)>
Returns the start and end positions of the Nth capture group. Returns
None
if pos
is not a valid capture group or if the capture group did
not match anything. The positions returned are always byte indices with
respect to the original string matched.
pub fn tree(&self) -> Option<&CaptureTreeNode>
[src]
pub fn tree(&self) -> Option<&CaptureTreeNode>
Get Capture Tree
Returns the capture tree for this region, if there is one.
pub fn iter<'a>(&'a self) -> RegionIter<'a>
[src]
pub fn iter<'a>(&'a self) -> RegionIter<'a>
Get an iterator over the captures in the region.
pub fn tree_traverse<F>(&self, callback: F) -> i32 where
F: Fn(u32, (usize, usize), u32) -> bool,
[src]
pub fn tree_traverse<F>(&self, callback: F) -> i32 where
F: Fn(u32, (usize, usize), u32) -> bool,
Walk the Tree of Captures
The given callback is invoked for each node in the capture tree. Each node is passed to the callback before any children.
pub fn tree_traverse_at<F>(&self, at: TraverseCallbackAt, callback: F) -> i32 where
F: Fn(u32, (usize, usize), u32) -> bool,
[src]
pub fn tree_traverse_at<F>(&self, at: TraverseCallbackAt, callback: F) -> i32 where
F: Fn(u32, (usize, usize), u32) -> bool,
Walk the Tree of Captures in a Given Order
The given callback is invoked for each node in the capture tree. The order in which the callback is invoked can be chosen.
Trait Implementations
impl Debug for Region
[src]
impl Debug for Region
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Eq for Region
[src]
impl Eq for Region
impl PartialEq for Region
[src]
impl PartialEq for Region
fn eq(&self, other: &Region) -> bool
[src]
fn eq(&self, other: &Region) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Region) -> bool
[src]
fn ne(&self, other: &Region) -> bool
This method tests for !=
.
impl Drop for Region
[src]
impl Drop for Region
impl Clone for Region
[src]
impl Clone for Region
fn clone(&self) -> Self
[src]
fn clone(&self) -> Self
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl<'a> IntoIterator for &'a Region
[src]
impl<'a> IntoIterator for &'a Region