pub struct EntryCmpByOptions { /* private fields */ }Expand description
A struct to compare two entries.
use std::cmp::Ordering;
use rspolib::{POEntry, EntryCmpByOptions};
let mut entry1 = POEntry::from("msgid 1");
let entry2 = POEntry::from("msgid 2");
let compare_by_all_fields = EntryCmpByOptions::new();
let compare_by_msgid_only = EntryCmpByOptions::new()
.by_all(false)
.by_msgid(true);
assert_eq!(entry1.cmp_by(&entry2, &compare_by_msgid_only), Ordering::Less);
assert_eq!(entry2.cmp_by(&entry1, &compare_by_msgid_only), Ordering::Greater);
entry1.msgid = "msgid 2".to_string();
assert_eq!(entry1.cmp_by(&entry2, &compare_by_msgid_only), Ordering::Equal);
entry1.msgstr = Some("msgstr 1".to_string());
assert_eq!(entry1.cmp_by(&entry2, &compare_by_msgid_only), Ordering::Equal);
assert_eq!(entry1.cmp_by(&entry2, &compare_by_all_fields), Ordering::Greater);Implementations§
Source§impl EntryCmpByOptions
impl EntryCmpByOptions
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a instance of EntryCmpByOptions with comparisons for all fields enabled
pub fn by_msgid(self, by_msgid: bool) -> Self
pub fn by_msgstr(self, by_msgstr: bool) -> Self
pub fn by_msgctxt(self, by_msgctxt: bool) -> Self
pub fn by_obsolete(self, by_obsolete: bool) -> Self
pub fn by_occurrences(self, by_occurrences: bool) -> Self
pub fn by_msgid_plural(self, by_msgid_plural: bool) -> Self
pub fn by_msgstr_plural(self, by_msgstr_plural: bool) -> Self
pub fn by_flags(self, by_flags: bool) -> Self
pub fn by_all(self, by_all: bool) -> Self
Trait Implementations§
Source§impl Default for EntryCmpByOptions
impl Default for EntryCmpByOptions
Auto Trait Implementations§
impl Freeze for EntryCmpByOptions
impl RefUnwindSafe for EntryCmpByOptions
impl Send for EntryCmpByOptions
impl Sync for EntryCmpByOptions
impl Unpin for EntryCmpByOptions
impl UnwindSafe for EntryCmpByOptions
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