Struct pica_record::primitives::Occurrence
source · pub struct Occurrence(/* private fields */);
Expand description
A mutable occurrence.
Implementations§
source§impl Occurrence
impl Occurrence
sourcepub fn new(occurrence: &str) -> Result<Self, ParsePicaError>
pub fn new(occurrence: &str) -> Result<Self, ParsePicaError>
Create a new OccurrenceRef from a string slice.
§Panics
This method panics if the occurrence is invalid.
§Example
use pica_record::primitives::OccurrenceRef;
let occurrence = OccurrenceRef::new("001")?;
assert_eq!(occurrence, "001");
sourcepub fn as_bytes(&self) -> &[u8] ⓘ
pub fn as_bytes(&self) -> &[u8] ⓘ
Returns the Occurrence as a byte slice.
§Example
use pica_record::primitives::Occurrence;
let occurrence = Occurrence::new("001")?;
assert_eq!(occurrence.as_bytes(), b"001");
sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the length (number of digits) of the Occurrence.
§Example
use pica_record::primitives::Occurrence;
let occurrence = Occurrence::new("001")?;
assert_eq!(occurrence.len(), 3);
sourcepub fn write_to(&self, out: &mut impl Write) -> Result<()>
pub fn write_to(&self, out: &mut impl Write) -> Result<()>
Write the Occurrence into the given writer.
§Example
use std::io::Cursor;
use pica_record::primitives::Occurrence;
let mut writer = Cursor::new(Vec::<u8>::new());
let occurrence = Occurrence::new("01")?;
occurrence.write_to(&mut writer);
assert_eq!(String::from_utf8(writer.into_inner())?, "/01");
Trait Implementations§
source§impl Clone for Occurrence
impl Clone for Occurrence
source§fn clone(&self) -> Occurrence
fn clone(&self) -> Occurrence
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for Occurrence
impl Debug for Occurrence
source§impl Display for Occurrence
impl Display for Occurrence
source§impl From<OccurrenceRef<'_>> for Occurrence
impl From<OccurrenceRef<'_>> for Occurrence
source§fn from(occurrence: OccurrenceRef<'_>) -> Self
fn from(occurrence: OccurrenceRef<'_>) -> Self
Creates a Occurrence from a OccurrenceRef.
§Example
use pica_record::primitives::{Occurrence, OccurrenceRef};
let occ_ref = OccurrenceRef::new("001")?;
let occ = Occurrence::from(occ_ref);
assert_eq!(occ, "001");
source§impl PartialEq<&str> for Occurrence
impl PartialEq<&str> for Occurrence
source§impl PartialEq<Occurrence> for OccurrenceRef<'_>
impl PartialEq<Occurrence> for OccurrenceRef<'_>
source§fn eq(&self, other: &Occurrence) -> bool
fn eq(&self, other: &Occurrence) -> bool
Compares a OccurrenceRef with Occurrence.
§Example
use pica_record::primitives::{Occurrence, OccurrenceRef};
let occ_ref = OccurrenceRef::new("999")?;
let occ = Occurrence::new("999")?;
assert_eq!(occ_ref, occ);
source§impl PartialEq for Occurrence
impl PartialEq for Occurrence
source§impl PartialOrd for Occurrence
impl PartialOrd for Occurrence
impl Eq for Occurrence
impl StructuralPartialEq for Occurrence
Auto Trait Implementations§
impl Freeze for Occurrence
impl RefUnwindSafe for Occurrence
impl Send for Occurrence
impl Sync for Occurrence
impl Unpin for Occurrence
impl UnwindSafe for Occurrence
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
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)