Skip to main content

Row

Struct Row 

Source
pub struct Row {
    pub file: String,
    pub line: usize,
    pub index: usize,
    pub cols: Vec<String>,
    pub header: Arc<Vec<String>>,
}
Expand description

One data row of a fixture file.

Fields§

§file: String

Base name of the file this row came from (happy.tsv).

§line: usize

Physical 1-based line number within that file.

§index: usize

0-based position among the file’s DATA rows (header and skipped lines do not advance it).

§cols: Vec<String>

The row’s columns, exactly as they appear in the file.

§header: Arc<Vec<String>>

The file’s header names, shared with every row of the file.

Implementations§

Source§

impl Row

Source

pub fn col(&self, i: usize) -> &str

Raw column by position. Out of range is "": a fixture with a trailing optional column should not need a length check at every use.

Source

pub fn unesc(&self, i: usize) -> String

Escape-decoded column by position. This is what a parser input column goes through.

Source

pub fn index_of(&self, name: &str) -> Option<usize>

Position of a header name, or None when the file has no such column.

Source

pub fn named(&self, name: &str) -> &str

Raw column by header name; "" when there is no such column.

Source

pub fn unesc_named(&self, name: &str) -> String

Escape-decoded column by header name.

Source

pub fn resolve(&self, selector: &Column) -> Result<usize>

Resolve a column selector to a position. An unknown name is a defect in the caller, not a missing value, so it is an error rather than a silent read of an absent column.

Source

pub fn location(&self) -> String

<file>:<line>, the prefix every failure message should carry.

Trait Implementations§

Source§

impl Clone for Row

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Row

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Forget for Row

§

impl Freeze for Row
where *const u8 is !null: Freeze, PhantomData<u8>: Freeze, PhantomData<String>: Freeze, *const ArcInner<Vec<String>> is !null: Freeze, PhantomData<ArcInner<Vec<String>>>: Freeze,

§

impl Move for Row

§

impl RefUnwindSafe for Row

§

impl Send for Row
where RawVecInner: Send, Arc<Vec<String>>: Send,

§

impl Sync for Row
where RawVecInner: Sync, Arc<Vec<String>>: Sync,

§

impl Unpin for Row
where *const u8 is !null: Unpin, Arc<Vec<String>>: Unpin,

§

impl UnsafeUnpin for Row

§

impl UnwindSafe for Row
where RawVecInner: UnwindSafe, Arc<Vec<String>>: UnwindSafe,

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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> ToOwned for T
where T: Clone,

Source§

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>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.