Struct scfg::Scfg [−][src]
pub struct Scfg { /* fields omitted */ }
Expand description
An scfg document. Implemented as a multimap.
If the preserve_order
feature is enabled, the directive names will be kept
in the order of their first appearance. Otherwise, they will be sorted by name.
Implementations
impl Scfg
[src]
impl Scfg
[src]pub fn get<Q: ?Sized>(&self, name: &Q) -> Option<&Directive> where
String: Borrow<Q>,
Q: Ord + Eq + Hash,
[src]
pub fn get<Q: ?Sized>(&self, name: &Q) -> Option<&Directive> where
String: Borrow<Q>,
Q: Ord + Eq + Hash,
[src]Retrieves the first directive with a particular name.
This will return None
if either, the name is not found, or if the name
somehow has no directives.
pub fn get_all<Q: ?Sized>(&self, name: &Q) -> Option<&[Directive]> where
String: Borrow<Q>,
Q: Ord + Eq + Hash,
[src]
pub fn get_all<Q: ?Sized>(&self, name: &Q) -> Option<&[Directive]> where
String: Borrow<Q>,
Q: Ord + Eq + Hash,
[src]Retrieves the all directives with a particular name.
pub fn get_all_mut<Q: ?Sized>(
&mut self,
name: &Q
) -> Option<&mut Vec<Directive>> where
String: Borrow<Q>,
Q: Ord + Eq + Hash,
[src]
pub fn get_all_mut<Q: ?Sized>(
&mut self,
name: &Q
) -> Option<&mut Vec<Directive>> where
String: Borrow<Q>,
Q: Ord + Eq + Hash,
[src]Retrieves a mutable reference to all directives with a particular name.
pub fn contains<Q: ?Sized>(&self, name: &Q) -> bool where
String: Borrow<Q>,
Q: Ord + Eq + Hash,
[src]
pub fn contains<Q: ?Sized>(&self, name: &Q) -> bool where
String: Borrow<Q>,
Q: Ord + Eq + Hash,
[src]Does the document contain a directive with name
.
let mut scfg = Scfg::new(); scfg.add("foo"); assert!(scfg.contains("foo")); assert!(!scfg.contains("bar"));
pub fn add(&mut self, name: impl Into<String>) -> &mut Directive
[src]
pub fn add(&mut self, name: impl Into<String>) -> &mut Directive
[src]Adds a new name returning the new (empty) directive.
let mut scfg = Scfg::new(); let dir = scfg.add("dir1"); assert_eq!(*dir, Directive::default());
Note
This does not validate that name
is a legal scfg word. It is possible to create
unparsable documents should name
contain control characters or newlines.
pub fn remove<Q: ?Sized>(&mut self, name: &Q) -> Option<Vec<Directive>> where
String: Borrow<Q>,
Q: Ord + Eq + Hash,
[src]
pub fn remove<Q: ?Sized>(&mut self, name: &Q) -> Option<Vec<Directive>> where
String: Borrow<Q>,
Q: Ord + Eq + Hash,
[src]Removes all directives with the supplied name, returning them.
Trait Implementations
impl Eq for Scfg
[src]
impl StructuralEq for Scfg
[src]
impl StructuralPartialEq for Scfg
[src]
Auto Trait Implementations
impl RefUnwindSafe for Scfg
impl Send for Scfg
impl Sync for Scfg
impl Unpin for Scfg
impl UnwindSafe for Scfg
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more