diff --git a/CHANGELOG.md b/CHANGELOG.md index 2fab614..76d6235 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ SPDX-License-Identifier: MIT ## Unreleased - Add `o` command for opening a documentation item to the tui viewer. -- Add tests for Rust 1.48.0. +- Add tests for Rust 1.48.0 and 1.49.0. ## v0.4.1 (2020-10-11) diff --git a/tests/html/1.49.0/anyhow/all.html b/tests/html/1.49.0/anyhow/all.html new file mode 100644 index 0000000..45c3c6c --- /dev/null +++ b/tests/html/1.49.0/anyhow/all.html @@ -0,0 +1,6 @@ +
This library provides anyhow::Error
, a trait object based error
+type for easy idiomatic error handling in Rust applications.
Use Result<T, anyhow::Error>
, or equivalently anyhow::Result<T>
, as
+the return type of any fallible function.
Within the function, use ?
to easily propagate any error that implements
+the std::error::Error
trait.
+use anyhow::Result; + +fn get_cluster_info() -> Result<ClusterMap> { + let config = std::fs::read_to_string("cluster.json")?; + let map: ClusterMap = serde_json::from_str(&config)?; + Ok(map) +}
Attach context to help the person troubleshooting the error understand +where things went wrong. A low-level error like "No such file or +directory" can be annoying to debug without more context about what higher +level step the application was in the middle of.
+ ++use anyhow::{Context, Result}; + +fn main() -> Result<()> { + ... + it.detach().context("Failed to detach the important thing")?; + + let content = std::fs::read(path) + .with_context(|| format!("Failed to read instrs from {}", path))?; + ... +}
Error: Failed to read instrs from ./path/to/instrs.json
+
+Caused by:
+ No such file or directory (os error 2)
+
+Downcasting is supported and can be by value, by shared reference, or by +mutable reference as needed.
+ ++// If the error was caused by redaction, then return a +// tombstone instead of the content. +match root_cause.downcast_ref::<DataStoreError>() { + Some(DataStoreError::Censored(_)) => Ok(Poll::Ready(REDACTED_CONTENT)), + None => Err(error), +}
If using the nightly channel, a backtrace is captured and printed with the
+error if the underlying error type does not already provide its own. In
+order to see backtraces, they must be enabled through the environment
+variables described in std::backtrace
:
RUST_BACKTRACE=1
;RUST_LIB_BACKTRACE=1
;RUST_BACKTRACE=1
and
+RUST_LIB_BACKTRACE=0
.The tracking issue for this feature is rust-lang/rust#53487.
+Anyhow works with any error type that has an impl of std::error::Error
,
+including ones defined in your crate. We do not bundle a derive(Error)
+macro but you can write the impls yourself or use a standalone macro like
+thiserror.
+use thiserror::Error; + +#[derive(Error, Debug)] +pub enum FormatError { + #[error("Invalid header (expected {expected:?}, got {found:?})")] + InvalidHeader { + expected: String, + found: String, + }, + #[error("Missing attribute: {0}")] + MissingAttribute(String), +}
One-off error messages can be constructed using the anyhow!
macro, which
+supports string interpolation and produces an anyhow::Error
.
+return Err(anyhow!("Missing attribute: {}", missing));
In no_std mode, the same API is almost all available and works the same way. +To depend on Anyhow in no_std mode, disable our default enabled "std" +feature in Cargo.toml. A global allocator is required.
+[dependencies]
+anyhow = { version = "1.0", default-features = false }
+
+Since the ?
-based error conversions would normally rely on the
+std::error::Error
trait which is only available through std, no_std mode
+will require an explicit .map_err(Error::msg)
when working with a
+non-Anyhow error type inside a function that returns Anyhow's error type.
pub use anyhow as format_err; |
anyhow | Construct an ad-hoc error from a string. + |
bail | Return early with an error. + |
ensure | Return early with an error if a condition is not satisfied. + |
Chain | Iterator of a chain of source errors. + |
Error | The |
Context | Provides the |
Result |
|
Redirecting to macro.anyhow.html...
+ + + \ No newline at end of file diff --git a/tests/html/1.49.0/anyhow/macro.anyhow.html b/tests/html/1.49.0/anyhow/macro.anyhow.html new file mode 100644 index 0000000..5e02104 --- /dev/null +++ b/tests/html/1.49.0/anyhow/macro.anyhow.html @@ -0,0 +1,25 @@ +Construct an ad-hoc error from a string.
+This evaluates to an Error
. It can take either just a string, or a format
+string with arguments. It also can take any custom type which implements
+Debug
and Display
.
+use anyhow::{anyhow, Result}; + +fn lookup(key: &str) -> Result<V> { + if key.len() != 16 { + return Err(anyhow!("key length must be 16 characters, got {:?}", key)); + } + + // ... +}
Redirecting to macro.bail.html...
+ + + \ No newline at end of file diff --git a/tests/html/1.49.0/anyhow/macro.bail.html b/tests/html/1.49.0/anyhow/macro.bail.html new file mode 100644 index 0000000..c54a909 --- /dev/null +++ b/tests/html/1.49.0/anyhow/macro.bail.html @@ -0,0 +1,29 @@ +Return early with an error.
+This macro is equivalent to return Err(From::from($err))
.
+if !has_permission(user, resource) { + bail!("permission denied for accessing {}", resource); +}
+#[derive(Error, Debug)] +enum ScienceError { + #[error("recursion limit exceeded")] + RecursionLimitExceeded, + ... +} + +if depth > MAX_DEPTH { + bail!(ScienceError::RecursionLimitExceeded); +}
Redirecting to macro.ensure.html...
+ + + \ No newline at end of file diff --git a/tests/html/1.49.0/anyhow/macro.ensure.html b/tests/html/1.49.0/anyhow/macro.ensure.html new file mode 100644 index 0000000..3620ead --- /dev/null +++ b/tests/html/1.49.0/anyhow/macro.ensure.html @@ -0,0 +1,28 @@ +Return early with an error if a condition is not satisfied.
+This macro is equivalent to if !$cond { return Err(From::from($err)); }
.
Analogously to assert!
, ensure!
takes a condition and exits the function
+if the condition fails. Unlike assert!
, ensure!
returns an Error
+rather than panicking.
+ensure!(user == 0, "only user 0 is allowed");
+#[derive(Error, Debug)] +enum ScienceError { + #[error("recursion limit exceeded")] + RecursionLimitExceeded, + ... +} + +ensure!(depth <= MAX_DEPTH, ScienceError::RecursionLimitExceeded);
Iterator of a chain of source errors.
+This type is the iterator returned by Error::chain
.
+use anyhow::Error; +use std::io; + +pub fn underlying_io_error_kind(error: &Error) -> Option<io::ErrorKind> { + for cause in error.chain() { + if let Some(io_error) = cause.downcast_ref::<io::Error>() { + return Some(io_error.kind()); + } + } + None +}
impl<'a> Chain<'a>
[src]impl<'a> Clone for Chain<'a>
[src]impl<'_> Default for Chain<'_>
[src]impl<'_> DoubleEndedIterator for Chain<'_>
[src]fn next_back(&mut self) -> Option<Self::Item>
[src]fn advance_back_by(&mut self, n: usize) -> Result<(), usize>
[src]fn nth_back(&mut self, n: usize) -> Option<Self::Item>
1.37.0[src]fn try_rfold<B, F, R>(&mut self, init: B, f: F) -> R where
F: FnMut(B, Self::Item) -> R,
R: Try<Ok = B>,
1.27.0[src]fn rfold<B, F>(self, init: B, f: F) -> B where
F: FnMut(B, Self::Item) -> B,
1.27.0[src]fn rfind<P>(&mut self, predicate: P) -> Option<Self::Item> where
P: FnMut(&Self::Item) -> bool,
1.27.0[src]impl<'_> ExactSizeIterator for Chain<'_>
[src]impl<'a> Iterator for Chain<'a>
[src]type Item = &'a (dyn StdError + 'static)
The type of the elements being iterated over.
+fn next(&mut self) -> Option<Self::Item>
[src]fn size_hint(&self) -> (usize, Option<usize>)
[src]fn count(self) -> usize
1.0.0[src]fn last(self) -> Option<Self::Item>
1.0.0[src]fn advance_by(&mut self, n: usize) -> Result<(), usize>
[src]fn nth(&mut self, n: usize) -> Option<Self::Item>
1.0.0[src]fn step_by(self, step: usize) -> StepBy<Self>
1.28.0[src]fn chain<U>(self, other: U) -> Chain<Self, <U as IntoIterator>::IntoIter> where
U: IntoIterator<Item = Self::Item>,
1.0.0[src]fn zip<U>(self, other: U) -> Zip<Self, <U as IntoIterator>::IntoIter> where
U: IntoIterator,
1.0.0[src]fn map<B, F>(self, f: F) -> Map<Self, F> where
F: FnMut(Self::Item) -> B,
1.0.0[src]fn for_each<F>(self, f: F) where
F: FnMut(Self::Item),
1.21.0[src]fn filter<P>(self, predicate: P) -> Filter<Self, P> where
P: FnMut(&Self::Item) -> bool,
1.0.0[src]fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F> where
F: FnMut(Self::Item) -> Option<B>,
1.0.0[src]fn enumerate(self) -> Enumerate<Self>
1.0.0[src]fn peekable(self) -> Peekable<Self>
1.0.0[src]fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P> where
P: FnMut(&Self::Item) -> bool,
1.0.0[src]fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P> where
P: FnMut(&Self::Item) -> bool,
1.0.0[src]fn map_while<B, P>(self, predicate: P) -> MapWhile<Self, P> where
P: FnMut(Self::Item) -> Option<B>,
[src]fn skip(self, n: usize) -> Skip<Self>
1.0.0[src]fn take(self, n: usize) -> Take<Self>
1.0.0[src]fn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F> where
F: FnMut(&mut St, Self::Item) -> Option<B>,
1.0.0[src]fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F> where
F: FnMut(Self::Item) -> U,
U: IntoIterator,
1.0.0[src]fn flatten(self) -> Flatten<Self> where
Self::Item: IntoIterator,
1.29.0[src]fn fuse(self) -> Fuse<Self>
1.0.0[src]fn inspect<F>(self, f: F) -> Inspect<Self, F> where
F: FnMut(&Self::Item),
1.0.0[src]fn by_ref(&mut self) -> &mut Self
1.0.0[src]#[must_use =
+ "if you really need to exhaust the iterator, consider `.for_each(drop)` instead"]fn collect<B>(self) -> B where
B: FromIterator<Self::Item>,
1.0.0[src]fn partition<B, F>(self, f: F) -> (B, B) where
B: Default + Extend<Self::Item>,
F: FnMut(&Self::Item) -> bool,
1.0.0[src]fn partition_in_place<'a, T, P>(self, predicate: P) -> usize where
P: FnMut(&T) -> bool,
Self: DoubleEndedIterator<Item = &'a mut T>,
T: 'a,
[src]fn is_partitioned<P>(self, predicate: P) -> bool where
P: FnMut(Self::Item) -> bool,
[src]fn try_fold<B, F, R>(&mut self, init: B, f: F) -> R where
F: FnMut(B, Self::Item) -> R,
R: Try<Ok = B>,
1.27.0[src]fn try_for_each<F, R>(&mut self, f: F) -> R where
F: FnMut(Self::Item) -> R,
R: Try<Ok = ()>,
1.27.0[src]fn fold<B, F>(self, init: B, f: F) -> B where
F: FnMut(B, Self::Item) -> B,
1.0.0[src]fn fold_first<F>(self, f: F) -> Option<Self::Item> where
F: FnMut(Self::Item, Self::Item) -> Self::Item,
[src]fn all<F>(&mut self, f: F) -> bool where
F: FnMut(Self::Item) -> bool,
1.0.0[src]fn any<F>(&mut self, f: F) -> bool where
F: FnMut(Self::Item) -> bool,
1.0.0[src]fn find<P>(&mut self, predicate: P) -> Option<Self::Item> where
P: FnMut(&Self::Item) -> bool,
1.0.0[src]fn find_map<B, F>(&mut self, f: F) -> Option<B> where
F: FnMut(Self::Item) -> Option<B>,
1.30.0[src]fn try_find<F, R>(
&mut self,
f: F
) -> Result<Option<Self::Item>, <R as Try>::Error> where
F: FnMut(&Self::Item) -> R,
R: Try<Ok = bool>,
[src]fn position<P>(&mut self, predicate: P) -> Option<usize> where
P: FnMut(Self::Item) -> bool,
1.0.0[src]fn rposition<P>(&mut self, predicate: P) -> Option<usize> where
P: FnMut(Self::Item) -> bool,
Self: ExactSizeIterator + DoubleEndedIterator,
1.0.0[src]fn max(self) -> Option<Self::Item> where
Self::Item: Ord,
1.0.0[src]fn min(self) -> Option<Self::Item> where
Self::Item: Ord,
1.0.0[src]fn max_by_key<B, F>(self, f: F) -> Option<Self::Item> where
B: Ord,
F: FnMut(&Self::Item) -> B,
1.6.0[src]fn max_by<F>(self, compare: F) -> Option<Self::Item> where
F: FnMut(&Self::Item, &Self::Item) -> Ordering,
1.15.0[src]fn min_by_key<B, F>(self, f: F) -> Option<Self::Item> where
B: Ord,
F: FnMut(&Self::Item) -> B,
1.6.0[src]fn min_by<F>(self, compare: F) -> Option<Self::Item> where
F: FnMut(&Self::Item, &Self::Item) -> Ordering,
1.15.0[src]fn rev(self) -> Rev<Self> where
Self: DoubleEndedIterator,
1.0.0[src]fn unzip<A, B, FromA, FromB>(self) -> (FromA, FromB) where
FromA: Default + Extend<A>,
FromB: Default + Extend<B>,
Self: Iterator<Item = (A, B)>,
1.0.0[src]fn copied<'a, T>(self) -> Copied<Self> where
Self: Iterator<Item = &'a T>,
T: 'a + Copy,
1.36.0[src]fn cloned<'a, T>(self) -> Cloned<Self> where
Self: Iterator<Item = &'a T>,
T: 'a + Clone,
1.0.0[src]fn cycle(self) -> Cycle<Self> where
Self: Clone,
1.0.0[src]fn sum<S>(self) -> S where
S: Sum<Self::Item>,
1.11.0[src]fn product<P>(self) -> P where
P: Product<Self::Item>,
1.11.0[src]fn cmp<I>(self, other: I) -> Ordering where
I: IntoIterator<Item = Self::Item>,
Self::Item: Ord,
1.5.0[src]fn cmp_by<I, F>(self, other: I, cmp: F) -> Ordering where
F: FnMut(Self::Item, <I as IntoIterator>::Item) -> Ordering,
I: IntoIterator,
[src]fn partial_cmp<I>(self, other: I) -> Option<Ordering> where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]fn partial_cmp_by<I, F>(self, other: I, partial_cmp: F) -> Option<Ordering> where
F: FnMut(Self::Item, <I as IntoIterator>::Item) -> Option<Ordering>,
I: IntoIterator,
[src]fn eq<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialEq<<I as IntoIterator>::Item>,
1.5.0[src]fn eq_by<I, F>(self, other: I, eq: F) -> bool where
F: FnMut(Self::Item, <I as IntoIterator>::Item) -> bool,
I: IntoIterator,
[src]fn ne<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialEq<<I as IntoIterator>::Item>,
1.5.0[src]fn lt<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]fn le<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]fn gt<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]fn ge<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]fn is_sorted(self) -> bool where
Self::Item: PartialOrd<Self::Item>,
[src]fn is_sorted_by<F>(self, compare: F) -> bool where
F: FnMut(&Self::Item, &Self::Item) -> Option<Ordering>,
[src]fn is_sorted_by_key<F, K>(self, f: F) -> bool where
F: FnMut(Self::Item) -> K,
K: PartialOrd<K>,
[src]impl<'a> !RefUnwindSafe for Chain<'a>
impl<'a> !Send for Chain<'a>
impl<'a> !Sync for Chain<'a>
impl<'a> Unpin for Chain<'a>
impl<'a> !UnwindSafe for Chain<'a>
impl<T> Any for T where
T: 'static + ?Sized,
[src]impl<T> Borrow<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]impl<T> From<T> for T
[src]impl<T, U> Into<U> for T where
U: From<T>,
[src]impl<I> IntoIterator for I where
I: Iterator,
[src]type Item = <I as Iterator>::Item
The type of the elements being iterated over.
+type IntoIter = I
Which kind of iterator are we turning this into?
+pub fn into_iter(self) -> I
[src]impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
The resulting type after obtaining ownership.
+pub fn to_owned(&self) -> T
[src]pub fn clone_into(&self, target: &mut T)
[src]impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]type Error = Infallible
The type returned in the event of a conversion error.
+pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]The Error
type, a wrapper around a dynamic error type.
Error
works a lot like Box<dyn std::error::Error>
, but with these
+differences:
Error
requires that the error is Send
, Sync
, and 'static
.Error
guarantees that a backtrace is available, even if the underlying
+error type does not provide one.Error
is represented as a narrow pointer — exactly one word in
+size instead of two.When you print an error object using "{}" or to_string(), only the outermost +underlying error or context is printed, not any of the lower level causes. +This is exactly as if you had called the Display impl of the error from +which you constructed your anyhow::Error.
+Failed to read instrs from ./path/to/instrs.json
+
+To print causes as well using anyhow's default formatting of causes, use the +alternate selector "{:#}".
+Failed to read instrs from ./path/to/instrs.json: No such file or directory (os error 2)
+
+The Debug format "{:?}" includes your backtrace if one was captured. Note
+that this is the representation you get by default if you return an error
+from fn main
instead of printing it explicitly yourself.
Error: Failed to read instrs from ./path/to/instrs.json
+
+Caused by:
+ No such file or directory (os error 2)
+
+and if there is a backtrace available:
+Error: Failed to read instrs from ./path/to/instrs.json
+
+Caused by:
+ No such file or directory (os error 2)
+
+Stack backtrace:
+ 0: <E as anyhow::context::ext::StdError>::ext_context
+ at /git/anyhow/src/backtrace.rs:26
+ 1: core::result::Result<T,E>::map_err
+ at /git/rustc/src/libcore/result.rs:596
+ 2: anyhow::context::<impl anyhow::Context<T,E> for core::result::Result<T,E>>::with_context
+ at /git/anyhow/src/context.rs:58
+ 3: testing::main
+ at src/main.rs:5
+ 4: std::rt::lang_start
+ at /git/rustc/src/libstd/rt.rs:61
+ 5: main
+ 6: __libc_start_main
+ 7: _start
+
+To see a conventional struct-style Debug representation, use "{:#?}".
+Error {
+ context: "Failed to read instrs from ./path/to/instrs.json",
+ source: Os {
+ code: 2,
+ kind: NotFound,
+ message: "No such file or directory",
+ },
+}
+
+If none of the built-in representations are appropriate and you would prefer +to render the error and its cause chain yourself, it can be done something +like this:
+ ++use anyhow::{Context, Result}; + +fn main() { + if let Err(err) = try_main() { + eprintln!("ERROR: {}", err); + err.chain().skip(1).for_each(|cause| eprintln!("because: {}", cause)); + std::process::exit(1); + } +} + +fn try_main() -> Result<()> { + ... +}
impl Error
[src]pub fn new<E>(error: E) -> Self where
E: StdError + Send + Sync + 'static,
[src]Create a new error object from any error type.
+The error type must be threadsafe and 'static
, so that the Error
+will be as well.
If the error type does not provide a backtrace, a backtrace will be +created here to ensure that a backtrace exists.
+pub fn msg<M>(message: M) -> Self where
M: Display + Debug + Send + Sync + 'static,
[src]Create a new error object from a printable error message.
+If the argument implements std::error::Error, prefer Error::new
+instead which preserves the underlying error's cause chain and
+backtrace. If the argument may or may not implement std::error::Error
+now or in the future, use anyhow!(err)
which handles either way
+correctly.
Error::msg("...")
is equivalent to anyhow!("...")
but occasionally
+convenient in places where a function is preferable over a macro, such
+as iterator or stream combinators:
+use anyhow::{Error, Result}; +use futures::stream::{Stream, StreamExt, TryStreamExt}; + +async fn demo<S>(stream: S) -> Result<Vec<Output>> +where + S: Stream<Item = Input>, +{ + stream + .then(ffi::do_some_work) // returns Result<Output, &str> + .map_err(Error::msg) + .try_collect() + .await +}
pub fn context<C>(self, context: C) -> Self where
C: Display + Send + Sync + 'static,
[src]Wrap the error value with additional context.
+For attaching context to a Result
as it is propagated, the
+Context
extension trait may be more convenient than
+this function.
The primary reason to use error.context(...)
instead of
+result.context(...)
via the Context
trait would be if the context
+needs to depend on some data held by the underlying error:
+use anyhow::Result; +use std::fs::File; +use std::path::Path; + +struct ParseError { + line: usize, + column: usize, +} + +fn parse_impl(file: File) -> Result<T, ParseError> { + ... +} + +pub fn parse(path: impl AsRef<Path>) -> Result<T> { + let file = File::open(&path)?; + parse_impl(file).map_err(|error| { + let context = format!( + "only the first {} lines of {} are valid", + error.line, path.as_ref().display(), + ); + anyhow::Error::new(error).context(context) + }) +}
pub fn chain(&self) -> Chain<'_>ⓘ
[src]An iterator of the chain of source errors contained by this Error.
+This iterator will visit every error in the cause chain of this error +object, beginning with the error that this error object was created +from.
++use anyhow::Error; +use std::io; + +pub fn underlying_io_error_kind(error: &Error) -> Option<io::ErrorKind> { + for cause in error.chain() { + if let Some(io_error) = cause.downcast_ref::<io::Error>() { + return Some(io_error.kind()); + } + } + None +}
pub fn root_cause(&self) -> &(dyn StdError + 'static)
[src]The lowest level cause of this error — this error's cause's +cause's cause etc.
+The root cause is the last error in the iterator produced by
+chain()
.
pub fn is<E>(&self) -> bool where
E: Display + Debug + Send + Sync + 'static,
[src]Returns true if E
is the type held by this error object.
For errors with context, this method returns true if E
matches the
+type of the context C
or the type of the error on which the
+context has been attached. For details about the interaction between
+context and downcasting, see here.
pub fn downcast<E>(self) -> Result<E, Self> where
E: Display + Debug + Send + Sync + 'static,
[src]Attempt to downcast the error object to a concrete type.
+pub fn downcast_ref<E>(&self) -> Option<&E> where
E: Display + Debug + Send + Sync + 'static,
[src]Downcast this error object by reference.
++// If the error was caused by redaction, then return a tombstone instead +// of the content. +match root_cause.downcast_ref::<DataStoreError>() { + Some(DataStoreError::Censored(_)) => Ok(Poll::Ready(REDACTED_CONTENT)), + None => Err(error), +}
pub fn downcast_mut<E>(&mut self) -> Option<&mut E> where
E: Display + Debug + Send + Sync + 'static,
[src]Downcast this error object by mutable reference.
+pub fn is<T>(&self) -> bool where
T: 'static + Error,
1.3.0[src]Returns true
if the boxed type is the same as T
pub fn downcast_ref<T>(&self) -> Option<&T> where
T: 'static + Error,
1.3.0[src]Returns some reference to the boxed value if it is of type T
, or
+None
if it isn't.
pub fn downcast_mut<T>(&mut self) -> Option<&mut T> where
T: 'static + Error,
1.3.0[src]Returns some mutable reference to the boxed value if it is of type T
, or
+None
if it isn't.
pub fn is<T>(&self) -> bool where
T: 'static + Error,
1.3.0[src]Forwards to the method defined on the type dyn Error
.
pub fn downcast_ref<T>(&self) -> Option<&T> where
T: 'static + Error,
1.3.0[src]Forwards to the method defined on the type dyn Error
.
pub fn downcast_mut<T>(&mut self) -> Option<&mut T> where
T: 'static + Error,
1.3.0[src]Forwards to the method defined on the type dyn Error
.
pub fn is<T>(&self) -> bool where
T: 'static + Error,
1.3.0[src]Forwards to the method defined on the type dyn Error
.
pub fn downcast_ref<T>(&self) -> Option<&T> where
T: 'static + Error,
1.3.0[src]Forwards to the method defined on the type dyn Error
.
pub fn downcast_mut<T>(&mut self) -> Option<&mut T> where
T: 'static + Error,
1.3.0[src]Forwards to the method defined on the type dyn Error
.
pub fn chain(&self) -> Chain<'_>
[src]error_iter
)Returns an iterator starting with the current error and continuing with
+recursively calling Error::source
.
If you want to omit the current error and only use its sources,
+use skip(1)
.
+#![feature(error_iter)] +use std::error::Error; +use std::fmt; + +#[derive(Debug)] +struct A; + +#[derive(Debug)] +struct B(Option<Box<dyn Error + 'static>>); + +impl fmt::Display for A { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "A") + } +} + +impl fmt::Display for B { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "B") + } +} + +impl Error for A {} + +impl Error for B { + fn source(&self) -> Option<&(dyn Error + 'static)> { + self.0.as_ref().map(|e| e.as_ref()) + } +} + +let b = B(Some(Box::new(A))); + +// let err : Box<Error> = b.into(); // or +let err = &b as &(dyn Error); + +let mut iter = err.chain(); + +assert_eq!("B".to_string(), iter.next().unwrap().to_string()); +assert_eq!("A".to_string(), iter.next().unwrap().to_string()); +assert!(iter.next().is_none()); +assert!(iter.next().is_none());
impl AsRef<dyn Error + 'static + Sync + Send> for Error
[src]impl AsRef<dyn Error + 'static> for Error
[src]impl Debug for Error
[src]impl Deref for Error
[src]type Target = dyn StdError + Send + Sync + 'static
The resulting type after dereferencing.
+fn deref(&self) -> &Self::Target
[src]impl DerefMut for Error
[src]impl Display for Error
[src]impl Drop for Error
[src]impl<E> From<E> for Error where
E: StdError + Send + Sync + 'static,
[src]impl From<Error> for Box<dyn StdError + Send + Sync + 'static>
[src]impl From<Error> for Box<dyn StdError + 'static>
[src]impl RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnwindSafe for Error
impl<T> Any for T where
T: 'static + ?Sized,
[src]impl<T> Borrow<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]impl<T> From<!> for T
[src]impl<T> From<T> for T
[src]impl<T, U> Into<U> for T where
U: From<T>,
[src]impl<T> ToString for T where
T: Display + ?Sized,
[src]impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]type Error = Infallible
The type returned in the event of a conversion error.
+pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]Provides the context
method for Result
.
This trait is sealed and cannot be implemented for types outside of
+anyhow
.
+use anyhow::{Context, Result}; +use std::fs; +use std::path::PathBuf; + +pub struct ImportantThing { + path: PathBuf, +} + +impl ImportantThing { + pub fn detach(&mut self) -> Result<()> {...} +} + +pub fn do_it(mut it: ImportantThing) -> Result<Vec<u8>> { + it.detach().context("Failed to detach the important thing")?; + + let path = &it.path; + let content = fs::read(path) + .with_context(|| format!("Failed to read instrs from {}", path.display()))?; + + Ok(content) +}
When printed, the outermost context would be printed first and the lower +level underlying causes would be enumerated below.
+Error: Failed to read instrs from ./path/to/instrs.json
+
+Caused by:
+ No such file or directory (os error 2)
+
+After attaching context of type C
onto an error of type E
, the resulting
+anyhow::Error
may be downcast to C
or to E
.
That is, in codebases that rely on downcasting, Anyhow's context supports +both of the following use cases:
+Attaching context whose type is insignificant onto errors whose type +is used in downcasts.
+In other error libraries whose context is not designed this way, it can +be risky to introduce context to existing code because new context might +break existing working downcasts. In Anyhow, any downcast that worked +before adding context will continue to work after you add a context, so +you should freely add human-readable context to errors wherever it would +be helpful.
+ ++use anyhow::{Context, Result}; + +fn do_it() -> Result<()> { + helper().context("Failed to complete the work")?; + ... +} + +fn main() { + let err = do_it().unwrap_err(); + if let Some(e) = err.downcast_ref::<SuspiciousError>() { + // If helper() returned SuspiciousError, this downcast will + // correctly succeed even with the context in between. + } +}
Attaching context whose type is used in downcasts onto errors whose +type is insignificant.
+Some codebases prefer to use machine-readable context to categorize +lower level errors in a way that will be actionable to higher levels of +the application.
+ ++use anyhow::{Context, Result}; + +fn do_it() -> Result<()> { + helper().context(HelperFailed)?; + ... +} + +fn main() { + let err = do_it().unwrap_err(); + if let Some(e) = err.downcast_ref::<HelperFailed>() { + // If helper failed, this downcast will succeed because + // HelperFailed is the context that has been attached to + // that error. + } +}
fn context<C>(self, context: C) -> Result<T, Error> where
C: Display + Send + Sync + 'static,
Wrap the error value with additional context.
+fn with_context<C, F>(self, f: F) -> Result<T, Error> where
C: Display + Send + Sync + 'static,
F: FnOnce() -> C,
Wrap the error value with additional context that is evaluated lazily +only once an error does occur.
+impl<T, E> Context<T, E> for Result<T, E> where
E: StdError + Send + Sync + 'static,
[src]fn context<C>(self, context: C) -> Result<T, Error> where
C: Display + Send + Sync + 'static,
[src]fn with_context<C, F>(self, context: F) -> Result<T, Error> where
C: Display + Send + Sync + 'static,
F: FnOnce() -> C,
[src]impl<T> Context<T, Infallible> for Option<T>
[src]+use anyhow::{Context, Result}; + +fn maybe_get() -> Option<T> { + ... +} + +fn demo() -> Result<()> { + let t = maybe_get().context("there is no T")?; + ... +}
fn context<C>(self, context: C) -> Result<T, Error> where
C: Display + Send + Sync + 'static,
[src]fn with_context<C, F>(self, context: F) -> Result<T, Error> where
C: Display + Send + Sync + 'static,
F: FnOnce() -> C,
[src]type Result<T, E = Error> = Result<T, E>;
Result<T, Error>
This is a reasonable return type to use throughout your application but also
+for fn main
; if you do, failures will be printed along with any
+context and a backtrace if one was captured.
anyhow::Result
may be used with one or two type parameters.
+use anyhow::Result; + +fn demo1() -> Result<T> {...} + // ^ equivalent to std::result::Result<T, anyhow::Error> + +fn demo2() -> Result<T, OtherError> {...} + // ^ equivalent to std::result::Result<T, OtherError>
+use anyhow::Result; + +fn main() -> Result<()> { + let config = std::fs::read_to_string("cluster.json")?; + let map: ClusterMap = serde_json::from_str(&config)?; + println!("cluster info: {:#?}", map); + Ok(()) +}
Redirecting to ../../kuchiki/struct.Attribute.html...
+ + + \ No newline at end of file diff --git a/tests/html/1.49.0/kuchiki/attributes/struct.Attributes.html b/tests/html/1.49.0/kuchiki/attributes/struct.Attributes.html new file mode 100644 index 0000000..b96f2a9 --- /dev/null +++ b/tests/html/1.49.0/kuchiki/attributes/struct.Attributes.html @@ -0,0 +1,10 @@ + + + + + + +Redirecting to ../../kuchiki/struct.Attributes.html...
+ + + \ No newline at end of file diff --git a/tests/html/1.49.0/kuchiki/attributes/struct.ExpandedName.html b/tests/html/1.49.0/kuchiki/attributes/struct.ExpandedName.html new file mode 100644 index 0000000..1c25971 --- /dev/null +++ b/tests/html/1.49.0/kuchiki/attributes/struct.ExpandedName.html @@ -0,0 +1,10 @@ + + + + + + +Redirecting to ../../kuchiki/struct.ExpandedName.html...
+ + + \ No newline at end of file diff --git a/tests/html/1.49.0/kuchiki/enum.NodeData.html b/tests/html/1.49.0/kuchiki/enum.NodeData.html new file mode 100644 index 0000000..7980fde --- /dev/null +++ b/tests/html/1.49.0/kuchiki/enum.NodeData.html @@ -0,0 +1,41 @@ +Node data specific to the node type.
+Element(ElementData)
Element node
+Text node
+Comment node
+Processing instruction node
+Doctype(Doctype)
Doctype node
+Document(DocumentData)
Document node
+Document fragment node
+impl Clone for NodeData
[src]impl Debug for NodeData
[src]impl PartialEq<NodeData> for NodeData
[src]impl StructuralPartialEq for NodeData
[src]impl !RefUnwindSafe for NodeData
impl !Send for NodeData
impl !Sync for NodeData
impl Unpin for NodeData
impl !UnwindSafe for NodeData
impl<T> Any for T where
T: 'static + ?Sized,
[src]impl<T> Borrow<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]impl<T> From<T> for T
[src]impl<T, U> Into<U> for T where
U: From<T>,
[src]impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
The resulting type after obtaining ownership.
+pub fn to_owned(&self) -> T
[src]pub fn clone_into(&self, target: &mut T)
[src]impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]type Error = Infallible
The type returned in the event of a conversion error.
+pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]pub fn parse_html() -> Parser<Sink>
Parse an HTML document with html5ever and the default configuration.
+pub fn parse_html_with_options(opts: ParseOpts) -> Parser<Sink>
Parse an HTML document with html5ever with custom configuration.
+Kuchiki (朽木), a HTML/XML tree manipulation library for Rust.
+iter | Node iterators + |
traits | This module re-exports a number of traits that are useful when using Kuchiki. +It can be used with: + |
Attribute | The non-identifying parts of an attribute + |
Attributes | Convenience wrapper around a btreemap that adds method for attributes in the null namespace. + |
Doctype | Data specific to doctype nodes. + |
DocumentData | Data specific to document nodes. + |
ElementData | Data specific to element nodes. + |
ExpandedName | + |
Node | A node inside a DOM-like tree. + |
NodeDataRef | Holds a strong reference to a node, but dereferences to some component inside of it. + |
NodeRef | A strong reference to a node. + |
ParseOpts | Options for the HTML parser. + |
Selector | A pre-compiled CSS Selector. + |
Selectors | A pre-compiled list of CSS Selectors. + |
Specificity | The specificity of a selector. + |
NodeData | Node data specific to the node type. + |
parse_html | Parse an HTML document with html5ever and the default configuration. + |
parse_html_with_options | Parse an HTML document with html5ever with custom configuration. + |
Marks either the start or the end of a node.
+Indicates that start of a node that has children.
+Yielded by Traverse::next
before the node’s descendants.
+In HTML or XML, this corresponds to an opening tag like <div>
Indicates that end of a node that has children.
+Yielded by Traverse::next
after the node’s descendants.
+In HTML or XML, this corresponds to a closing tag like </div>
impl<T: Clone> Clone for NodeEdge<T>
[src]impl<T: Copy> Copy for NodeEdge<T>
[src]impl<T: Debug> Debug for NodeEdge<T>
[src]impl<T: Eq> Eq for NodeEdge<T>
[src]impl<T: PartialEq> PartialEq<NodeEdge<T>> for NodeEdge<T>
[src]impl<T> StructuralEq for NodeEdge<T>
[src]impl<T> StructuralPartialEq for NodeEdge<T>
[src]impl<T> RefUnwindSafe for NodeEdge<T> where
T: RefUnwindSafe,
impl<T> Send for NodeEdge<T> where
T: Send,
impl<T> Sync for NodeEdge<T> where
T: Sync,
impl<T> Unpin for NodeEdge<T> where
T: Unpin,
impl<T> UnwindSafe for NodeEdge<T> where
T: UnwindSafe,
impl<T> Any for T where
T: 'static + ?Sized,
[src]impl<T> Borrow<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]impl<T> From<T> for T
[src]impl<T, U> Into<U> for T where
U: From<T>,
[src]impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
The resulting type after obtaining ownership.
+pub fn to_owned(&self) -> T
[src]pub fn clone_into(&self, target: &mut T)
[src]impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]type Error = Infallible
The type returned in the event of a conversion error.
+pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]Node iterators
+Ancestors | An iterator on ancestor nodes. + |
Comments | A node iterator adaptor that yields comment nodes. + |
Descendants | An iterator of references to a given node and its descendants, in tree order. + |
Elements | A node iterator adaptor that yields element nodes. + |
Select | An element iterator adaptor that yields elements maching given selectors. + |
Siblings | A double-ended iterator of sibling nodes. + |
TextNodes | A node iterator adaptor that yields text nodes. + |
Traverse | An iterator of the start and end edges of the nodes in a given subtree. + |
NodeEdge | Marks either the start or the end of a node. + |
ElementIterator | Convenience methods for element iterators. + |
NodeIterator | Convenience methods for node iterators. + |
An iterator on ancestor nodes.
+impl Clone for Ancestors
[src]impl Debug for Ancestors
[src]impl Iterator for Ancestors
[src]type Item = NodeRef
The type of the elements being iterated over.
+fn next(&mut self) -> Option<NodeRef>
[src]fn size_hint(&self) -> (usize, Option<usize>)
1.0.0[src]fn count(self) -> usize
1.0.0[src]fn last(self) -> Option<Self::Item>
1.0.0[src]fn advance_by(&mut self, n: usize) -> Result<(), usize>
[src]fn nth(&mut self, n: usize) -> Option<Self::Item>
1.0.0[src]fn step_by(self, step: usize) -> StepBy<Self>
1.28.0[src]fn chain<U>(self, other: U) -> Chain<Self, <U as IntoIterator>::IntoIter> where
U: IntoIterator<Item = Self::Item>,
1.0.0[src]fn zip<U>(self, other: U) -> Zip<Self, <U as IntoIterator>::IntoIter> where
U: IntoIterator,
1.0.0[src]fn map<B, F>(self, f: F) -> Map<Self, F> where
F: FnMut(Self::Item) -> B,
1.0.0[src]fn for_each<F>(self, f: F) where
F: FnMut(Self::Item),
1.21.0[src]fn filter<P>(self, predicate: P) -> Filter<Self, P> where
P: FnMut(&Self::Item) -> bool,
1.0.0[src]fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F> where
F: FnMut(Self::Item) -> Option<B>,
1.0.0[src]fn enumerate(self) -> Enumerate<Self>
1.0.0[src]fn peekable(self) -> Peekable<Self>
1.0.0[src]fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P> where
P: FnMut(&Self::Item) -> bool,
1.0.0[src]fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P> where
P: FnMut(&Self::Item) -> bool,
1.0.0[src]fn map_while<B, P>(self, predicate: P) -> MapWhile<Self, P> where
P: FnMut(Self::Item) -> Option<B>,
[src]fn skip(self, n: usize) -> Skip<Self>
1.0.0[src]fn take(self, n: usize) -> Take<Self>
1.0.0[src]fn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F> where
F: FnMut(&mut St, Self::Item) -> Option<B>,
1.0.0[src]fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F> where
F: FnMut(Self::Item) -> U,
U: IntoIterator,
1.0.0[src]fn flatten(self) -> Flatten<Self> where
Self::Item: IntoIterator,
1.29.0[src]fn fuse(self) -> Fuse<Self>
1.0.0[src]fn inspect<F>(self, f: F) -> Inspect<Self, F> where
F: FnMut(&Self::Item),
1.0.0[src]fn by_ref(&mut self) -> &mut Self
1.0.0[src]#[must_use =
+ "if you really need to exhaust the iterator, consider `.for_each(drop)` instead"]fn collect<B>(self) -> B where
B: FromIterator<Self::Item>,
1.0.0[src]fn partition<B, F>(self, f: F) -> (B, B) where
B: Default + Extend<Self::Item>,
F: FnMut(&Self::Item) -> bool,
1.0.0[src]fn partition_in_place<'a, T, P>(self, predicate: P) -> usize where
P: FnMut(&T) -> bool,
Self: DoubleEndedIterator<Item = &'a mut T>,
T: 'a,
[src]fn is_partitioned<P>(self, predicate: P) -> bool where
P: FnMut(Self::Item) -> bool,
[src]fn try_fold<B, F, R>(&mut self, init: B, f: F) -> R where
F: FnMut(B, Self::Item) -> R,
R: Try<Ok = B>,
1.27.0[src]fn try_for_each<F, R>(&mut self, f: F) -> R where
F: FnMut(Self::Item) -> R,
R: Try<Ok = ()>,
1.27.0[src]fn fold<B, F>(self, init: B, f: F) -> B where
F: FnMut(B, Self::Item) -> B,
1.0.0[src]fn fold_first<F>(self, f: F) -> Option<Self::Item> where
F: FnMut(Self::Item, Self::Item) -> Self::Item,
[src]fn all<F>(&mut self, f: F) -> bool where
F: FnMut(Self::Item) -> bool,
1.0.0[src]fn any<F>(&mut self, f: F) -> bool where
F: FnMut(Self::Item) -> bool,
1.0.0[src]fn find<P>(&mut self, predicate: P) -> Option<Self::Item> where
P: FnMut(&Self::Item) -> bool,
1.0.0[src]fn find_map<B, F>(&mut self, f: F) -> Option<B> where
F: FnMut(Self::Item) -> Option<B>,
1.30.0[src]fn try_find<F, R>(
&mut self,
f: F
) -> Result<Option<Self::Item>, <R as Try>::Error> where
F: FnMut(&Self::Item) -> R,
R: Try<Ok = bool>,
[src]fn position<P>(&mut self, predicate: P) -> Option<usize> where
P: FnMut(Self::Item) -> bool,
1.0.0[src]fn rposition<P>(&mut self, predicate: P) -> Option<usize> where
P: FnMut(Self::Item) -> bool,
Self: ExactSizeIterator + DoubleEndedIterator,
1.0.0[src]fn max(self) -> Option<Self::Item> where
Self::Item: Ord,
1.0.0[src]fn min(self) -> Option<Self::Item> where
Self::Item: Ord,
1.0.0[src]fn max_by_key<B, F>(self, f: F) -> Option<Self::Item> where
B: Ord,
F: FnMut(&Self::Item) -> B,
1.6.0[src]fn max_by<F>(self, compare: F) -> Option<Self::Item> where
F: FnMut(&Self::Item, &Self::Item) -> Ordering,
1.15.0[src]fn min_by_key<B, F>(self, f: F) -> Option<Self::Item> where
B: Ord,
F: FnMut(&Self::Item) -> B,
1.6.0[src]fn min_by<F>(self, compare: F) -> Option<Self::Item> where
F: FnMut(&Self::Item, &Self::Item) -> Ordering,
1.15.0[src]fn rev(self) -> Rev<Self> where
Self: DoubleEndedIterator,
1.0.0[src]fn unzip<A, B, FromA, FromB>(self) -> (FromA, FromB) where
FromA: Default + Extend<A>,
FromB: Default + Extend<B>,
Self: Iterator<Item = (A, B)>,
1.0.0[src]fn copied<'a, T>(self) -> Copied<Self> where
Self: Iterator<Item = &'a T>,
T: 'a + Copy,
1.36.0[src]fn cloned<'a, T>(self) -> Cloned<Self> where
Self: Iterator<Item = &'a T>,
T: 'a + Clone,
1.0.0[src]fn cycle(self) -> Cycle<Self> where
Self: Clone,
1.0.0[src]fn sum<S>(self) -> S where
S: Sum<Self::Item>,
1.11.0[src]fn product<P>(self) -> P where
P: Product<Self::Item>,
1.11.0[src]fn cmp<I>(self, other: I) -> Ordering where
I: IntoIterator<Item = Self::Item>,
Self::Item: Ord,
1.5.0[src]fn cmp_by<I, F>(self, other: I, cmp: F) -> Ordering where
F: FnMut(Self::Item, <I as IntoIterator>::Item) -> Ordering,
I: IntoIterator,
[src]fn partial_cmp<I>(self, other: I) -> Option<Ordering> where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]fn partial_cmp_by<I, F>(self, other: I, partial_cmp: F) -> Option<Ordering> where
F: FnMut(Self::Item, <I as IntoIterator>::Item) -> Option<Ordering>,
I: IntoIterator,
[src]fn eq<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialEq<<I as IntoIterator>::Item>,
1.5.0[src]fn eq_by<I, F>(self, other: I, eq: F) -> bool where
F: FnMut(Self::Item, <I as IntoIterator>::Item) -> bool,
I: IntoIterator,
[src]fn ne<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialEq<<I as IntoIterator>::Item>,
1.5.0[src]fn lt<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]fn le<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]fn gt<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]fn ge<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]fn is_sorted(self) -> bool where
Self::Item: PartialOrd<Self::Item>,
[src]fn is_sorted_by<F>(self, compare: F) -> bool where
F: FnMut(&Self::Item, &Self::Item) -> Option<Ordering>,
[src]fn is_sorted_by_key<F, K>(self, f: F) -> bool where
F: FnMut(Self::Item) -> K,
K: PartialOrd<K>,
[src]impl !RefUnwindSafe for Ancestors
impl !Send for Ancestors
impl !Sync for Ancestors
impl Unpin for Ancestors
impl !UnwindSafe for Ancestors
impl<T> Any for T where
T: 'static + ?Sized,
[src]impl<T> Borrow<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]impl<T> From<T> for T
[src]impl<T, U> Into<U> for T where
U: From<T>,
[src]impl<I> IntoIterator for I where
I: Iterator,
[src]type Item = <I as Iterator>::Item
The type of the elements being iterated over.
+type IntoIter = I
Which kind of iterator are we turning this into?
+pub fn into_iter(self) -> I
[src]impl<I> NodeIterator for I where
I: Iterator<Item = NodeRef>,
[src]fn elements(self) -> Elements<Self>ⓘNotable traits for Elements<I>
impl<I> Iterator for Elements<I> where
I: Iterator<Item = NodeRef>, type Item = NodeDataRef<ElementData>;
[src]fn text_nodes(self) -> TextNodes<Self>ⓘ
[src]fn comments(self) -> Comments<Self>ⓘ
[src]fn select(self, selectors: &str) -> Result<Select<Elements<Self>>, ()>
[src]impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
The resulting type after obtaining ownership.
+pub fn to_owned(&self) -> T
[src]pub fn clone_into(&self, target: &mut T)
[src]impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]type Error = Infallible
The type returned in the event of a conversion error.
+pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]A node iterator adaptor that yields comment nodes.
+impl<I: Clone> Clone for Comments<I>
[src]impl<I: Debug> Debug for Comments<I>
[src]impl<I> DoubleEndedIterator for Comments<I> where
I: DoubleEndedIterator<Item = NodeRef>,
[src]fn next_back(&mut self) -> Option<NodeDataRef<RefCell<String>>>
[src]fn advance_back_by(&mut self, n: usize) -> Result<(), usize>
[src]fn nth_back(&mut self, n: usize) -> Option<Self::Item>
1.37.0[src]fn try_rfold<B, F, R>(&mut self, init: B, f: F) -> R where
F: FnMut(B, Self::Item) -> R,
R: Try<Ok = B>,
1.27.0[src]fn rfold<B, F>(self, init: B, f: F) -> B where
F: FnMut(B, Self::Item) -> B,
1.27.0[src]fn rfind<P>(&mut self, predicate: P) -> Option<Self::Item> where
P: FnMut(&Self::Item) -> bool,
1.27.0[src]impl<I> Iterator for Comments<I> where
I: Iterator<Item = NodeRef>,
[src]type Item = NodeDataRef<RefCell<String>>
The type of the elements being iterated over.
+fn next(&mut self) -> Option<NodeDataRef<RefCell<String>>>
[src]fn size_hint(&self) -> (usize, Option<usize>)
1.0.0[src]fn count(self) -> usize
1.0.0[src]fn last(self) -> Option<Self::Item>
1.0.0[src]fn advance_by(&mut self, n: usize) -> Result<(), usize>
[src]fn nth(&mut self, n: usize) -> Option<Self::Item>
1.0.0[src]fn step_by(self, step: usize) -> StepBy<Self>
1.28.0[src]fn chain<U>(self, other: U) -> Chain<Self, <U as IntoIterator>::IntoIter> where
U: IntoIterator<Item = Self::Item>,
1.0.0[src]fn zip<U>(self, other: U) -> Zip<Self, <U as IntoIterator>::IntoIter> where
U: IntoIterator,
1.0.0[src]fn map<B, F>(self, f: F) -> Map<Self, F> where
F: FnMut(Self::Item) -> B,
1.0.0[src]fn for_each<F>(self, f: F) where
F: FnMut(Self::Item),
1.21.0[src]fn filter<P>(self, predicate: P) -> Filter<Self, P> where
P: FnMut(&Self::Item) -> bool,
1.0.0[src]fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F> where
F: FnMut(Self::Item) -> Option<B>,
1.0.0[src]fn enumerate(self) -> Enumerate<Self>
1.0.0[src]fn peekable(self) -> Peekable<Self>
1.0.0[src]fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P> where
P: FnMut(&Self::Item) -> bool,
1.0.0[src]fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P> where
P: FnMut(&Self::Item) -> bool,
1.0.0[src]fn map_while<B, P>(self, predicate: P) -> MapWhile<Self, P> where
P: FnMut(Self::Item) -> Option<B>,
[src]fn skip(self, n: usize) -> Skip<Self>
1.0.0[src]fn take(self, n: usize) -> Take<Self>
1.0.0[src]fn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F> where
F: FnMut(&mut St, Self::Item) -> Option<B>,
1.0.0[src]fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F> where
F: FnMut(Self::Item) -> U,
U: IntoIterator,
1.0.0[src]fn flatten(self) -> Flatten<Self> where
Self::Item: IntoIterator,
1.29.0[src]fn fuse(self) -> Fuse<Self>
1.0.0[src]fn inspect<F>(self, f: F) -> Inspect<Self, F> where
F: FnMut(&Self::Item),
1.0.0[src]fn by_ref(&mut self) -> &mut Self
1.0.0[src]#[must_use =
+ "if you really need to exhaust the iterator, consider `.for_each(drop)` instead"]fn collect<B>(self) -> B where
B: FromIterator<Self::Item>,
1.0.0[src]fn partition<B, F>(self, f: F) -> (B, B) where
B: Default + Extend<Self::Item>,
F: FnMut(&Self::Item) -> bool,
1.0.0[src]fn partition_in_place<'a, T, P>(self, predicate: P) -> usize where
P: FnMut(&T) -> bool,
Self: DoubleEndedIterator<Item = &'a mut T>,
T: 'a,
[src]fn is_partitioned<P>(self, predicate: P) -> bool where
P: FnMut(Self::Item) -> bool,
[src]fn try_fold<B, F, R>(&mut self, init: B, f: F) -> R where
F: FnMut(B, Self::Item) -> R,
R: Try<Ok = B>,
1.27.0[src]fn try_for_each<F, R>(&mut self, f: F) -> R where
F: FnMut(Self::Item) -> R,
R: Try<Ok = ()>,
1.27.0[src]fn fold<B, F>(self, init: B, f: F) -> B where
F: FnMut(B, Self::Item) -> B,
1.0.0[src]fn fold_first<F>(self, f: F) -> Option<Self::Item> where
F: FnMut(Self::Item, Self::Item) -> Self::Item,
[src]fn all<F>(&mut self, f: F) -> bool where
F: FnMut(Self::Item) -> bool,
1.0.0[src]fn any<F>(&mut self, f: F) -> bool where
F: FnMut(Self::Item) -> bool,
1.0.0[src]fn find<P>(&mut self, predicate: P) -> Option<Self::Item> where
P: FnMut(&Self::Item) -> bool,
1.0.0[src]fn find_map<B, F>(&mut self, f: F) -> Option<B> where
F: FnMut(Self::Item) -> Option<B>,
1.30.0[src]fn try_find<F, R>(
&mut self,
f: F
) -> Result<Option<Self::Item>, <R as Try>::Error> where
F: FnMut(&Self::Item) -> R,
R: Try<Ok = bool>,
[src]fn position<P>(&mut self, predicate: P) -> Option<usize> where
P: FnMut(Self::Item) -> bool,
1.0.0[src]fn rposition<P>(&mut self, predicate: P) -> Option<usize> where
P: FnMut(Self::Item) -> bool,
Self: ExactSizeIterator + DoubleEndedIterator,
1.0.0[src]fn max(self) -> Option<Self::Item> where
Self::Item: Ord,
1.0.0[src]fn min(self) -> Option<Self::Item> where
Self::Item: Ord,
1.0.0[src]fn max_by_key<B, F>(self, f: F) -> Option<Self::Item> where
B: Ord,
F: FnMut(&Self::Item) -> B,
1.6.0[src]fn max_by<F>(self, compare: F) -> Option<Self::Item> where
F: FnMut(&Self::Item, &Self::Item) -> Ordering,
1.15.0[src]fn min_by_key<B, F>(self, f: F) -> Option<Self::Item> where
B: Ord,
F: FnMut(&Self::Item) -> B,
1.6.0[src]fn min_by<F>(self, compare: F) -> Option<Self::Item> where
F: FnMut(&Self::Item, &Self::Item) -> Ordering,
1.15.0[src]fn rev(self) -> Rev<Self> where
Self: DoubleEndedIterator,
1.0.0[src]fn unzip<A, B, FromA, FromB>(self) -> (FromA, FromB) where
FromA: Default + Extend<A>,
FromB: Default + Extend<B>,
Self: Iterator<Item = (A, B)>,
1.0.0[src]fn copied<'a, T>(self) -> Copied<Self> where
Self: Iterator<Item = &'a T>,
T: 'a + Copy,
1.36.0[src]fn cloned<'a, T>(self) -> Cloned<Self> where
Self: Iterator<Item = &'a T>,
T: 'a + Clone,
1.0.0[src]fn cycle(self) -> Cycle<Self> where
Self: Clone,
1.0.0[src]fn sum<S>(self) -> S where
S: Sum<Self::Item>,
1.11.0[src]fn product<P>(self) -> P where
P: Product<Self::Item>,
1.11.0[src]fn cmp<I>(self, other: I) -> Ordering where
I: IntoIterator<Item = Self::Item>,
Self::Item: Ord,
1.5.0[src]fn cmp_by<I, F>(self, other: I, cmp: F) -> Ordering where
F: FnMut(Self::Item, <I as IntoIterator>::Item) -> Ordering,
I: IntoIterator,
[src]fn partial_cmp<I>(self, other: I) -> Option<Ordering> where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]fn partial_cmp_by<I, F>(self, other: I, partial_cmp: F) -> Option<Ordering> where
F: FnMut(Self::Item, <I as IntoIterator>::Item) -> Option<Ordering>,
I: IntoIterator,
[src]fn eq<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialEq<<I as IntoIterator>::Item>,
1.5.0[src]fn eq_by<I, F>(self, other: I, eq: F) -> bool where
F: FnMut(Self::Item, <I as IntoIterator>::Item) -> bool,
I: IntoIterator,
[src]fn ne<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialEq<<I as IntoIterator>::Item>,
1.5.0[src]fn lt<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]fn le<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]fn gt<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]fn ge<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]fn is_sorted(self) -> bool where
Self::Item: PartialOrd<Self::Item>,
[src]fn is_sorted_by<F>(self, compare: F) -> bool where
F: FnMut(&Self::Item, &Self::Item) -> Option<Ordering>,
[src]fn is_sorted_by_key<F, K>(self, f: F) -> bool where
F: FnMut(Self::Item) -> K,
K: PartialOrd<K>,
[src]impl<I> RefUnwindSafe for Comments<I> where
I: RefUnwindSafe,
impl<I> Send for Comments<I> where
I: Send,
impl<I> Sync for Comments<I> where
I: Sync,
impl<I> Unpin for Comments<I> where
I: Unpin,
impl<I> UnwindSafe for Comments<I> where
I: UnwindSafe,
impl<T> Any for T where
T: 'static + ?Sized,
[src]impl<T> Borrow<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]impl<T> From<T> for T
[src]impl<T, U> Into<U> for T where
U: From<T>,
[src]impl<I> IntoIterator for I where
I: Iterator,
[src]type Item = <I as Iterator>::Item
The type of the elements being iterated over.
+type IntoIter = I
Which kind of iterator are we turning this into?
+pub fn into_iter(self) -> I
[src]impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
The resulting type after obtaining ownership.
+pub fn to_owned(&self) -> T
[src]pub fn clone_into(&self, target: &mut T)
[src]impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]type Error = Infallible
The type returned in the event of a conversion error.
+pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]An iterator of references to a given node and its descendants, in tree order.
+impl Clone for Descendants
[src]fn clone(&self) -> DescendantsⓘNotable traits for Descendants
impl Iterator for Descendants type Item = NodeRef;
[src]fn clone_from(&mut self, source: &Self)
1.0.0[src]impl Debug for Descendants
[src]impl DoubleEndedIterator for Descendants
[src]fn next_back(&mut self) -> Option<NodeRef>
[src]fn advance_back_by(&mut self, n: usize) -> Result<(), usize>
[src]fn nth_back(&mut self, n: usize) -> Option<Self::Item>
1.37.0[src]fn try_rfold<B, F, R>(&mut self, init: B, f: F) -> R where
F: FnMut(B, Self::Item) -> R,
R: Try<Ok = B>,
1.27.0[src]fn rfold<B, F>(self, init: B, f: F) -> B where
F: FnMut(B, Self::Item) -> B,
1.27.0[src]fn rfind<P>(&mut self, predicate: P) -> Option<Self::Item> where
P: FnMut(&Self::Item) -> bool,
1.27.0[src]impl Iterator for Descendants
[src]type Item = NodeRef
The type of the elements being iterated over.
+fn next(&mut self) -> Option<NodeRef>
[src]fn size_hint(&self) -> (usize, Option<usize>)
1.0.0[src]fn count(self) -> usize
1.0.0[src]fn last(self) -> Option<Self::Item>
1.0.0[src]fn advance_by(&mut self, n: usize) -> Result<(), usize>
[src]fn nth(&mut self, n: usize) -> Option<Self::Item>
1.0.0[src]fn step_by(self, step: usize) -> StepBy<Self>
1.28.0[src]fn chain<U>(self, other: U) -> Chain<Self, <U as IntoIterator>::IntoIter> where
U: IntoIterator<Item = Self::Item>,
1.0.0[src]fn zip<U>(self, other: U) -> Zip<Self, <U as IntoIterator>::IntoIter> where
U: IntoIterator,
1.0.0[src]fn map<B, F>(self, f: F) -> Map<Self, F> where
F: FnMut(Self::Item) -> B,
1.0.0[src]fn for_each<F>(self, f: F) where
F: FnMut(Self::Item),
1.21.0[src]fn filter<P>(self, predicate: P) -> Filter<Self, P> where
P: FnMut(&Self::Item) -> bool,
1.0.0[src]fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F> where
F: FnMut(Self::Item) -> Option<B>,
1.0.0[src]fn enumerate(self) -> Enumerate<Self>
1.0.0[src]fn peekable(self) -> Peekable<Self>
1.0.0[src]fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P> where
P: FnMut(&Self::Item) -> bool,
1.0.0[src]fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P> where
P: FnMut(&Self::Item) -> bool,
1.0.0[src]fn map_while<B, P>(self, predicate: P) -> MapWhile<Self, P> where
P: FnMut(Self::Item) -> Option<B>,
[src]fn skip(self, n: usize) -> Skip<Self>
1.0.0[src]fn take(self, n: usize) -> Take<Self>
1.0.0[src]fn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F> where
F: FnMut(&mut St, Self::Item) -> Option<B>,
1.0.0[src]fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F> where
F: FnMut(Self::Item) -> U,
U: IntoIterator,
1.0.0[src]fn flatten(self) -> Flatten<Self> where
Self::Item: IntoIterator,
1.29.0[src]fn fuse(self) -> Fuse<Self>
1.0.0[src]fn inspect<F>(self, f: F) -> Inspect<Self, F> where
F: FnMut(&Self::Item),
1.0.0[src]fn by_ref(&mut self) -> &mut Self
1.0.0[src]#[must_use =
+ "if you really need to exhaust the iterator, consider `.for_each(drop)` instead"]fn collect<B>(self) -> B where
B: FromIterator<Self::Item>,
1.0.0[src]fn partition<B, F>(self, f: F) -> (B, B) where
B: Default + Extend<Self::Item>,
F: FnMut(&Self::Item) -> bool,
1.0.0[src]fn partition_in_place<'a, T, P>(self, predicate: P) -> usize where
P: FnMut(&T) -> bool,
Self: DoubleEndedIterator<Item = &'a mut T>,
T: 'a,
[src]fn is_partitioned<P>(self, predicate: P) -> bool where
P: FnMut(Self::Item) -> bool,
[src]fn try_fold<B, F, R>(&mut self, init: B, f: F) -> R where
F: FnMut(B, Self::Item) -> R,
R: Try<Ok = B>,
1.27.0[src]fn try_for_each<F, R>(&mut self, f: F) -> R where
F: FnMut(Self::Item) -> R,
R: Try<Ok = ()>,
1.27.0[src]fn fold<B, F>(self, init: B, f: F) -> B where
F: FnMut(B, Self::Item) -> B,
1.0.0[src]fn fold_first<F>(self, f: F) -> Option<Self::Item> where
F: FnMut(Self::Item, Self::Item) -> Self::Item,
[src]fn all<F>(&mut self, f: F) -> bool where
F: FnMut(Self::Item) -> bool,
1.0.0[src]fn any<F>(&mut self, f: F) -> bool where
F: FnMut(Self::Item) -> bool,
1.0.0[src]fn find<P>(&mut self, predicate: P) -> Option<Self::Item> where
P: FnMut(&Self::Item) -> bool,
1.0.0[src]fn find_map<B, F>(&mut self, f: F) -> Option<B> where
F: FnMut(Self::Item) -> Option<B>,
1.30.0[src]fn try_find<F, R>(
&mut self,
f: F
) -> Result<Option<Self::Item>, <R as Try>::Error> where
F: FnMut(&Self::Item) -> R,
R: Try<Ok = bool>,
[src]fn position<P>(&mut self, predicate: P) -> Option<usize> where
P: FnMut(Self::Item) -> bool,
1.0.0[src]fn rposition<P>(&mut self, predicate: P) -> Option<usize> where
P: FnMut(Self::Item) -> bool,
Self: ExactSizeIterator + DoubleEndedIterator,
1.0.0[src]fn max(self) -> Option<Self::Item> where
Self::Item: Ord,
1.0.0[src]fn min(self) -> Option<Self::Item> where
Self::Item: Ord,
1.0.0[src]fn max_by_key<B, F>(self, f: F) -> Option<Self::Item> where
B: Ord,
F: FnMut(&Self::Item) -> B,
1.6.0[src]fn max_by<F>(self, compare: F) -> Option<Self::Item> where
F: FnMut(&Self::Item, &Self::Item) -> Ordering,
1.15.0[src]fn min_by_key<B, F>(self, f: F) -> Option<Self::Item> where
B: Ord,
F: FnMut(&Self::Item) -> B,
1.6.0[src]fn min_by<F>(self, compare: F) -> Option<Self::Item> where
F: FnMut(&Self::Item, &Self::Item) -> Ordering,
1.15.0[src]fn rev(self) -> Rev<Self> where
Self: DoubleEndedIterator,
1.0.0[src]fn unzip<A, B, FromA, FromB>(self) -> (FromA, FromB) where
FromA: Default + Extend<A>,
FromB: Default + Extend<B>,
Self: Iterator<Item = (A, B)>,
1.0.0[src]fn copied<'a, T>(self) -> Copied<Self> where
Self: Iterator<Item = &'a T>,
T: 'a + Copy,
1.36.0[src]fn cloned<'a, T>(self) -> Cloned<Self> where
Self: Iterator<Item = &'a T>,
T: 'a + Clone,
1.0.0[src]fn cycle(self) -> Cycle<Self> where
Self: Clone,
1.0.0[src]fn sum<S>(self) -> S where
S: Sum<Self::Item>,
1.11.0[src]fn product<P>(self) -> P where
P: Product<Self::Item>,
1.11.0[src]fn cmp<I>(self, other: I) -> Ordering where
I: IntoIterator<Item = Self::Item>,
Self::Item: Ord,
1.5.0[src]fn cmp_by<I, F>(self, other: I, cmp: F) -> Ordering where
F: FnMut(Self::Item, <I as IntoIterator>::Item) -> Ordering,
I: IntoIterator,
[src]fn partial_cmp<I>(self, other: I) -> Option<Ordering> where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]fn partial_cmp_by<I, F>(self, other: I, partial_cmp: F) -> Option<Ordering> where
F: FnMut(Self::Item, <I as IntoIterator>::Item) -> Option<Ordering>,
I: IntoIterator,
[src]fn eq<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialEq<<I as IntoIterator>::Item>,
1.5.0[src]fn eq_by<I, F>(self, other: I, eq: F) -> bool where
F: FnMut(Self::Item, <I as IntoIterator>::Item) -> bool,
I: IntoIterator,
[src]fn ne<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialEq<<I as IntoIterator>::Item>,
1.5.0[src]fn lt<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]fn le<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]fn gt<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]fn ge<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]fn is_sorted(self) -> bool where
Self::Item: PartialOrd<Self::Item>,
[src]fn is_sorted_by<F>(self, compare: F) -> bool where
F: FnMut(&Self::Item, &Self::Item) -> Option<Ordering>,
[src]fn is_sorted_by_key<F, K>(self, f: F) -> bool where
F: FnMut(Self::Item) -> K,
K: PartialOrd<K>,
[src]impl !RefUnwindSafe for Descendants
impl !Send for Descendants
impl !Sync for Descendants
impl Unpin for Descendants
impl !UnwindSafe for Descendants
impl<T> Any for T where
T: 'static + ?Sized,
[src]impl<T> Borrow<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]impl<T> From<T> for T
[src]impl<T, U> Into<U> for T where
U: From<T>,
[src]impl<I> IntoIterator for I where
I: Iterator,
[src]type Item = <I as Iterator>::Item
The type of the elements being iterated over.
+type IntoIter = I
Which kind of iterator are we turning this into?
+pub fn into_iter(self) -> I
[src]impl<I> NodeIterator for I where
I: Iterator<Item = NodeRef>,
[src]fn elements(self) -> Elements<Self>ⓘNotable traits for Elements<I>
impl<I> Iterator for Elements<I> where
I: Iterator<Item = NodeRef>, type Item = NodeDataRef<ElementData>;
[src]fn text_nodes(self) -> TextNodes<Self>ⓘ
[src]fn comments(self) -> Comments<Self>ⓘ
[src]fn select(self, selectors: &str) -> Result<Select<Elements<Self>>, ()>
[src]impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
The resulting type after obtaining ownership.
+pub fn to_owned(&self) -> T
[src]pub fn clone_into(&self, target: &mut T)
[src]impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]type Error = Infallible
The type returned in the event of a conversion error.
+pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]A node iterator adaptor that yields element nodes.
+impl<I: Clone> Clone for Elements<I>
[src]fn clone(&self) -> Elements<I>ⓘNotable traits for Elements<I>
impl<I> Iterator for Elements<I> where
I: Iterator<Item = NodeRef>, type Item = NodeDataRef<ElementData>;
[src]fn clone_from(&mut self, source: &Self)
1.0.0[src]impl<I: Debug> Debug for Elements<I>
[src]impl<I> DoubleEndedIterator for Elements<I> where
I: DoubleEndedIterator<Item = NodeRef>,
[src]fn next_back(&mut self) -> Option<NodeDataRef<ElementData>>
[src]fn advance_back_by(&mut self, n: usize) -> Result<(), usize>
[src]fn nth_back(&mut self, n: usize) -> Option<Self::Item>
1.37.0[src]fn try_rfold<B, F, R>(&mut self, init: B, f: F) -> R where
F: FnMut(B, Self::Item) -> R,
R: Try<Ok = B>,
1.27.0[src]fn rfold<B, F>(self, init: B, f: F) -> B where
F: FnMut(B, Self::Item) -> B,
1.27.0[src]fn rfind<P>(&mut self, predicate: P) -> Option<Self::Item> where
P: FnMut(&Self::Item) -> bool,
1.27.0[src]impl<I> Iterator for Elements<I> where
I: Iterator<Item = NodeRef>,
[src]type Item = NodeDataRef<ElementData>
The type of the elements being iterated over.
+fn next(&mut self) -> Option<NodeDataRef<ElementData>>
[src]fn size_hint(&self) -> (usize, Option<usize>)
1.0.0[src]fn count(self) -> usize
1.0.0[src]fn last(self) -> Option<Self::Item>
1.0.0[src]fn advance_by(&mut self, n: usize) -> Result<(), usize>
[src]fn nth(&mut self, n: usize) -> Option<Self::Item>
1.0.0[src]fn step_by(self, step: usize) -> StepBy<Self>
1.28.0[src]fn chain<U>(self, other: U) -> Chain<Self, <U as IntoIterator>::IntoIter> where
U: IntoIterator<Item = Self::Item>,
1.0.0[src]fn zip<U>(self, other: U) -> Zip<Self, <U as IntoIterator>::IntoIter> where
U: IntoIterator,
1.0.0[src]fn map<B, F>(self, f: F) -> Map<Self, F> where
F: FnMut(Self::Item) -> B,
1.0.0[src]fn for_each<F>(self, f: F) where
F: FnMut(Self::Item),
1.21.0[src]fn filter<P>(self, predicate: P) -> Filter<Self, P> where
P: FnMut(&Self::Item) -> bool,
1.0.0[src]fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F> where
F: FnMut(Self::Item) -> Option<B>,
1.0.0[src]fn enumerate(self) -> Enumerate<Self>
1.0.0[src]fn peekable(self) -> Peekable<Self>
1.0.0[src]fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P> where
P: FnMut(&Self::Item) -> bool,
1.0.0[src]fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P> where
P: FnMut(&Self::Item) -> bool,
1.0.0[src]fn map_while<B, P>(self, predicate: P) -> MapWhile<Self, P> where
P: FnMut(Self::Item) -> Option<B>,
[src]fn skip(self, n: usize) -> Skip<Self>
1.0.0[src]fn take(self, n: usize) -> Take<Self>
1.0.0[src]fn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F> where
F: FnMut(&mut St, Self::Item) -> Option<B>,
1.0.0[src]fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F> where
F: FnMut(Self::Item) -> U,
U: IntoIterator,
1.0.0[src]fn flatten(self) -> Flatten<Self> where
Self::Item: IntoIterator,
1.29.0[src]fn fuse(self) -> Fuse<Self>
1.0.0[src]fn inspect<F>(self, f: F) -> Inspect<Self, F> where
F: FnMut(&Self::Item),
1.0.0[src]fn by_ref(&mut self) -> &mut Self
1.0.0[src]#[must_use =
+ "if you really need to exhaust the iterator, consider `.for_each(drop)` instead"]fn collect<B>(self) -> B where
B: FromIterator<Self::Item>,
1.0.0[src]fn partition<B, F>(self, f: F) -> (B, B) where
B: Default + Extend<Self::Item>,
F: FnMut(&Self::Item) -> bool,
1.0.0[src]fn partition_in_place<'a, T, P>(self, predicate: P) -> usize where
P: FnMut(&T) -> bool,
Self: DoubleEndedIterator<Item = &'a mut T>,
T: 'a,
[src]fn is_partitioned<P>(self, predicate: P) -> bool where
P: FnMut(Self::Item) -> bool,
[src]fn try_fold<B, F, R>(&mut self, init: B, f: F) -> R where
F: FnMut(B, Self::Item) -> R,
R: Try<Ok = B>,
1.27.0[src]fn try_for_each<F, R>(&mut self, f: F) -> R where
F: FnMut(Self::Item) -> R,
R: Try<Ok = ()>,
1.27.0[src]fn fold<B, F>(self, init: B, f: F) -> B where
F: FnMut(B, Self::Item) -> B,
1.0.0[src]fn fold_first<F>(self, f: F) -> Option<Self::Item> where
F: FnMut(Self::Item, Self::Item) -> Self::Item,
[src]fn all<F>(&mut self, f: F) -> bool where
F: FnMut(Self::Item) -> bool,
1.0.0[src]fn any<F>(&mut self, f: F) -> bool where
F: FnMut(Self::Item) -> bool,
1.0.0[src]fn find<P>(&mut self, predicate: P) -> Option<Self::Item> where
P: FnMut(&Self::Item) -> bool,
1.0.0[src]fn find_map<B, F>(&mut self, f: F) -> Option<B> where
F: FnMut(Self::Item) -> Option<B>,
1.30.0[src]fn try_find<F, R>(
&mut self,
f: F
) -> Result<Option<Self::Item>, <R as Try>::Error> where
F: FnMut(&Self::Item) -> R,
R: Try<Ok = bool>,
[src]fn position<P>(&mut self, predicate: P) -> Option<usize> where
P: FnMut(Self::Item) -> bool,
1.0.0[src]fn rposition<P>(&mut self, predicate: P) -> Option<usize> where
P: FnMut(Self::Item) -> bool,
Self: ExactSizeIterator + DoubleEndedIterator,
1.0.0[src]fn max(self) -> Option<Self::Item> where
Self::Item: Ord,
1.0.0[src]fn min(self) -> Option<Self::Item> where
Self::Item: Ord,
1.0.0[src]fn max_by_key<B, F>(self, f: F) -> Option<Self::Item> where
B: Ord,
F: FnMut(&Self::Item) -> B,
1.6.0[src]fn max_by<F>(self, compare: F) -> Option<Self::Item> where
F: FnMut(&Self::Item, &Self::Item) -> Ordering,
1.15.0[src]fn min_by_key<B, F>(self, f: F) -> Option<Self::Item> where
B: Ord,
F: FnMut(&Self::Item) -> B,
1.6.0[src]fn min_by<F>(self, compare: F) -> Option<Self::Item> where
F: FnMut(&Self::Item, &Self::Item) -> Ordering,
1.15.0[src]fn rev(self) -> Rev<Self> where
Self: DoubleEndedIterator,
1.0.0[src]fn unzip<A, B, FromA, FromB>(self) -> (FromA, FromB) where
FromA: Default + Extend<A>,
FromB: Default + Extend<B>,
Self: Iterator<Item = (A, B)>,
1.0.0[src]fn copied<'a, T>(self) -> Copied<Self> where
Self: Iterator<Item = &'a T>,
T: 'a + Copy,
1.36.0[src]fn cloned<'a, T>(self) -> Cloned<Self> where
Self: Iterator<Item = &'a T>,
T: 'a + Clone,
1.0.0[src]fn cycle(self) -> Cycle<Self> where
Self: Clone,
1.0.0[src]fn sum<S>(self) -> S where
S: Sum<Self::Item>,
1.11.0[src]fn product<P>(self) -> P where
P: Product<Self::Item>,
1.11.0[src]fn cmp<I>(self, other: I) -> Ordering where
I: IntoIterator<Item = Self::Item>,
Self::Item: Ord,
1.5.0[src]fn cmp_by<I, F>(self, other: I, cmp: F) -> Ordering where
F: FnMut(Self::Item, <I as IntoIterator>::Item) -> Ordering,
I: IntoIterator,
[src]fn partial_cmp<I>(self, other: I) -> Option<Ordering> where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]fn partial_cmp_by<I, F>(self, other: I, partial_cmp: F) -> Option<Ordering> where
F: FnMut(Self::Item, <I as IntoIterator>::Item) -> Option<Ordering>,
I: IntoIterator,
[src]fn eq<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialEq<<I as IntoIterator>::Item>,
1.5.0[src]fn eq_by<I, F>(self, other: I, eq: F) -> bool where
F: FnMut(Self::Item, <I as IntoIterator>::Item) -> bool,
I: IntoIterator,
[src]fn ne<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialEq<<I as IntoIterator>::Item>,
1.5.0[src]fn lt<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]fn le<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]fn gt<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]fn ge<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]fn is_sorted(self) -> bool where
Self::Item: PartialOrd<Self::Item>,
[src]fn is_sorted_by<F>(self, compare: F) -> bool where
F: FnMut(&Self::Item, &Self::Item) -> Option<Ordering>,
[src]fn is_sorted_by_key<F, K>(self, f: F) -> bool where
F: FnMut(Self::Item) -> K,
K: PartialOrd<K>,
[src]impl<I> RefUnwindSafe for Elements<I> where
I: RefUnwindSafe,
impl<I> Send for Elements<I> where
I: Send,
impl<I> Sync for Elements<I> where
I: Sync,
impl<I> Unpin for Elements<I> where
I: Unpin,
impl<I> UnwindSafe for Elements<I> where
I: UnwindSafe,
impl<T> Any for T where
T: 'static + ?Sized,
[src]impl<T> Borrow<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]impl<I> ElementIterator for I where
I: Iterator<Item = NodeDataRef<ElementData>>,
[src]impl<T> From<T> for T
[src]impl<T, U> Into<U> for T where
U: From<T>,
[src]impl<I> IntoIterator for I where
I: Iterator,
[src]type Item = <I as Iterator>::Item
The type of the elements being iterated over.
+type IntoIter = I
Which kind of iterator are we turning this into?
+pub fn into_iter(self) -> I
[src]impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
The resulting type after obtaining ownership.
+pub fn to_owned(&self) -> T
[src]pub fn clone_into(&self, target: &mut T)
[src]impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]type Error = Infallible
The type returned in the event of a conversion error.
+pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]An element iterator adaptor that yields elements maching given selectors.
+iter: I
The underlying iterator.
+selectors: S
The selectors to be matched.
+impl<I, S> DoubleEndedIterator for Select<I, S> where
I: DoubleEndedIterator<Item = NodeDataRef<ElementData>>,
S: Borrow<Selectors>,
[src]fn next_back(&mut self) -> Option<NodeDataRef<ElementData>>
[src]fn advance_back_by(&mut self, n: usize) -> Result<(), usize>
[src]fn nth_back(&mut self, n: usize) -> Option<Self::Item>
1.37.0[src]fn try_rfold<B, F, R>(&mut self, init: B, f: F) -> R where
F: FnMut(B, Self::Item) -> R,
R: Try<Ok = B>,
1.27.0[src]fn rfold<B, F>(self, init: B, f: F) -> B where
F: FnMut(B, Self::Item) -> B,
1.27.0[src]fn rfind<P>(&mut self, predicate: P) -> Option<Self::Item> where
P: FnMut(&Self::Item) -> bool,
1.27.0[src]impl<I, S> Iterator for Select<I, S> where
I: Iterator<Item = NodeDataRef<ElementData>>,
S: Borrow<Selectors>,
[src]type Item = NodeDataRef<ElementData>
The type of the elements being iterated over.
+fn next(&mut self) -> Option<NodeDataRef<ElementData>>
[src]fn size_hint(&self) -> (usize, Option<usize>)
1.0.0[src]fn count(self) -> usize
1.0.0[src]fn last(self) -> Option<Self::Item>
1.0.0[src]fn advance_by(&mut self, n: usize) -> Result<(), usize>
[src]fn nth(&mut self, n: usize) -> Option<Self::Item>
1.0.0[src]fn step_by(self, step: usize) -> StepBy<Self>
1.28.0[src]fn chain<U>(self, other: U) -> Chain<Self, <U as IntoIterator>::IntoIter> where
U: IntoIterator<Item = Self::Item>,
1.0.0[src]fn zip<U>(self, other: U) -> Zip<Self, <U as IntoIterator>::IntoIter> where
U: IntoIterator,
1.0.0[src]fn map<B, F>(self, f: F) -> Map<Self, F> where
F: FnMut(Self::Item) -> B,
1.0.0[src]fn for_each<F>(self, f: F) where
F: FnMut(Self::Item),
1.21.0[src]fn filter<P>(self, predicate: P) -> Filter<Self, P> where
P: FnMut(&Self::Item) -> bool,
1.0.0[src]fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F> where
F: FnMut(Self::Item) -> Option<B>,
1.0.0[src]fn enumerate(self) -> Enumerate<Self>
1.0.0[src]fn peekable(self) -> Peekable<Self>
1.0.0[src]fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P> where
P: FnMut(&Self::Item) -> bool,
1.0.0[src]fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P> where
P: FnMut(&Self::Item) -> bool,
1.0.0[src]fn map_while<B, P>(self, predicate: P) -> MapWhile<Self, P> where
P: FnMut(Self::Item) -> Option<B>,
[src]fn skip(self, n: usize) -> Skip<Self>
1.0.0[src]fn take(self, n: usize) -> Take<Self>
1.0.0[src]fn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F> where
F: FnMut(&mut St, Self::Item) -> Option<B>,
1.0.0[src]fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F> where
F: FnMut(Self::Item) -> U,
U: IntoIterator,
1.0.0[src]fn flatten(self) -> Flatten<Self> where
Self::Item: IntoIterator,
1.29.0[src]fn fuse(self) -> Fuse<Self>
1.0.0[src]fn inspect<F>(self, f: F) -> Inspect<Self, F> where
F: FnMut(&Self::Item),
1.0.0[src]fn by_ref(&mut self) -> &mut Self
1.0.0[src]#[must_use =
+ "if you really need to exhaust the iterator, consider `.for_each(drop)` instead"]fn collect<B>(self) -> B where
B: FromIterator<Self::Item>,
1.0.0[src]fn partition<B, F>(self, f: F) -> (B, B) where
B: Default + Extend<Self::Item>,
F: FnMut(&Self::Item) -> bool,
1.0.0[src]fn partition_in_place<'a, T, P>(self, predicate: P) -> usize where
P: FnMut(&T) -> bool,
Self: DoubleEndedIterator<Item = &'a mut T>,
T: 'a,
[src]fn is_partitioned<P>(self, predicate: P) -> bool where
P: FnMut(Self::Item) -> bool,
[src]fn try_fold<B, F, R>(&mut self, init: B, f: F) -> R where
F: FnMut(B, Self::Item) -> R,
R: Try<Ok = B>,
1.27.0[src]fn try_for_each<F, R>(&mut self, f: F) -> R where
F: FnMut(Self::Item) -> R,
R: Try<Ok = ()>,
1.27.0[src]fn fold<B, F>(self, init: B, f: F) -> B where
F: FnMut(B, Self::Item) -> B,
1.0.0[src]fn fold_first<F>(self, f: F) -> Option<Self::Item> where
F: FnMut(Self::Item, Self::Item) -> Self::Item,
[src]fn all<F>(&mut self, f: F) -> bool where
F: FnMut(Self::Item) -> bool,
1.0.0[src]fn any<F>(&mut self, f: F) -> bool where
F: FnMut(Self::Item) -> bool,
1.0.0[src]fn find<P>(&mut self, predicate: P) -> Option<Self::Item> where
P: FnMut(&Self::Item) -> bool,
1.0.0[src]fn find_map<B, F>(&mut self, f: F) -> Option<B> where
F: FnMut(Self::Item) -> Option<B>,
1.30.0[src]fn try_find<F, R>(
&mut self,
f: F
) -> Result<Option<Self::Item>, <R as Try>::Error> where
F: FnMut(&Self::Item) -> R,
R: Try<Ok = bool>,
[src]fn position<P>(&mut self, predicate: P) -> Option<usize> where
P: FnMut(Self::Item) -> bool,
1.0.0[src]fn rposition<P>(&mut self, predicate: P) -> Option<usize> where
P: FnMut(Self::Item) -> bool,
Self: ExactSizeIterator + DoubleEndedIterator,
1.0.0[src]fn max(self) -> Option<Self::Item> where
Self::Item: Ord,
1.0.0[src]fn min(self) -> Option<Self::Item> where
Self::Item: Ord,
1.0.0[src]fn max_by_key<B, F>(self, f: F) -> Option<Self::Item> where
B: Ord,
F: FnMut(&Self::Item) -> B,
1.6.0[src]fn max_by<F>(self, compare: F) -> Option<Self::Item> where
F: FnMut(&Self::Item, &Self::Item) -> Ordering,
1.15.0[src]fn min_by_key<B, F>(self, f: F) -> Option<Self::Item> where
B: Ord,
F: FnMut(&Self::Item) -> B,
1.6.0[src]fn min_by<F>(self, compare: F) -> Option<Self::Item> where
F: FnMut(&Self::Item, &Self::Item) -> Ordering,
1.15.0[src]fn rev(self) -> Rev<Self> where
Self: DoubleEndedIterator,
1.0.0[src]fn unzip<A, B, FromA, FromB>(self) -> (FromA, FromB) where
FromA: Default + Extend<A>,
FromB: Default + Extend<B>,
Self: Iterator<Item = (A, B)>,
1.0.0[src]fn copied<'a, T>(self) -> Copied<Self> where
Self: Iterator<Item = &'a T>,
T: 'a + Copy,
1.36.0[src]fn cloned<'a, T>(self) -> Cloned<Self> where
Self: Iterator<Item = &'a T>,
T: 'a + Clone,
1.0.0[src]fn cycle(self) -> Cycle<Self> where
Self: Clone,
1.0.0[src]fn sum<S>(self) -> S where
S: Sum<Self::Item>,
1.11.0[src]fn product<P>(self) -> P where
P: Product<Self::Item>,
1.11.0[src]fn cmp<I>(self, other: I) -> Ordering where
I: IntoIterator<Item = Self::Item>,
Self::Item: Ord,
1.5.0[src]fn cmp_by<I, F>(self, other: I, cmp: F) -> Ordering where
F: FnMut(Self::Item, <I as IntoIterator>::Item) -> Ordering,
I: IntoIterator,
[src]fn partial_cmp<I>(self, other: I) -> Option<Ordering> where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]fn partial_cmp_by<I, F>(self, other: I, partial_cmp: F) -> Option<Ordering> where
F: FnMut(Self::Item, <I as IntoIterator>::Item) -> Option<Ordering>,
I: IntoIterator,
[src]fn eq<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialEq<<I as IntoIterator>::Item>,
1.5.0[src]fn eq_by<I, F>(self, other: I, eq: F) -> bool where
F: FnMut(Self::Item, <I as IntoIterator>::Item) -> bool,
I: IntoIterator,
[src]fn ne<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialEq<<I as IntoIterator>::Item>,
1.5.0[src]fn lt<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]fn le<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]fn gt<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]fn ge<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]fn is_sorted(self) -> bool where
Self::Item: PartialOrd<Self::Item>,
[src]fn is_sorted_by<F>(self, compare: F) -> bool where
F: FnMut(&Self::Item, &Self::Item) -> Option<Ordering>,
[src]fn is_sorted_by_key<F, K>(self, f: F) -> bool where
F: FnMut(Self::Item) -> K,
K: PartialOrd<K>,
[src]impl<I, S> RefUnwindSafe for Select<I, S> where
I: RefUnwindSafe,
S: RefUnwindSafe,
impl<I, S> Send for Select<I, S> where
I: Send,
S: Send,
impl<I, S> Sync for Select<I, S> where
I: Sync,
S: Sync,
impl<I, S> Unpin for Select<I, S> where
I: Unpin,
S: Unpin,
impl<I, S> UnwindSafe for Select<I, S> where
I: UnwindSafe,
S: UnwindSafe,
impl<T> Any for T where
T: 'static + ?Sized,
[src]impl<T> Borrow<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]impl<I> ElementIterator for I where
I: Iterator<Item = NodeDataRef<ElementData>>,
[src]impl<T> From<T> for T
[src]impl<T, U> Into<U> for T where
U: From<T>,
[src]impl<I> IntoIterator for I where
I: Iterator,
[src]type Item = <I as Iterator>::Item
The type of the elements being iterated over.
+type IntoIter = I
Which kind of iterator are we turning this into?
+pub fn into_iter(self) -> I
[src]impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]type Error = Infallible
The type returned in the event of a conversion error.
+pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]A double-ended iterator of sibling nodes.
+impl Clone for Siblings
[src]impl Debug for Siblings
[src]impl DoubleEndedIterator for Siblings
[src]fn next_back(&mut self) -> Option<NodeRef>
[src]fn advance_back_by(&mut self, n: usize) -> Result<(), usize>
[src]fn nth_back(&mut self, n: usize) -> Option<Self::Item>
1.37.0[src]fn try_rfold<B, F, R>(&mut self, init: B, f: F) -> R where
F: FnMut(B, Self::Item) -> R,
R: Try<Ok = B>,
1.27.0[src]fn rfold<B, F>(self, init: B, f: F) -> B where
F: FnMut(B, Self::Item) -> B,
1.27.0[src]fn rfind<P>(&mut self, predicate: P) -> Option<Self::Item> where
P: FnMut(&Self::Item) -> bool,
1.27.0[src]impl Iterator for Siblings
[src]type Item = NodeRef
The type of the elements being iterated over.
+fn next(&mut self) -> Option<NodeRef>
[src]fn size_hint(&self) -> (usize, Option<usize>)
1.0.0[src]fn count(self) -> usize
1.0.0[src]fn last(self) -> Option<Self::Item>
1.0.0[src]fn advance_by(&mut self, n: usize) -> Result<(), usize>
[src]fn nth(&mut self, n: usize) -> Option<Self::Item>
1.0.0[src]fn step_by(self, step: usize) -> StepBy<Self>
1.28.0[src]fn chain<U>(self, other: U) -> Chain<Self, <U as IntoIterator>::IntoIter> where
U: IntoIterator<Item = Self::Item>,
1.0.0[src]fn zip<U>(self, other: U) -> Zip<Self, <U as IntoIterator>::IntoIter> where
U: IntoIterator,
1.0.0[src]fn map<B, F>(self, f: F) -> Map<Self, F> where
F: FnMut(Self::Item) -> B,
1.0.0[src]fn for_each<F>(self, f: F) where
F: FnMut(Self::Item),
1.21.0[src]fn filter<P>(self, predicate: P) -> Filter<Self, P> where
P: FnMut(&Self::Item) -> bool,
1.0.0[src]fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F> where
F: FnMut(Self::Item) -> Option<B>,
1.0.0[src]fn enumerate(self) -> Enumerate<Self>
1.0.0[src]fn peekable(self) -> Peekable<Self>
1.0.0[src]fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P> where
P: FnMut(&Self::Item) -> bool,
1.0.0[src]fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P> where
P: FnMut(&Self::Item) -> bool,
1.0.0[src]fn map_while<B, P>(self, predicate: P) -> MapWhile<Self, P> where
P: FnMut(Self::Item) -> Option<B>,
[src]fn skip(self, n: usize) -> Skip<Self>
1.0.0[src]fn take(self, n: usize) -> Take<Self>
1.0.0[src]fn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F> where
F: FnMut(&mut St, Self::Item) -> Option<B>,
1.0.0[src]fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F> where
F: FnMut(Self::Item) -> U,
U: IntoIterator,
1.0.0[src]fn flatten(self) -> Flatten<Self> where
Self::Item: IntoIterator,
1.29.0[src]fn fuse(self) -> Fuse<Self>
1.0.0[src]fn inspect<F>(self, f: F) -> Inspect<Self, F> where
F: FnMut(&Self::Item),
1.0.0[src]fn by_ref(&mut self) -> &mut Self
1.0.0[src]#[must_use =
+ "if you really need to exhaust the iterator, consider `.for_each(drop)` instead"]fn collect<B>(self) -> B where
B: FromIterator<Self::Item>,
1.0.0[src]fn partition<B, F>(self, f: F) -> (B, B) where
B: Default + Extend<Self::Item>,
F: FnMut(&Self::Item) -> bool,
1.0.0[src]fn partition_in_place<'a, T, P>(self, predicate: P) -> usize where
P: FnMut(&T) -> bool,
Self: DoubleEndedIterator<Item = &'a mut T>,
T: 'a,
[src]fn is_partitioned<P>(self, predicate: P) -> bool where
P: FnMut(Self::Item) -> bool,
[src]fn try_fold<B, F, R>(&mut self, init: B, f: F) -> R where
F: FnMut(B, Self::Item) -> R,
R: Try<Ok = B>,
1.27.0[src]fn try_for_each<F, R>(&mut self, f: F) -> R where
F: FnMut(Self::Item) -> R,
R: Try<Ok = ()>,
1.27.0[src]fn fold<B, F>(self, init: B, f: F) -> B where
F: FnMut(B, Self::Item) -> B,
1.0.0[src]fn fold_first<F>(self, f: F) -> Option<Self::Item> where
F: FnMut(Self::Item, Self::Item) -> Self::Item,
[src]fn all<F>(&mut self, f: F) -> bool where
F: FnMut(Self::Item) -> bool,
1.0.0[src]fn any<F>(&mut self, f: F) -> bool where
F: FnMut(Self::Item) -> bool,
1.0.0[src]fn find<P>(&mut self, predicate: P) -> Option<Self::Item> where
P: FnMut(&Self::Item) -> bool,
1.0.0[src]fn find_map<B, F>(&mut self, f: F) -> Option<B> where
F: FnMut(Self::Item) -> Option<B>,
1.30.0[src]fn try_find<F, R>(
&mut self,
f: F
) -> Result<Option<Self::Item>, <R as Try>::Error> where
F: FnMut(&Self::Item) -> R,
R: Try<Ok = bool>,
[src]fn position<P>(&mut self, predicate: P) -> Option<usize> where
P: FnMut(Self::Item) -> bool,
1.0.0[src]fn rposition<P>(&mut self, predicate: P) -> Option<usize> where
P: FnMut(Self::Item) -> bool,
Self: ExactSizeIterator + DoubleEndedIterator,
1.0.0[src]fn max(self) -> Option<Self::Item> where
Self::Item: Ord,
1.0.0[src]fn min(self) -> Option<Self::Item> where
Self::Item: Ord,
1.0.0[src]fn max_by_key<B, F>(self, f: F) -> Option<Self::Item> where
B: Ord,
F: FnMut(&Self::Item) -> B,
1.6.0[src]fn max_by<F>(self, compare: F) -> Option<Self::Item> where
F: FnMut(&Self::Item, &Self::Item) -> Ordering,
1.15.0[src]fn min_by_key<B, F>(self, f: F) -> Option<Self::Item> where
B: Ord,
F: FnMut(&Self::Item) -> B,
1.6.0[src]fn min_by<F>(self, compare: F) -> Option<Self::Item> where
F: FnMut(&Self::Item, &Self::Item) -> Ordering,
1.15.0[src]fn rev(self) -> Rev<Self> where
Self: DoubleEndedIterator,
1.0.0[src]fn unzip<A, B, FromA, FromB>(self) -> (FromA, FromB) where
FromA: Default + Extend<A>,
FromB: Default + Extend<B>,
Self: Iterator<Item = (A, B)>,
1.0.0[src]fn copied<'a, T>(self) -> Copied<Self> where
Self: Iterator<Item = &'a T>,
T: 'a + Copy,
1.36.0[src]fn cloned<'a, T>(self) -> Cloned<Self> where
Self: Iterator<Item = &'a T>,
T: 'a + Clone,
1.0.0[src]fn cycle(self) -> Cycle<Self> where
Self: Clone,
1.0.0[src]fn sum<S>(self) -> S where
S: Sum<Self::Item>,
1.11.0[src]fn product<P>(self) -> P where
P: Product<Self::Item>,
1.11.0[src]fn cmp<I>(self, other: I) -> Ordering where
I: IntoIterator<Item = Self::Item>,
Self::Item: Ord,
1.5.0[src]fn cmp_by<I, F>(self, other: I, cmp: F) -> Ordering where
F: FnMut(Self::Item, <I as IntoIterator>::Item) -> Ordering,
I: IntoIterator,
[src]fn partial_cmp<I>(self, other: I) -> Option<Ordering> where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]fn partial_cmp_by<I, F>(self, other: I, partial_cmp: F) -> Option<Ordering> where
F: FnMut(Self::Item, <I as IntoIterator>::Item) -> Option<Ordering>,
I: IntoIterator,
[src]fn eq<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialEq<<I as IntoIterator>::Item>,
1.5.0[src]fn eq_by<I, F>(self, other: I, eq: F) -> bool where
F: FnMut(Self::Item, <I as IntoIterator>::Item) -> bool,
I: IntoIterator,
[src]fn ne<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialEq<<I as IntoIterator>::Item>,
1.5.0[src]fn lt<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]fn le<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]fn gt<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]fn ge<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]fn is_sorted(self) -> bool where
Self::Item: PartialOrd<Self::Item>,
[src]fn is_sorted_by<F>(self, compare: F) -> bool where
F: FnMut(&Self::Item, &Self::Item) -> Option<Ordering>,
[src]fn is_sorted_by_key<F, K>(self, f: F) -> bool where
F: FnMut(Self::Item) -> K,
K: PartialOrd<K>,
[src]impl !RefUnwindSafe for Siblings
impl !Send for Siblings
impl !Sync for Siblings
impl Unpin for Siblings
impl !UnwindSafe for Siblings
impl<T> Any for T where
T: 'static + ?Sized,
[src]impl<T> Borrow<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]impl<T> From<T> for T
[src]impl<T, U> Into<U> for T where
U: From<T>,
[src]impl<I> IntoIterator for I where
I: Iterator,
[src]type Item = <I as Iterator>::Item
The type of the elements being iterated over.
+type IntoIter = I
Which kind of iterator are we turning this into?
+pub fn into_iter(self) -> I
[src]impl<I> NodeIterator for I where
I: Iterator<Item = NodeRef>,
[src]fn elements(self) -> Elements<Self>ⓘNotable traits for Elements<I>
impl<I> Iterator for Elements<I> where
I: Iterator<Item = NodeRef>, type Item = NodeDataRef<ElementData>;
[src]fn text_nodes(self) -> TextNodes<Self>ⓘ
[src]fn comments(self) -> Comments<Self>ⓘ
[src]fn select(self, selectors: &str) -> Result<Select<Elements<Self>>, ()>
[src]impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
The resulting type after obtaining ownership.
+pub fn to_owned(&self) -> T
[src]pub fn clone_into(&self, target: &mut T)
[src]impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]type Error = Infallible
The type returned in the event of a conversion error.
+pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]A node iterator adaptor that yields text nodes.
+impl<I: Clone> Clone for TextNodes<I>
[src]impl<I: Debug> Debug for TextNodes<I>
[src]impl<I> DoubleEndedIterator for TextNodes<I> where
I: DoubleEndedIterator<Item = NodeRef>,
[src]fn next_back(&mut self) -> Option<NodeDataRef<RefCell<String>>>
[src]fn advance_back_by(&mut self, n: usize) -> Result<(), usize>
[src]fn nth_back(&mut self, n: usize) -> Option<Self::Item>
1.37.0[src]fn try_rfold<B, F, R>(&mut self, init: B, f: F) -> R where
F: FnMut(B, Self::Item) -> R,
R: Try<Ok = B>,
1.27.0[src]fn rfold<B, F>(self, init: B, f: F) -> B where
F: FnMut(B, Self::Item) -> B,
1.27.0[src]fn rfind<P>(&mut self, predicate: P) -> Option<Self::Item> where
P: FnMut(&Self::Item) -> bool,
1.27.0[src]impl<I> Iterator for TextNodes<I> where
I: Iterator<Item = NodeRef>,
[src]type Item = NodeDataRef<RefCell<String>>
The type of the elements being iterated over.
+fn next(&mut self) -> Option<NodeDataRef<RefCell<String>>>
[src]fn size_hint(&self) -> (usize, Option<usize>)
1.0.0[src]fn count(self) -> usize
1.0.0[src]fn last(self) -> Option<Self::Item>
1.0.0[src]fn advance_by(&mut self, n: usize) -> Result<(), usize>
[src]fn nth(&mut self, n: usize) -> Option<Self::Item>
1.0.0[src]fn step_by(self, step: usize) -> StepBy<Self>
1.28.0[src]fn chain<U>(self, other: U) -> Chain<Self, <U as IntoIterator>::IntoIter> where
U: IntoIterator<Item = Self::Item>,
1.0.0[src]fn zip<U>(self, other: U) -> Zip<Self, <U as IntoIterator>::IntoIter> where
U: IntoIterator,
1.0.0[src]fn map<B, F>(self, f: F) -> Map<Self, F> where
F: FnMut(Self::Item) -> B,
1.0.0[src]fn for_each<F>(self, f: F) where
F: FnMut(Self::Item),
1.21.0[src]fn filter<P>(self, predicate: P) -> Filter<Self, P> where
P: FnMut(&Self::Item) -> bool,
1.0.0[src]fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F> where
F: FnMut(Self::Item) -> Option<B>,
1.0.0[src]fn enumerate(self) -> Enumerate<Self>
1.0.0[src]fn peekable(self) -> Peekable<Self>
1.0.0[src]fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P> where
P: FnMut(&Self::Item) -> bool,
1.0.0[src]fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P> where
P: FnMut(&Self::Item) -> bool,
1.0.0[src]fn map_while<B, P>(self, predicate: P) -> MapWhile<Self, P> where
P: FnMut(Self::Item) -> Option<B>,
[src]fn skip(self, n: usize) -> Skip<Self>
1.0.0[src]fn take(self, n: usize) -> Take<Self>
1.0.0[src]fn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F> where
F: FnMut(&mut St, Self::Item) -> Option<B>,
1.0.0[src]fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F> where
F: FnMut(Self::Item) -> U,
U: IntoIterator,
1.0.0[src]fn flatten(self) -> Flatten<Self> where
Self::Item: IntoIterator,
1.29.0[src]fn fuse(self) -> Fuse<Self>
1.0.0[src]fn inspect<F>(self, f: F) -> Inspect<Self, F> where
F: FnMut(&Self::Item),
1.0.0[src]fn by_ref(&mut self) -> &mut Self
1.0.0[src]#[must_use =
+ "if you really need to exhaust the iterator, consider `.for_each(drop)` instead"]fn collect<B>(self) -> B where
B: FromIterator<Self::Item>,
1.0.0[src]fn partition<B, F>(self, f: F) -> (B, B) where
B: Default + Extend<Self::Item>,
F: FnMut(&Self::Item) -> bool,
1.0.0[src]fn partition_in_place<'a, T, P>(self, predicate: P) -> usize where
P: FnMut(&T) -> bool,
Self: DoubleEndedIterator<Item = &'a mut T>,
T: 'a,
[src]fn is_partitioned<P>(self, predicate: P) -> bool where
P: FnMut(Self::Item) -> bool,
[src]fn try_fold<B, F, R>(&mut self, init: B, f: F) -> R where
F: FnMut(B, Self::Item) -> R,
R: Try<Ok = B>,
1.27.0[src]fn try_for_each<F, R>(&mut self, f: F) -> R where
F: FnMut(Self::Item) -> R,
R: Try<Ok = ()>,
1.27.0[src]fn fold<B, F>(self, init: B, f: F) -> B where
F: FnMut(B, Self::Item) -> B,
1.0.0[src]fn fold_first<F>(self, f: F) -> Option<Self::Item> where
F: FnMut(Self::Item, Self::Item) -> Self::Item,
[src]fn all<F>(&mut self, f: F) -> bool where
F: FnMut(Self::Item) -> bool,
1.0.0[src]fn any<F>(&mut self, f: F) -> bool where
F: FnMut(Self::Item) -> bool,
1.0.0[src]fn find<P>(&mut self, predicate: P) -> Option<Self::Item> where
P: FnMut(&Self::Item) -> bool,
1.0.0[src]fn find_map<B, F>(&mut self, f: F) -> Option<B> where
F: FnMut(Self::Item) -> Option<B>,
1.30.0[src]fn try_find<F, R>(
&mut self,
f: F
) -> Result<Option<Self::Item>, <R as Try>::Error> where
F: FnMut(&Self::Item) -> R,
R: Try<Ok = bool>,
[src]fn position<P>(&mut self, predicate: P) -> Option<usize> where
P: FnMut(Self::Item) -> bool,
1.0.0[src]fn rposition<P>(&mut self, predicate: P) -> Option<usize> where
P: FnMut(Self::Item) -> bool,
Self: ExactSizeIterator + DoubleEndedIterator,
1.0.0[src]fn max(self) -> Option<Self::Item> where
Self::Item: Ord,
1.0.0[src]fn min(self) -> Option<Self::Item> where
Self::Item: Ord,
1.0.0[src]fn max_by_key<B, F>(self, f: F) -> Option<Self::Item> where
B: Ord,
F: FnMut(&Self::Item) -> B,
1.6.0[src]fn max_by<F>(self, compare: F) -> Option<Self::Item> where
F: FnMut(&Self::Item, &Self::Item) -> Ordering,
1.15.0[src]fn min_by_key<B, F>(self, f: F) -> Option<Self::Item> where
B: Ord,
F: FnMut(&Self::Item) -> B,
1.6.0[src]fn min_by<F>(self, compare: F) -> Option<Self::Item> where
F: FnMut(&Self::Item, &Self::Item) -> Ordering,
1.15.0[src]fn rev(self) -> Rev<Self> where
Self: DoubleEndedIterator,
1.0.0[src]fn unzip<A, B, FromA, FromB>(self) -> (FromA, FromB) where
FromA: Default + Extend<A>,
FromB: Default + Extend<B>,
Self: Iterator<Item = (A, B)>,
1.0.0[src]fn copied<'a, T>(self) -> Copied<Self> where
Self: Iterator<Item = &'a T>,
T: 'a + Copy,
1.36.0[src]fn cloned<'a, T>(self) -> Cloned<Self> where
Self: Iterator<Item = &'a T>,
T: 'a + Clone,
1.0.0[src]fn cycle(self) -> Cycle<Self> where
Self: Clone,
1.0.0[src]fn sum<S>(self) -> S where
S: Sum<Self::Item>,
1.11.0[src]fn product<P>(self) -> P where
P: Product<Self::Item>,
1.11.0[src]fn cmp<I>(self, other: I) -> Ordering where
I: IntoIterator<Item = Self::Item>,
Self::Item: Ord,
1.5.0[src]fn cmp_by<I, F>(self, other: I, cmp: F) -> Ordering where
F: FnMut(Self::Item, <I as IntoIterator>::Item) -> Ordering,
I: IntoIterator,
[src]fn partial_cmp<I>(self, other: I) -> Option<Ordering> where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]fn partial_cmp_by<I, F>(self, other: I, partial_cmp: F) -> Option<Ordering> where
F: FnMut(Self::Item, <I as IntoIterator>::Item) -> Option<Ordering>,
I: IntoIterator,
[src]fn eq<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialEq<<I as IntoIterator>::Item>,
1.5.0[src]fn eq_by<I, F>(self, other: I, eq: F) -> bool where
F: FnMut(Self::Item, <I as IntoIterator>::Item) -> bool,
I: IntoIterator,
[src]fn ne<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialEq<<I as IntoIterator>::Item>,
1.5.0[src]fn lt<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]fn le<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]fn gt<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]fn ge<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]fn is_sorted(self) -> bool where
Self::Item: PartialOrd<Self::Item>,
[src]fn is_sorted_by<F>(self, compare: F) -> bool where
F: FnMut(&Self::Item, &Self::Item) -> Option<Ordering>,
[src]fn is_sorted_by_key<F, K>(self, f: F) -> bool where
F: FnMut(Self::Item) -> K,
K: PartialOrd<K>,
[src]impl<I> RefUnwindSafe for TextNodes<I> where
I: RefUnwindSafe,
impl<I> Send for TextNodes<I> where
I: Send,
impl<I> Sync for TextNodes<I> where
I: Sync,
impl<I> Unpin for TextNodes<I> where
I: Unpin,
impl<I> UnwindSafe for TextNodes<I> where
I: UnwindSafe,
impl<T> Any for T where
T: 'static + ?Sized,
[src]impl<T> Borrow<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]impl<T> From<T> for T
[src]impl<T, U> Into<U> for T where
U: From<T>,
[src]impl<I> IntoIterator for I where
I: Iterator,
[src]type Item = <I as Iterator>::Item
The type of the elements being iterated over.
+type IntoIter = I
Which kind of iterator are we turning this into?
+pub fn into_iter(self) -> I
[src]impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
The resulting type after obtaining ownership.
+pub fn to_owned(&self) -> T
[src]pub fn clone_into(&self, target: &mut T)
[src]impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]type Error = Infallible
The type returned in the event of a conversion error.
+pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]An iterator of the start and end edges of the nodes in a given subtree.
+impl Clone for Traverse
[src]impl Debug for Traverse
[src]impl DoubleEndedIterator for Traverse
[src]fn next_back(&mut self) -> Option<NodeEdge<NodeRef>>
[src]fn advance_back_by(&mut self, n: usize) -> Result<(), usize>
[src]fn nth_back(&mut self, n: usize) -> Option<Self::Item>
1.37.0[src]fn try_rfold<B, F, R>(&mut self, init: B, f: F) -> R where
F: FnMut(B, Self::Item) -> R,
R: Try<Ok = B>,
1.27.0[src]fn rfold<B, F>(self, init: B, f: F) -> B where
F: FnMut(B, Self::Item) -> B,
1.27.0[src]fn rfind<P>(&mut self, predicate: P) -> Option<Self::Item> where
P: FnMut(&Self::Item) -> bool,
1.27.0[src]impl Iterator for Traverse
[src]type Item = NodeEdge<NodeRef>
The type of the elements being iterated over.
+fn next(&mut self) -> Option<NodeEdge<NodeRef>>
[src]fn size_hint(&self) -> (usize, Option<usize>)
1.0.0[src]fn count(self) -> usize
1.0.0[src]fn last(self) -> Option<Self::Item>
1.0.0[src]fn advance_by(&mut self, n: usize) -> Result<(), usize>
[src]fn nth(&mut self, n: usize) -> Option<Self::Item>
1.0.0[src]fn step_by(self, step: usize) -> StepBy<Self>
1.28.0[src]fn chain<U>(self, other: U) -> Chain<Self, <U as IntoIterator>::IntoIter> where
U: IntoIterator<Item = Self::Item>,
1.0.0[src]fn zip<U>(self, other: U) -> Zip<Self, <U as IntoIterator>::IntoIter> where
U: IntoIterator,
1.0.0[src]fn map<B, F>(self, f: F) -> Map<Self, F> where
F: FnMut(Self::Item) -> B,
1.0.0[src]fn for_each<F>(self, f: F) where
F: FnMut(Self::Item),
1.21.0[src]fn filter<P>(self, predicate: P) -> Filter<Self, P> where
P: FnMut(&Self::Item) -> bool,
1.0.0[src]fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F> where
F: FnMut(Self::Item) -> Option<B>,
1.0.0[src]fn enumerate(self) -> Enumerate<Self>
1.0.0[src]fn peekable(self) -> Peekable<Self>
1.0.0[src]fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P> where
P: FnMut(&Self::Item) -> bool,
1.0.0[src]fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P> where
P: FnMut(&Self::Item) -> bool,
1.0.0[src]fn map_while<B, P>(self, predicate: P) -> MapWhile<Self, P> where
P: FnMut(Self::Item) -> Option<B>,
[src]fn skip(self, n: usize) -> Skip<Self>
1.0.0[src]fn take(self, n: usize) -> Take<Self>
1.0.0[src]fn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F> where
F: FnMut(&mut St, Self::Item) -> Option<B>,
1.0.0[src]fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F> where
F: FnMut(Self::Item) -> U,
U: IntoIterator,
1.0.0[src]fn flatten(self) -> Flatten<Self> where
Self::Item: IntoIterator,
1.29.0[src]fn fuse(self) -> Fuse<Self>
1.0.0[src]fn inspect<F>(self, f: F) -> Inspect<Self, F> where
F: FnMut(&Self::Item),
1.0.0[src]fn by_ref(&mut self) -> &mut Self
1.0.0[src]#[must_use =
+ "if you really need to exhaust the iterator, consider `.for_each(drop)` instead"]fn collect<B>(self) -> B where
B: FromIterator<Self::Item>,
1.0.0[src]fn partition<B, F>(self, f: F) -> (B, B) where
B: Default + Extend<Self::Item>,
F: FnMut(&Self::Item) -> bool,
1.0.0[src]fn partition_in_place<'a, T, P>(self, predicate: P) -> usize where
P: FnMut(&T) -> bool,
Self: DoubleEndedIterator<Item = &'a mut T>,
T: 'a,
[src]fn is_partitioned<P>(self, predicate: P) -> bool where
P: FnMut(Self::Item) -> bool,
[src]fn try_fold<B, F, R>(&mut self, init: B, f: F) -> R where
F: FnMut(B, Self::Item) -> R,
R: Try<Ok = B>,
1.27.0[src]fn try_for_each<F, R>(&mut self, f: F) -> R where
F: FnMut(Self::Item) -> R,
R: Try<Ok = ()>,
1.27.0[src]fn fold<B, F>(self, init: B, f: F) -> B where
F: FnMut(B, Self::Item) -> B,
1.0.0[src]fn fold_first<F>(self, f: F) -> Option<Self::Item> where
F: FnMut(Self::Item, Self::Item) -> Self::Item,
[src]fn all<F>(&mut self, f: F) -> bool where
F: FnMut(Self::Item) -> bool,
1.0.0[src]fn any<F>(&mut self, f: F) -> bool where
F: FnMut(Self::Item) -> bool,
1.0.0[src]fn find<P>(&mut self, predicate: P) -> Option<Self::Item> where
P: FnMut(&Self::Item) -> bool,
1.0.0[src]fn find_map<B, F>(&mut self, f: F) -> Option<B> where
F: FnMut(Self::Item) -> Option<B>,
1.30.0[src]fn try_find<F, R>(
&mut self,
f: F
) -> Result<Option<Self::Item>, <R as Try>::Error> where
F: FnMut(&Self::Item) -> R,
R: Try<Ok = bool>,
[src]fn position<P>(&mut self, predicate: P) -> Option<usize> where
P: FnMut(Self::Item) -> bool,
1.0.0[src]fn rposition<P>(&mut self, predicate: P) -> Option<usize> where
P: FnMut(Self::Item) -> bool,
Self: ExactSizeIterator + DoubleEndedIterator,
1.0.0[src]fn max(self) -> Option<Self::Item> where
Self::Item: Ord,
1.0.0[src]fn min(self) -> Option<Self::Item> where
Self::Item: Ord,
1.0.0[src]fn max_by_key<B, F>(self, f: F) -> Option<Self::Item> where
B: Ord,
F: FnMut(&Self::Item) -> B,
1.6.0[src]fn max_by<F>(self, compare: F) -> Option<Self::Item> where
F: FnMut(&Self::Item, &Self::Item) -> Ordering,
1.15.0[src]fn min_by_key<B, F>(self, f: F) -> Option<Self::Item> where
B: Ord,
F: FnMut(&Self::Item) -> B,
1.6.0[src]fn min_by<F>(self, compare: F) -> Option<Self::Item> where
F: FnMut(&Self::Item, &Self::Item) -> Ordering,
1.15.0[src]fn rev(self) -> Rev<Self> where
Self: DoubleEndedIterator,
1.0.0[src]fn unzip<A, B, FromA, FromB>(self) -> (FromA, FromB) where
FromA: Default + Extend<A>,
FromB: Default + Extend<B>,
Self: Iterator<Item = (A, B)>,
1.0.0[src]fn copied<'a, T>(self) -> Copied<Self> where
Self: Iterator<Item = &'a T>,
T: 'a + Copy,
1.36.0[src]fn cloned<'a, T>(self) -> Cloned<Self> where
Self: Iterator<Item = &'a T>,
T: 'a + Clone,
1.0.0[src]fn cycle(self) -> Cycle<Self> where
Self: Clone,
1.0.0[src]fn sum<S>(self) -> S where
S: Sum<Self::Item>,
1.11.0[src]fn product<P>(self) -> P where
P: Product<Self::Item>,
1.11.0[src]fn cmp<I>(self, other: I) -> Ordering where
I: IntoIterator<Item = Self::Item>,
Self::Item: Ord,
1.5.0[src]fn cmp_by<I, F>(self, other: I, cmp: F) -> Ordering where
F: FnMut(Self::Item, <I as IntoIterator>::Item) -> Ordering,
I: IntoIterator,
[src]fn partial_cmp<I>(self, other: I) -> Option<Ordering> where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]fn partial_cmp_by<I, F>(self, other: I, partial_cmp: F) -> Option<Ordering> where
F: FnMut(Self::Item, <I as IntoIterator>::Item) -> Option<Ordering>,
I: IntoIterator,
[src]fn eq<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialEq<<I as IntoIterator>::Item>,
1.5.0[src]fn eq_by<I, F>(self, other: I, eq: F) -> bool where
F: FnMut(Self::Item, <I as IntoIterator>::Item) -> bool,
I: IntoIterator,
[src]fn ne<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialEq<<I as IntoIterator>::Item>,
1.5.0[src]fn lt<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]fn le<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]fn gt<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]fn ge<I>(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>,
1.5.0[src]fn is_sorted(self) -> bool where
Self::Item: PartialOrd<Self::Item>,
[src]fn is_sorted_by<F>(self, compare: F) -> bool where
F: FnMut(&Self::Item, &Self::Item) -> Option<Ordering>,
[src]fn is_sorted_by_key<F, K>(self, f: F) -> bool where
F: FnMut(Self::Item) -> K,
K: PartialOrd<K>,
[src]impl !RefUnwindSafe for Traverse
impl !Send for Traverse
impl !Sync for Traverse
impl Unpin for Traverse
impl !UnwindSafe for Traverse
impl<T> Any for T where
T: 'static + ?Sized,
[src]impl<T> Borrow<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]impl<T> From<T> for T
[src]impl<T, U> Into<U> for T where
U: From<T>,
[src]impl<I> IntoIterator for I where
I: Iterator,
[src]type Item = <I as Iterator>::Item
The type of the elements being iterated over.
+type IntoIter = I
Which kind of iterator are we turning this into?
+pub fn into_iter(self) -> I
[src]impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
The resulting type after obtaining ownership.
+pub fn to_owned(&self) -> T
[src]pub fn clone_into(&self, target: &mut T)
[src]impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]type Error = Infallible
The type returned in the event of a conversion error.
+pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]Convenience methods for element iterators.
+fn select(self, selectors: &str) -> Result<Select<Self>, ()>
Filter this element iterator to elements maching the given selectors.
+impl<I> ElementIterator for I where
I: Iterator<Item = NodeDataRef<ElementData>>,
[src]Convenience methods for node iterators.
+fn elements(self) -> Elements<Self>ⓘNotable traits for Elements<I>
impl<I> Iterator for Elements<I> where
I: Iterator<Item = NodeRef>, type Item = NodeDataRef<ElementData>;
Filter this element iterator to elements.
+fn text_nodes(self) -> TextNodes<Self>ⓘ
Filter this node iterator to text nodes.
+fn comments(self) -> Comments<Self>ⓘ
Filter this node iterator to comment nodes.
+fn select(self, selectors: &str) -> Result<Select<Elements<Self>>, ()>
Filter this node iterator to elements maching the given selectors.
+Redirecting to ../../kuchiki/struct.NodeDataRef.html...
+ + + \ No newline at end of file diff --git a/tests/html/1.49.0/kuchiki/parser/fn.parse_html.html b/tests/html/1.49.0/kuchiki/parser/fn.parse_html.html new file mode 100644 index 0000000..acb2f6c --- /dev/null +++ b/tests/html/1.49.0/kuchiki/parser/fn.parse_html.html @@ -0,0 +1,10 @@ + + + + + + +Redirecting to ../../kuchiki/fn.parse_html.html...
+ + + \ No newline at end of file diff --git a/tests/html/1.49.0/kuchiki/parser/fn.parse_html_with_options.html b/tests/html/1.49.0/kuchiki/parser/fn.parse_html_with_options.html new file mode 100644 index 0000000..51fac03 --- /dev/null +++ b/tests/html/1.49.0/kuchiki/parser/fn.parse_html_with_options.html @@ -0,0 +1,10 @@ + + + + + + +Redirecting to ../../kuchiki/fn.parse_html_with_options.html...
+ + + \ No newline at end of file diff --git a/tests/html/1.49.0/kuchiki/parser/struct.ParseOpts.html b/tests/html/1.49.0/kuchiki/parser/struct.ParseOpts.html new file mode 100644 index 0000000..b2a948d --- /dev/null +++ b/tests/html/1.49.0/kuchiki/parser/struct.ParseOpts.html @@ -0,0 +1,10 @@ + + + + + + +Redirecting to ../../kuchiki/struct.ParseOpts.html...
+ + + \ No newline at end of file diff --git a/tests/html/1.49.0/kuchiki/select/struct.Selector.html b/tests/html/1.49.0/kuchiki/select/struct.Selector.html new file mode 100644 index 0000000..916916c --- /dev/null +++ b/tests/html/1.49.0/kuchiki/select/struct.Selector.html @@ -0,0 +1,10 @@ + + + + + + +Redirecting to ../../kuchiki/struct.Selector.html...
+ + + \ No newline at end of file diff --git a/tests/html/1.49.0/kuchiki/select/struct.Selectors.html b/tests/html/1.49.0/kuchiki/select/struct.Selectors.html new file mode 100644 index 0000000..9f9d47d --- /dev/null +++ b/tests/html/1.49.0/kuchiki/select/struct.Selectors.html @@ -0,0 +1,10 @@ + + + + + + +Redirecting to ../../kuchiki/struct.Selectors.html...
+ + + \ No newline at end of file diff --git a/tests/html/1.49.0/kuchiki/select/struct.Specificity.html b/tests/html/1.49.0/kuchiki/select/struct.Specificity.html new file mode 100644 index 0000000..2e8565e --- /dev/null +++ b/tests/html/1.49.0/kuchiki/select/struct.Specificity.html @@ -0,0 +1,10 @@ + + + + + + +Redirecting to ../../kuchiki/struct.Specificity.html...
+ + + \ No newline at end of file diff --git a/tests/html/1.49.0/kuchiki/sidebar-items.js b/tests/html/1.49.0/kuchiki/sidebar-items.js new file mode 100644 index 0000000..5bbe9ea --- /dev/null +++ b/tests/html/1.49.0/kuchiki/sidebar-items.js @@ -0,0 +1 @@ +initSidebarItems({"enum":[["NodeData","Node data specific to the node type."]],"fn":[["parse_html","Parse an HTML document with html5ever and the default configuration."],["parse_html_with_options","Parse an HTML document with html5ever with custom configuration."]],"mod":[["iter","Node iterators"],["traits","This module re-exports a number of traits that are useful when using Kuchiki. It can be used with:"]],"struct":[["Attribute","The non-identifying parts of an attribute"],["Attributes","Convenience wrapper around a btreemap that adds method for attributes in the null namespace."],["Doctype","Data specific to doctype nodes."],["DocumentData","Data specific to document nodes."],["ElementData","Data specific to element nodes."],["ExpandedName","https://www.w3.org/TR/REC-xml-names/#dt-expname"],["Node","A node inside a DOM-like tree."],["NodeDataRef","Holds a strong reference to a node, but dereferences to some component inside of it."],["NodeRef","A strong reference to a node."],["ParseOpts","Options for the HTML parser."],["Selector","A pre-compiled CSS Selector."],["Selectors","A pre-compiled list of CSS Selectors."],["Specificity","The specificity of a selector."]]}); \ No newline at end of file diff --git a/tests/html/1.49.0/kuchiki/struct.Attribute.html b/tests/html/1.49.0/kuchiki/struct.Attribute.html new file mode 100644 index 0000000..900bb4f --- /dev/null +++ b/tests/html/1.49.0/kuchiki/struct.Attribute.html @@ -0,0 +1,30 @@ +The non-identifying parts of an attribute
+prefix: Option<Prefix>
The namespace prefix, if any
+value: String
The attribute value
+impl Clone for Attribute
[src]impl Debug for Attribute
[src]impl PartialEq<Attribute> for Attribute
[src]impl StructuralPartialEq for Attribute
[src]impl RefUnwindSafe for Attribute
impl Send for Attribute
impl Sync for Attribute
impl Unpin for Attribute
impl UnwindSafe for Attribute
impl<T> Any for T where
T: 'static + ?Sized,
[src]impl<T> Borrow<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]impl<T> From<T> for T
[src]impl<T, U> Into<U> for T where
U: From<T>,
[src]impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
The resulting type after obtaining ownership.
+pub fn to_owned(&self) -> T
[src]pub fn clone_into(&self, target: &mut T)
[src]impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]type Error = Infallible
The type returned in the event of a conversion error.
+pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]Convenience wrapper around a btreemap that adds method for attributes in the null namespace.
+map: BTreeMap<ExpandedName, Attribute>
A map of attributes whose name can have namespaces.
+impl Attributes
[src]pub fn contains<A: Into<LocalName>>(&self, local_name: A) -> bool
[src]Like BTreeMap::contains
+pub fn get<A: Into<LocalName>>(&self, local_name: A) -> Option<&str>
[src]Like BTreeMap::get
+pub fn get_mut<A: Into<LocalName>>(
&mut self,
local_name: A
) -> Option<&mut String>
[src]Like BTreeMap::get_mut
+pub fn entry<A: Into<LocalName>>(
&mut self,
local_name: A
) -> Entry<'_, ExpandedName, Attribute>
[src]Like BTreeMap::entry
+pub fn insert<A: Into<LocalName>>(
&mut self,
local_name: A,
value: String
) -> Option<Attribute>
[src]Like BTreeMap::insert
+pub fn remove<A: Into<LocalName>>(&mut self, local_name: A) -> Option<Attribute>
[src]Like BTreeMap::remove
+impl Clone for Attributes
[src]fn clone(&self) -> Attributes
[src]fn clone_from(&mut self, source: &Self)
1.0.0[src]impl Debug for Attributes
[src]impl PartialEq<Attributes> for Attributes
[src]fn eq(&self, other: &Attributes) -> bool
[src]fn ne(&self, other: &Attributes) -> bool
[src]impl StructuralPartialEq for Attributes
[src]impl RefUnwindSafe for Attributes
impl Send for Attributes
impl Sync for Attributes
impl Unpin for Attributes
impl UnwindSafe for Attributes
impl<T> Any for T where
T: 'static + ?Sized,
[src]impl<T> Borrow<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]impl<T> From<T> for T
[src]impl<T, U> Into<U> for T where
U: From<T>,
[src]impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
The resulting type after obtaining ownership.
+pub fn to_owned(&self) -> T
[src]pub fn clone_into(&self, target: &mut T)
[src]impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]type Error = Infallible
The type returned in the event of a conversion error.
+pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]Data specific to doctype nodes.
+name: String
The name of the doctype
+public_id: String
The public ID of the doctype
+system_id: String
The system ID of the doctype
+impl Clone for Doctype
[src]impl Debug for Doctype
[src]impl PartialEq<Doctype> for Doctype
[src]impl StructuralPartialEq for Doctype
[src]impl RefUnwindSafe for Doctype
impl Send for Doctype
impl Sync for Doctype
impl Unpin for Doctype
impl UnwindSafe for Doctype
impl<T> Any for T where
T: 'static + ?Sized,
[src]impl<T> Borrow<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]impl<T> From<T> for T
[src]impl<T, U> Into<U> for T where
U: From<T>,
[src]impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
The resulting type after obtaining ownership.
+pub fn to_owned(&self) -> T
[src]pub fn clone_into(&self, target: &mut T)
[src]impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]type Error = Infallible
The type returned in the event of a conversion error.
+pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]Data specific to document nodes.
+impl DocumentData
[src]pub fn quirks_mode(&self) -> QuirksMode
[src]The quirks mode of the document, as determined by the HTML parser.
+impl Clone for DocumentData
[src]fn clone(&self) -> DocumentData
[src]fn clone_from(&mut self, source: &Self)
1.0.0[src]impl Debug for DocumentData
[src]impl PartialEq<DocumentData> for DocumentData
[src]fn eq(&self, other: &DocumentData) -> bool
[src]fn ne(&self, other: &DocumentData) -> bool
[src]impl StructuralPartialEq for DocumentData
[src]impl !RefUnwindSafe for DocumentData
impl Send for DocumentData
impl !Sync for DocumentData
impl Unpin for DocumentData
impl UnwindSafe for DocumentData
impl<T> Any for T where
T: 'static + ?Sized,
[src]impl<T> Borrow<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]impl<T> From<T> for T
[src]impl<T, U> Into<U> for T where
U: From<T>,
[src]impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
The resulting type after obtaining ownership.
+pub fn to_owned(&self) -> T
[src]pub fn clone_into(&self, target: &mut T)
[src]impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]type Error = Infallible
The type returned in the event of a conversion error.
+pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]Data specific to element nodes.
+name: QualName
The namespace and local name of the element, such as ns!(html)
and body
.
attributes: RefCell<Attributes>
The attributes of the elements.
+template_contents: Option<NodeRef>
If the element is an HTML <template>
element,
+the document fragment node that is the root of template contents.
impl Clone for ElementData
[src]fn clone(&self) -> ElementData
[src]fn clone_from(&mut self, source: &Self)
1.0.0[src]impl Debug for ElementData
[src]impl PartialEq<ElementData> for ElementData
[src]fn eq(&self, other: &ElementData) -> bool
[src]fn ne(&self, other: &ElementData) -> bool
[src]impl StructuralPartialEq for ElementData
[src]impl !RefUnwindSafe for ElementData
impl !Send for ElementData
impl !Sync for ElementData
impl Unpin for ElementData
impl !UnwindSafe for ElementData
impl<T> Any for T where
T: 'static + ?Sized,
[src]impl<T> Borrow<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]impl<T> From<T> for T
[src]impl<T, U> Into<U> for T where
U: From<T>,
[src]impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
The resulting type after obtaining ownership.
+pub fn to_owned(&self) -> T
[src]pub fn clone_into(&self, target: &mut T)
[src]impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]type Error = Infallible
The type returned in the event of a conversion error.
+pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]ns: Namespace
Namespace URL
+local: LocalName
"Local" part of the name
+impl ExpandedName
[src]pub fn new<N: Into<Namespace>, L: Into<LocalName>>(ns: N, local: L) -> Self
[src]Trivial constructor
+impl Clone for ExpandedName
[src]fn clone(&self) -> ExpandedName
[src]fn clone_from(&mut self, source: &Self)
1.0.0[src]impl Debug for ExpandedName
[src]impl Eq for ExpandedName
[src]impl Hash for ExpandedName
[src]fn hash<__H: Hasher>(&self, state: &mut __H)
[src]fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]impl Ord for ExpandedName
[src]fn cmp(&self, other: &ExpandedName) -> Ordering
[src]#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]impl PartialEq<ExpandedName> for ExpandedName
[src]fn eq(&self, other: &ExpandedName) -> bool
[src]fn ne(&self, other: &ExpandedName) -> bool
[src]impl PartialOrd<ExpandedName> for ExpandedName
[src]fn partial_cmp(&self, other: &ExpandedName) -> Option<Ordering>
[src]fn lt(&self, other: &ExpandedName) -> bool
[src]fn le(&self, other: &ExpandedName) -> bool
[src]fn gt(&self, other: &ExpandedName) -> bool
[src]fn ge(&self, other: &ExpandedName) -> bool
[src]impl StructuralEq for ExpandedName
[src]impl StructuralPartialEq for ExpandedName
[src]impl RefUnwindSafe for ExpandedName
impl Send for ExpandedName
impl Sync for ExpandedName
impl Unpin for ExpandedName
impl UnwindSafe for ExpandedName
impl<T> Any for T where
T: 'static + ?Sized,
[src]impl<T> Borrow<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]impl<T> From<T> for T
[src]impl<T, U> Into<U> for T where
U: From<T>,
[src]impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
The resulting type after obtaining ownership.
+pub fn to_owned(&self) -> T
[src]pub fn clone_into(&self, target: &mut T)
[src]impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]type Error = Infallible
The type returned in the event of a conversion error.
+pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]A node inside a DOM-like tree.
+impl Node
[src]pub fn data(&self) -> &NodeData
[src]Return a reference to this node’s node-type-specific data.
+pub fn as_element(&self) -> Option<&ElementData>
[src]If this node is an element, return a reference to element-specific data.
+pub fn as_text(&self) -> Option<&RefCell<String>>
[src]If this node is a text node, return a reference to its contents.
+pub fn as_comment(&self) -> Option<&RefCell<String>>
[src]If this node is a comment, return a reference to its contents.
+pub fn as_doctype(&self) -> Option<&Doctype>
[src]If this node is a document, return a reference to doctype-specific data.
+pub fn as_document(&self) -> Option<&DocumentData>
[src]If this node is a document, return a reference to document-specific data.
+pub fn parent(&self) -> Option<NodeRef>
[src]Return a reference to the parent node, unless this node is the root of the tree.
+pub fn first_child(&self) -> Option<NodeRef>
[src]Return a reference to the first child of this node, unless it has no child.
+pub fn last_child(&self) -> Option<NodeRef>
[src]Return a reference to the last child of this node, unless it has no child.
+pub fn previous_sibling(&self) -> Option<NodeRef>
[src]Return a reference to the previous sibling of this node, unless it is a first child.
+pub fn next_sibling(&self) -> Option<NodeRef>
[src]Return a reference to the previous sibling of this node, unless it is a last child.
+pub fn detach(&self)
[src]Detach a node from its parent and siblings. Children are not affected.
+To remove a node and its descendants, detach it and drop any strong reference to it.
+impl Debug for Node
[src]impl Drop for Node
[src]Prevent implicit recursion when dropping nodes to avoid overflowing the stack.
+The implicit drop is correct, but recursive. +In the worst case (where no node has both a next sibling and a child), +a tree of a few tens of thousands of nodes could cause a stack overflow.
+This Drop
implementations makes sure the recursion does not happen.
+Instead, it has an explicit Vec<Rc<Node>>
stack to traverse the subtree,
+but only following Rc<Node>
references that are "unique":
+that have a strong reference count of 1.
+Those are the nodes that would have been dropped recursively.
The stack holds ancestors of the current node rather than preceding siblings, +on the assumption that large document trees are typically wider than deep.
+impl !RefUnwindSafe for Node
impl !Send for Node
impl !Sync for Node
impl Unpin for Node
impl !UnwindSafe for Node
impl<T> Any for T where
T: 'static + ?Sized,
[src]impl<T> Borrow<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]impl<T> From<T> for T
[src]impl<T, U> Into<U> for T where
U: From<T>,
[src]impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]type Error = Infallible
The type returned in the event of a conversion error.
+pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]Holds a strong reference to a node, but dereferences to some component inside of it.
+impl<T> NodeDataRef<T>
[src]pub fn new<F>(rc: NodeRef, f: F) -> NodeDataRef<T> where
F: FnOnce(&Node) -> &T,
[src]Create a NodeDataRef
for a component in a given node.
pub fn new_opt<F>(rc: NodeRef, f: F) -> Option<NodeDataRef<T>> where
F: FnOnce(&Node) -> Option<&T>,
[src]Create a NodeDataRef
for and a component that may or may not be in a given node.
pub fn as_node(&self) -> &NodeRef
[src]Access the corresponding node.
+impl NodeDataRef<ElementData>
[src]pub fn text_contents(&self) -> String
[src]Return the concatenation of all text nodes in this subtree.
+impl<T> Clone for NodeDataRef<T>
[src]fn clone(&self) -> Self
[src]fn clone_from(&mut self, source: &Self)
1.0.0[src]impl<T: Debug> Debug for NodeDataRef<T>
[src]impl<T> Deref for NodeDataRef<T>
[src]impl Element for NodeDataRef<ElementData>
[src]type Impl = KuchikiSelectors
fn opaque(&self) -> OpaqueElement
[src]fn is_html_slot_element(&self) -> bool
[src]fn parent_node_is_shadow_root(&self) -> bool
[src]fn containing_shadow_host(&self) -> Option<Self>
[src]fn parent_element(&self) -> Option<Self>
[src]fn prev_sibling_element(&self) -> Option<Self>
[src]fn next_sibling_element(&self) -> Option<Self>
[src]fn is_empty(&self) -> bool
[src]fn is_root(&self) -> bool
[src]fn is_html_element_in_html_document(&self) -> bool
[src]fn has_local_name(&self, name: &LocalName) -> bool
[src]fn has_namespace(&self, namespace: &Namespace) -> bool
[src]fn is_part(&self, _name: &LocalName) -> bool
[src]fn exported_part(&self, _: &LocalName) -> Option<LocalName>
[src]fn imported_part(&self, _: &LocalName) -> Option<LocalName>
[src]fn is_pseudo_element(&self) -> bool
[src]fn is_same_type(&self, other: &Self) -> bool
[src]fn is_link(&self) -> bool
[src]fn has_id(&self, id: &LocalName, case_sensitivity: CaseSensitivity) -> bool
[src]fn has_class(&self, name: &LocalName, case_sensitivity: CaseSensitivity) -> bool
[src]fn attr_matches(
&self,
ns: &NamespaceConstraint<&Namespace>,
local_name: &LocalName,
operation: &AttrSelectorOperation<&String>
) -> bool
[src]fn match_pseudo_element(
&self,
pseudo: &PseudoElement,
_context: &mut MatchingContext<'_, KuchikiSelectors>
) -> bool
[src]fn match_non_ts_pseudo_class<F>(
&self,
pseudo: &PseudoClass,
_context: &mut MatchingContext<'_, KuchikiSelectors>,
_flags_setter: &mut F
) -> bool where
F: FnMut(&Self, ElementSelectorFlags),
[src]fn pseudo_element_originating_element(&self) -> Option<Self>
fn assigned_slot(&self) -> Option<Self>
fn ignores_nth_child_selectors(&self) -> bool
impl<T: Eq> Eq for NodeDataRef<T>
[src]impl<T> PartialEq<NodeDataRef<T>> for NodeDataRef<T>
[src]impl<T> StructuralEq for NodeDataRef<T>
[src]impl<T> !RefUnwindSafe for NodeDataRef<T>
impl<T> !Send for NodeDataRef<T>
impl<T> !Sync for NodeDataRef<T>
impl<T> Unpin for NodeDataRef<T>
impl<T> !UnwindSafe for NodeDataRef<T>
impl<T> Any for T where
T: 'static + ?Sized,
[src]impl<T> Borrow<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]impl<T> From<T> for T
[src]impl<T, U> Into<U> for T where
U: From<T>,
[src]impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
The resulting type after obtaining ownership.
+pub fn to_owned(&self) -> T
[src]pub fn clone_into(&self, target: &mut T)
[src]impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]type Error = Infallible
The type returned in the event of a conversion error.
+pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]A strong reference to a node.
+A node is destroyed when the last strong reference to it dropped.
+Each node holds a strong reference to its first child and next sibling (if any), +but only a weak reference to its last child, previous sibling, and parent. +This is to avoid strong reference cycles, which would cause memory leaks.
+As a result, a single NodeRef
is sufficient to keep alive a node
+and nodes that are after it in tree order
+(its descendants, its following siblings, and their descendants)
+but not other nodes in a tree.
To avoid detroying nodes prematurely, +programs typically hold a strong reference to the root of a document +until they’re done with that document.
+impl NodeRef
[src]pub fn inclusive_ancestors(&self) -> Ancestorsⓘ
[src]Return an iterator of references to this node and its ancestors.
+pub fn ancestors(&self) -> Ancestorsⓘ
[src]Return an iterator of references to this node’s ancestors.
+pub fn inclusive_preceding_siblings(&self) -> Rev<Siblings>
[src]Return an iterator of references to this node and the siblings before it.
+pub fn preceding_siblings(&self) -> Rev<Siblings>
[src]Return an iterator of references to this node’s siblings before it.
+pub fn inclusive_following_siblings(&self) -> Siblingsⓘ
[src]Return an iterator of references to this node and the siblings after it.
+pub fn following_siblings(&self) -> Siblingsⓘ
[src]Return an iterator of references to this node’s siblings after it.
+pub fn children(&self) -> Siblingsⓘ
[src]Return an iterator of references to this node’s children.
+pub fn inclusive_descendants(&self) -> DescendantsⓘNotable traits for Descendants
impl Iterator for Descendants type Item = NodeRef;
[src]Return an iterator of references to this node and its descendants, in tree order.
+Parent nodes appear before the descendants.
+Note: this is the NodeEdge::Start
items from traverse()
.
pub fn descendants(&self) -> DescendantsⓘNotable traits for Descendants
impl Iterator for Descendants type Item = NodeRef;
[src]Return an iterator of references to this node’s descendants, in tree order.
+Parent nodes appear before the descendants.
+Note: this is the NodeEdge::Start
items from traverse()
.
pub fn traverse_inclusive(&self) -> Traverseⓘ
[src]Return an iterator of the start and end edges of this node and its descendants, +in tree order.
+pub fn traverse(&self) -> Traverseⓘ
[src]Return an iterator of the start and end edges of this node’s descendants, +in tree order.
+pub fn select(
&self,
selectors: &str
) -> Result<Select<Elements<Descendants>>, ()>
[src]Return an iterator of the inclusive descendants element that match the given selector list.
+pub fn select_first(
&self,
selectors: &str
) -> Result<NodeDataRef<ElementData>, ()>
[src]Return the first inclusive descendants element that match the given selector list.
+impl NodeRef
[src]pub fn into_element_ref(self) -> Option<NodeDataRef<ElementData>>
[src]If this node is an element, return a strong reference to element-specific data.
+pub fn into_text_ref(self) -> Option<NodeDataRef<RefCell<String>>>
[src]If this node is a text node, return a strong reference to its contents.
+pub fn into_comment_ref(self) -> Option<NodeDataRef<RefCell<String>>>
[src]If this node is a comment, return a strong reference to its contents.
+pub fn into_doctype_ref(self) -> Option<NodeDataRef<Doctype>>
[src]If this node is a doctype, return a strong reference to doctype-specific data.
+pub fn into_document_ref(self) -> Option<NodeDataRef<DocumentData>>
[src]If this node is a document, return a strong reference to document-specific data.
+impl NodeRef
[src]pub fn serialize<W: Write>(&self, writer: &mut W) -> Result<()>
[src]Serialize this node and its descendants in HTML syntax to the given stream.
+pub fn serialize_to_file<P: AsRef<Path>>(&self, path: P) -> Result<()>
[src]Serialize this node and its descendants in HTML syntax to a new file at the given path.
+impl NodeRef
[src]pub fn new(data: NodeData) -> NodeRef
[src]Create a new node.
+pub fn new_element<I>(name: QualName, attributes: I) -> NodeRef where
I: IntoIterator<Item = (ExpandedName, Attribute)>,
[src]Create a new element node.
+pub fn new_text<T: Into<String>>(value: T) -> NodeRef
[src]Create a new text node.
+pub fn new_comment<T: Into<String>>(value: T) -> NodeRef
[src]Create a new comment node.
+pub fn new_processing_instruction<T1, T2>(target: T1, data: T2) -> NodeRef where
T1: Into<String>,
T2: Into<String>,
[src]Create a new processing instruction node.
+pub fn new_doctype<T1, T2, T3>(
name: T1,
public_id: T2,
system_id: T3
) -> NodeRef where
T1: Into<String>,
T2: Into<String>,
T3: Into<String>,
[src]Create a new doctype node.
+pub fn new_document() -> NodeRef
[src]Create a new document node.
+pub fn text_contents(&self) -> String
[src]Return the concatenation of all text nodes in this subtree.
+impl NodeRef
[src]pub fn append(&self, new_child: NodeRef)
[src]Append a new child to this node, after existing children.
+The new child is detached from its previous position.
+pub fn prepend(&self, new_child: NodeRef)
[src]Prepend a new child to this node, before existing children.
+The new child is detached from its previous position.
+pub fn insert_after(&self, new_sibling: NodeRef)
[src]Insert a new sibling after this node.
+The new sibling is detached from its previous position.
+pub fn insert_before(&self, new_sibling: NodeRef)
[src]Insert a new sibling before this node.
+The new sibling is detached from its previous position.
+pub fn data(&self) -> &NodeData
[src]Return a reference to this node’s node-type-specific data.
+pub fn as_element(&self) -> Option<&ElementData>
[src]If this node is an element, return a reference to element-specific data.
+pub fn as_text(&self) -> Option<&RefCell<String>>
[src]If this node is a text node, return a reference to its contents.
+pub fn as_comment(&self) -> Option<&RefCell<String>>
[src]If this node is a comment, return a reference to its contents.
+pub fn as_doctype(&self) -> Option<&Doctype>
[src]If this node is a document, return a reference to doctype-specific data.
+pub fn as_document(&self) -> Option<&DocumentData>
[src]If this node is a document, return a reference to document-specific data.
+pub fn parent(&self) -> Option<NodeRef>
[src]Return a reference to the parent node, unless this node is the root of the tree.
+pub fn first_child(&self) -> Option<NodeRef>
[src]Return a reference to the first child of this node, unless it has no child.
+pub fn last_child(&self) -> Option<NodeRef>
[src]Return a reference to the last child of this node, unless it has no child.
+pub fn previous_sibling(&self) -> Option<NodeRef>
[src]Return a reference to the previous sibling of this node, unless it is a first child.
+pub fn next_sibling(&self) -> Option<NodeRef>
[src]Return a reference to the previous sibling of this node, unless it is a last child.
+pub fn detach(&self)
[src]Detach a node from its parent and siblings. Children are not affected.
+To remove a node and its descendants, detach it and drop any strong reference to it.
+impl Clone for NodeRef
[src]impl Debug for NodeRef
[src]impl Deref for NodeRef
[src]impl Eq for NodeRef
[src]impl PartialEq<NodeRef> for NodeRef
[src]impl Serialize for NodeRef
[src]fn serialize<S: Serializer>(
&self,
serializer: &mut S,
traversal_scope: TraversalScope
) -> Result<()>
[src]impl ToString for NodeRef
[src]impl !RefUnwindSafe for NodeRef
impl !Send for NodeRef
impl !Sync for NodeRef
impl Unpin for NodeRef
impl !UnwindSafe for NodeRef
impl<T> Any for T where
T: 'static + ?Sized,
[src]impl<T> Borrow<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]impl<T> From<T> for T
[src]impl<T, U> Into<U> for T where
U: From<T>,
[src]impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
The resulting type after obtaining ownership.
+pub fn to_owned(&self) -> T
[src]pub fn clone_into(&self, target: &mut T)
[src]impl<T> ToString for T where
T: Display + ?Sized,
[src]impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]type Error = Infallible
The type returned in the event of a conversion error.
+pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]Options for the HTML parser.
+tokenizer: TokenizerOpts
Options for the HTML tokenizer.
+tree_builder: TreeBuilderOpts
Options for the HTML tree builder.
+on_parse_error: Option<Box<dyn FnMut(Cow<'static, str>)>>
A callback for HTML parse errors (which are never fatal).
+impl !RefUnwindSafe for ParseOpts
impl !Send for ParseOpts
impl !Sync for ParseOpts
impl Unpin for ParseOpts
impl !UnwindSafe for ParseOpts
impl<T> Any for T where
T: 'static + ?Sized,
[src]impl<T> Borrow<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]impl<T> From<T> for T
[src]impl<T, U> Into<U> for T where
U: From<T>,
[src]impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]type Error = Infallible
The type returned in the event of a conversion error.
+pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]A pre-compiled CSS Selector.
+impl Selector
[src]pub fn matches(&self, element: &NodeDataRef<ElementData>) -> bool
[src]Returns whether the given element matches this selector.
+pub fn specificity(&self) -> Specificity
[src]Return the specificity of this selector.
+impl RefUnwindSafe for Selector
impl Send for Selector
impl Sync for Selector
impl Unpin for Selector
impl UnwindSafe for Selector
impl<T> Any for T where
T: 'static + ?Sized,
[src]impl<T> Borrow<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]impl<T> From<T> for T
[src]impl<T, U> Into<U> for T where
U: From<T>,
[src]impl<T> ToString for T where
T: Display + ?Sized,
[src]impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]type Error = Infallible
The type returned in the event of a conversion error.
+pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]A pre-compiled list of CSS Selectors.
+impl Selectors
[src]pub fn compile(s: &str) -> Result<Selectors, ()>
[src]Compile a list of selectors. This may fail on syntax errors or unsupported selectors.
+pub fn matches(&self, element: &NodeDataRef<ElementData>) -> bool
[src]Returns whether the given element matches this list of selectors.
+pub fn filter<I>(&self, iter: I) -> Select<I, &Selectors>ⓘNotable traits for Select<I, S>
impl<I, S> Iterator for Select<I, S> where
I: Iterator<Item = NodeDataRef<ElementData>>,
S: Borrow<Selectors>, type Item = NodeDataRef<ElementData>;
where
I: Iterator<Item = NodeDataRef<ElementData>>,
[src]Filter an element iterator, yielding those matching this list of selectors.
+impl RefUnwindSafe for Selectors
impl Send for Selectors
impl Sync for Selectors
impl Unpin for Selectors
impl UnwindSafe for Selectors
impl<T> Any for T where
T: 'static + ?Sized,
[src]impl<T> Borrow<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]impl<T> From<T> for T
[src]impl<T, U> Into<U> for T where
U: From<T>,
[src]impl<T> ToString for T where
T: Display + ?Sized,
[src]impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]type Error = Infallible
The type returned in the event of a conversion error.
+pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]The specificity of a selector.
+Opaque, but ordered.
+Determines precedence in the cascading algorithm. +When equal, a rule later in source order takes precedence.
+impl Clone for Specificity
[src]fn clone(&self) -> Specificity
[src]fn clone_from(&mut self, source: &Self)
1.0.0[src]impl Copy for Specificity
[src]impl Eq for Specificity
[src]impl Hash for Specificity
[src]fn hash<__H: Hasher>(&self, state: &mut __H)
[src]fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]impl Ord for Specificity
[src]fn cmp(&self, other: &Specificity) -> Ordering
[src]#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]impl PartialEq<Specificity> for Specificity
[src]fn eq(&self, other: &Specificity) -> bool
[src]fn ne(&self, other: &Specificity) -> bool
[src]impl PartialOrd<Specificity> for Specificity
[src]fn partial_cmp(&self, other: &Specificity) -> Option<Ordering>
[src]fn lt(&self, other: &Specificity) -> bool
[src]fn le(&self, other: &Specificity) -> bool
[src]fn gt(&self, other: &Specificity) -> bool
[src]fn ge(&self, other: &Specificity) -> bool
[src]impl StructuralEq for Specificity
[src]impl StructuralPartialEq for Specificity
[src]impl RefUnwindSafe for Specificity
impl Send for Specificity
impl Sync for Specificity
impl Unpin for Specificity
impl UnwindSafe for Specificity
impl<T> Any for T where
T: 'static + ?Sized,
[src]impl<T> Borrow<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]impl<T> From<T> for T
[src]impl<T, U> Into<U> for T where
U: From<T>,
[src]impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
The resulting type after obtaining ownership.
+pub fn to_owned(&self) -> T
[src]pub fn clone_into(&self, target: &mut T)
[src]impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]type Error = Infallible
The type returned in the event of a conversion error.
+pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]This module re-exports a number of traits that are useful when using Kuchiki. +It can be used with:
+ ++use kuchiki::traits::*;
pub use crate::iter::ElementIterator; |
pub use crate::iter::NodeIterator; |
TendrilSink | Trait for types that can process a tendril. + |
Trait for types that can process a tendril.
+This is a "push" interface, unlike the "pull" interface of
+Iterator<Item=Tendril<F>>
. The push interface matches
+html5ever and other incremental parsers with a similar
+architecture.
type Output
What the overall result of processing is.
+fn process(&mut self, t: Tendril<F, A>)
Process this tendril.
+fn error(&mut self, desc: Cow<'static, str>)
Indicates that an error has occurred.
+fn finish(self) -> Self::Output
Indicates the end of the stream.
+fn one<T>(self, t: T) -> Self::Output where
T: Into<Tendril<F, A>>,
Process one tendril and finish.
+fn from_iter<I>(self, i: I) -> Self::Output where
I: IntoIterator,
<I as IntoIterator>::Item: Into<Tendril<F, A>>,
Consume an iterator of tendrils, processing each item, then finish.
+fn read_from<R>(self, r: &mut R) -> Result<Self::Output, Error> where
F: SliceFormat<Slice = [u8]>,
R: Read,
Read from the given stream of bytes until exhaustion and process incrementally,
+then finish. Return Err
at the first I/O error.
fn from_file<P>(self, path: P) -> Result<Self::Output, Error> where
F: SliceFormat<Slice = [u8]>,
P: AsRef<Path>,
Read from the file at the given path and process incrementally,
+then finish. Return Err
at the first I/O error.
impl<Sink> TendrilSink<UTF8, NonAtomic> for Parser<Sink> where
Sink: TreeSink,
pub fn process(&mut self, t: Tendril<UTF8, NonAtomic>)
pub fn error(&mut self, desc: Cow<'static, str>)
type Output = <Sink as TreeSink>::Output
pub fn finish(self) -> <Parser<Sink> as TendrilSink<UTF8, NonAtomic>>::Output
impl<Sink, A> TendrilSink<Bytes, A> for Utf8LossyDecoder<Sink, A> where
A: Atomicity,
Sink: TendrilSink<UTF8, A>,
pub fn process(&mut self, t: Tendril<Bytes, A>)
pub fn error(&mut self, desc: Cow<'static, str>)
type Output = <Sink as TendrilSink<UTF8, A>>::Output
pub fn finish(self) -> <Sink as TendrilSink<UTF8, A>>::Output
Redirecting to ../../kuchiki/enum.NodeData.html...
+ + + \ No newline at end of file diff --git a/tests/html/1.49.0/kuchiki/tree/struct.Doctype.html b/tests/html/1.49.0/kuchiki/tree/struct.Doctype.html new file mode 100644 index 0000000..829afc2 --- /dev/null +++ b/tests/html/1.49.0/kuchiki/tree/struct.Doctype.html @@ -0,0 +1,10 @@ + + + + + + +Redirecting to ../../kuchiki/struct.Doctype.html...
+ + + \ No newline at end of file diff --git a/tests/html/1.49.0/kuchiki/tree/struct.DocumentData.html b/tests/html/1.49.0/kuchiki/tree/struct.DocumentData.html new file mode 100644 index 0000000..a09fdbe --- /dev/null +++ b/tests/html/1.49.0/kuchiki/tree/struct.DocumentData.html @@ -0,0 +1,10 @@ + + + + + + +Redirecting to ../../kuchiki/struct.DocumentData.html...
+ + + \ No newline at end of file diff --git a/tests/html/1.49.0/kuchiki/tree/struct.ElementData.html b/tests/html/1.49.0/kuchiki/tree/struct.ElementData.html new file mode 100644 index 0000000..be78ee4 --- /dev/null +++ b/tests/html/1.49.0/kuchiki/tree/struct.ElementData.html @@ -0,0 +1,10 @@ + + + + + + +Redirecting to ../../kuchiki/struct.ElementData.html...
+ + + \ No newline at end of file diff --git a/tests/html/1.49.0/kuchiki/tree/struct.Node.html b/tests/html/1.49.0/kuchiki/tree/struct.Node.html new file mode 100644 index 0000000..592e435 --- /dev/null +++ b/tests/html/1.49.0/kuchiki/tree/struct.Node.html @@ -0,0 +1,10 @@ + + + + + + +Redirecting to ../../kuchiki/struct.Node.html...
+ + + \ No newline at end of file diff --git a/tests/html/1.49.0/kuchiki/tree/struct.NodeRef.html b/tests/html/1.49.0/kuchiki/tree/struct.NodeRef.html new file mode 100644 index 0000000..700be54 --- /dev/null +++ b/tests/html/1.49.0/kuchiki/tree/struct.NodeRef.html @@ -0,0 +1,10 @@ + + + + + + +Redirecting to ../../kuchiki/struct.NodeRef.html...
+ + + \ No newline at end of file diff --git a/tests/html/1.49.0/log/all.html b/tests/html/1.49.0/log/all.html new file mode 100644 index 0000000..443f7ba --- /dev/null +++ b/tests/html/1.49.0/log/all.html @@ -0,0 +1,4 @@ +pub const STATIC_MAX_LEVEL: LevelFilter;
The statically resolved maximum log level.
+See the crate level documentation for information on how to configure this.
+This value is checked by the log macros, but not by the Log
ger returned by
+the logger
function. Code that manually calls functions on that value
+should compare the level against this value.
An enum representing the available verbosity levels of the logger.
+Typical usage includes: checking if a certain Level
is enabled with
+log_enabled!
, specifying the Level
of
+log!
, and comparing a Level
directly to a
+LevelFilter
.
The "error" level.
+Designates very serious errors.
+The "warn" level.
+Designates hazardous situations.
+The "info" level.
+Designates useful information.
+The "debug" level.
+Designates lower priority information.
+The "trace" level.
+Designates very low priority, often extremely verbose, information.
+impl Level
[src]pub fn max() -> Level
[src]Returns the most verbose logging level.
+pub fn to_level_filter(&self) -> LevelFilter
[src]Converts the Level
to the equivalent LevelFilter
.
impl Clone for Level
[src]impl Copy for Level
[src]impl Debug for Level
[src]impl Display for Level
[src]impl Eq for Level
[src]impl FromStr for Level
[src]type Err = ParseLevelError
The associated error which can be returned from parsing.
+fn from_str(level: &str) -> Result<Level, Self::Err>
[src]impl Hash for Level
[src]fn hash<__H: Hasher>(&self, state: &mut __H)
[src]fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]impl Ord for Level
[src]fn cmp(&self, other: &Level) -> Ordering
[src]#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]impl PartialEq<Level> for Level
[src]impl PartialEq<Level> for LevelFilter
[src]impl PartialEq<LevelFilter> for Level
[src]fn eq(&self, other: &LevelFilter) -> bool
[src]#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]impl PartialOrd<Level> for Level
[src]fn partial_cmp(&self, other: &Level) -> Option<Ordering>
[src]fn lt(&self, other: &Level) -> bool
[src]fn le(&self, other: &Level) -> bool
[src]fn gt(&self, other: &Level) -> bool
[src]fn ge(&self, other: &Level) -> bool
[src]impl PartialOrd<Level> for LevelFilter
[src]fn partial_cmp(&self, other: &Level) -> Option<Ordering>
[src]fn lt(&self, other: &Level) -> bool
[src]fn le(&self, other: &Level) -> bool
[src]fn gt(&self, other: &Level) -> bool
[src]fn ge(&self, other: &Level) -> bool
[src]impl PartialOrd<LevelFilter> for Level
[src]fn partial_cmp(&self, other: &LevelFilter) -> Option<Ordering>
[src]fn lt(&self, other: &LevelFilter) -> bool
[src]fn le(&self, other: &LevelFilter) -> bool
[src]fn gt(&self, other: &LevelFilter) -> bool
[src]fn ge(&self, other: &LevelFilter) -> bool
[src]impl StructuralEq for Level
[src]impl RefUnwindSafe for Level
impl Send for Level
impl Sync for Level
impl Unpin for Level
impl UnwindSafe for Level
impl<T> Any for T where
T: 'static + ?Sized,
[src]impl<T> Borrow<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]impl<T> From<T> for T
[src]impl<T, U> Into<U> for T where
U: From<T>,
[src]impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
The resulting type after obtaining ownership.
+pub fn to_owned(&self) -> T
[src]pub fn clone_into(&self, target: &mut T)
[src]impl<T> ToString for T where
T: Display + ?Sized,
[src]impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]type Error = Infallible
The type returned in the event of a conversion error.
+pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]An enum representing the available verbosity level filters of the logger.
+A LevelFilter
may be compared directly to a Level
. Use this type
+to get and set the maximum log level with max_level()
and set_max_level
.
A level lower than all log levels.
+Corresponds to the Error
log level.
Corresponds to the Warn
log level.
Corresponds to the Info
log level.
Corresponds to the Debug
log level.
Corresponds to the Trace
log level.
impl LevelFilter
[src]pub fn max() -> LevelFilter
[src]Returns the most verbose logging level filter.
+pub fn to_level(&self) -> Option<Level>
[src]Converts self
to the equivalent Level
.
Returns None
if self
is LevelFilter::Off
.
impl Clone for LevelFilter
[src]fn clone(&self) -> LevelFilter
[src]fn clone_from(&mut self, source: &Self)
1.0.0[src]impl Copy for LevelFilter
[src]impl Debug for LevelFilter
[src]impl Display for LevelFilter
[src]impl Eq for LevelFilter
[src]impl FromStr for LevelFilter
[src]type Err = ParseLevelError
The associated error which can be returned from parsing.
+fn from_str(level: &str) -> Result<LevelFilter, Self::Err>
[src]impl Hash for LevelFilter
[src]fn hash<__H: Hasher>(&self, state: &mut __H)
[src]fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]impl Ord for LevelFilter
[src]fn cmp(&self, other: &LevelFilter) -> Ordering
[src]#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]impl PartialEq<Level> for LevelFilter
[src]impl PartialEq<LevelFilter> for Level
[src]fn eq(&self, other: &LevelFilter) -> bool
[src]#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]impl PartialEq<LevelFilter> for LevelFilter
[src]fn eq(&self, other: &LevelFilter) -> bool
[src]#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]impl PartialOrd<Level> for LevelFilter
[src]fn partial_cmp(&self, other: &Level) -> Option<Ordering>
[src]fn lt(&self, other: &Level) -> bool
[src]fn le(&self, other: &Level) -> bool
[src]fn gt(&self, other: &Level) -> bool
[src]fn ge(&self, other: &Level) -> bool
[src]impl PartialOrd<LevelFilter> for Level
[src]fn partial_cmp(&self, other: &LevelFilter) -> Option<Ordering>
[src]fn lt(&self, other: &LevelFilter) -> bool
[src]fn le(&self, other: &LevelFilter) -> bool
[src]fn gt(&self, other: &LevelFilter) -> bool
[src]fn ge(&self, other: &LevelFilter) -> bool
[src]impl PartialOrd<LevelFilter> for LevelFilter
[src]fn partial_cmp(&self, other: &LevelFilter) -> Option<Ordering>
[src]fn lt(&self, other: &LevelFilter) -> bool
[src]fn le(&self, other: &LevelFilter) -> bool
[src]fn gt(&self, other: &LevelFilter) -> bool
[src]fn ge(&self, other: &LevelFilter) -> bool
[src]impl StructuralEq for LevelFilter
[src]impl RefUnwindSafe for LevelFilter
impl Send for LevelFilter
impl Sync for LevelFilter
impl Unpin for LevelFilter
impl UnwindSafe for LevelFilter
impl<T> Any for T where
T: 'static + ?Sized,
[src]impl<T> Borrow<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]impl<T> From<T> for T
[src]impl<T, U> Into<U> for T where
U: From<T>,
[src]impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
The resulting type after obtaining ownership.
+pub fn to_owned(&self) -> T
[src]pub fn clone_into(&self, target: &mut T)
[src]impl<T> ToString for T where
T: Display + ?Sized,
[src]impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]type Error = Infallible
The type returned in the event of a conversion error.
+pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]pub fn logger() -> &'static dyn Log
Returns a reference to the logger.
+If a logger has not been set, a no-op implementation is returned.
+pub fn max_level() -> LevelFilter
pub fn set_boxed_logger(logger: Box<dyn Log>) -> Result<(), SetLoggerError>
Sets the global logger to a Box<Log>
.
This is a simple convenience wrapper over set_logger
, which takes a
+Box<Log>
rather than a &'static Log
. See the documentation for
+set_logger
for more details.
Requires the std
feature.
An error is returned if a logger has already been set.
+pub fn set_logger(logger: &'static dyn Log) -> Result<(), SetLoggerError>
Sets the global logger to a &'static Log
.
This function may only be called once in the lifetime of a program. Any log
+events that occur before the call to set_logger
completes will be ignored.
This function does not typically need to be called manually. Logger +implementations should provide an initialization method that installs the +logger internally.
+This method is available even when the std
feature is disabled. However,
+it is currently unavailable on thumbv6
targets, which lack support for
+some atomic operations which are used by this function. Even on those
+targets, set_logger_racy
will be available.
An error is returned if a logger has already been set.
++use log::{error, info, warn, Record, Level, Metadata, LevelFilter}; + +static MY_LOGGER: MyLogger = MyLogger; + +struct MyLogger; + +impl log::Log for MyLogger { + fn enabled(&self, metadata: &Metadata) -> bool { + metadata.level() <= Level::Info + } + + fn log(&self, record: &Record) { + if self.enabled(record.metadata()) { + println!("{} - {}", record.level(), record.args()); + } + } + fn flush(&self) {} +} + +log::set_logger(&MY_LOGGER).unwrap(); +log::set_max_level(LevelFilter::Info); + +info!("hello log"); +warn!("warning"); +error!("oops");
pub unsafe fn set_logger_racy(
logger: &'static dyn Log
) -> Result<(), SetLoggerError>
A thread-unsafe version of set_logger
.
This function is available on all platforms, even those that do not have
+support for atomics that is needed by set_logger
.
In almost all cases, set_logger
should be preferred.
This function is only safe to call when no other logger initialization +function is called while this function still executes.
+This can be upheld by (for example) making sure that there are no other +threads, and (on embedded) that interrupts are disabled.
+It is safe to use other logging functions while this function runs +(including all logging macros).
+pub fn set_max_level(level: LevelFilter)
Sets the global maximum log level.
+Generally, this should only be called by the active logging implementation.
+A lightweight logging facade.
+The log
crate provides a single logging API that abstracts over the
+actual logging implementation. Libraries can use the logging API provided
+by this crate, and the consumer of those libraries can choose the logging
+implementation that is most suitable for its use case.
If no logging implementation is selected, the facade falls back to a "noop" +implementation that ignores all log messages. The overhead in this case +is very small - just an integer load, comparison and jump.
+A log request consists of a target, a level, and a body. A target is a +string which defaults to the module path of the location of the log request, +though that default may be overridden. Logger implementations typically use +the target to filter requests based on some user configuration.
+The basic use of the log crate is through the five logging macros: error!
,
+warn!
, info!
, debug!
and trace!
+where error!
represents the highest-priority log messages
+and trace!
the lowest. The log messages are filtered by configuring
+the log level to exclude messages with a lower priority.
+Each of these macros accept format strings similarly to println!
.
Libraries should link only to the log
crate, and use the provided
+macros to log whatever information will be useful to downstream consumers.
+use log::{info, warn}; + +pub fn shave_the_yak(yak: &mut Yak) { + info!(target: "yak_events", "Commencing yak shaving for {:?}", yak); + + loop { + match find_a_razor() { + Ok(razor) => { + info!("Razor located: {}", razor); + yak.shave(razor); + break; + } + Err(err) => { + warn!("Unable to locate a razor: {}, retrying", err); + } + } + } +}
Executables should choose a logging implementation and initialize it early in the +runtime of the program. Logging implementations will typically include a +function to do this. Any log messages generated before +the implementation is initialized will be ignored.
+The executable itself may use the log
crate to log as well.
The logging system may only be initialized once.
+In order to produce log output executables have to use +a logger implementation compatible with the facade. +There are many available implementations to choose from, +here are some of the most popular ones:
+Loggers implement the Log
trait. Here's a very basic example that simply
+logs all messages at the Error
, Warn
or
+Info
levels to stdout:
+use log::{Record, Level, Metadata}; + +struct SimpleLogger; + +impl log::Log for SimpleLogger { + fn enabled(&self, metadata: &Metadata) -> bool { + metadata.level() <= Level::Info + } + + fn log(&self, record: &Record) { + if self.enabled(record.metadata()) { + println!("{} - {}", record.level(), record.args()); + } + } + + fn flush(&self) {} +} +
Loggers are installed by calling the set_logger
function. The maximum
+log level also needs to be adjusted via the set_max_level
function. The
+logging facade uses this as an optimization to improve performance of log
+messages at levels that are disabled. It's important to set it, as it
+defaults to Off
, so no log messages will ever be captured!
+In the case of our example logger, we'll want to set the maximum log level
+to Info
, since we ignore any Debug
or
+Trace
level log messages. A logging implementation should
+provide a function that wraps a call to set_logger
and
+set_max_level
, handling initialization of the logger:
+use log::{SetLoggerError, LevelFilter}; + +static LOGGER: SimpleLogger = SimpleLogger; + +pub fn init() -> Result<(), SetLoggerError> { + log::set_logger(&LOGGER) + .map(|()| log::set_max_level(LevelFilter::Info)) +}
Implementations that adjust their configurations at runtime should take care +to adjust the maximum log level as well.
+std
set_logger
requires you to provide a &'static Log
, which can be hard to
+obtain if your logger depends on some runtime configuration. The
+set_boxed_logger
function is available with the std
Cargo feature. It is
+identical to set_logger
except that it takes a Box<Log>
rather than a
+&'static Log
:
+pub fn init() -> Result<(), SetLoggerError> { + log::set_boxed_logger(Box::new(SimpleLogger)) + .map(|()| log::set_max_level(LevelFilter::Info)) +}
Log levels can be statically disabled at compile time via Cargo features. Log invocations at +disabled levels will be skipped and will not even be present in the resulting binary. +This level is configured separately for release and debug builds. The features are:
+max_level_off
max_level_error
max_level_warn
max_level_info
max_level_debug
max_level_trace
release_max_level_off
release_max_level_error
release_max_level_warn
release_max_level_info
release_max_level_debug
release_max_level_trace
These features control the value of the STATIC_MAX_LEVEL
constant. The logging macros check
+this value before logging a message. By default, no levels are disabled.
Libraries should avoid using the max level features because they're global and can't be changed +once they're set.
+For example, a crate can disable trace level logs in debug builds and trace, debug, and info +level logs in release builds with the following configuration:
+[dependencies]
+log = { version = "0.4", features = ["max_level_debug", "release_max_level_warn"] }
+
+The following crate feature flags are available in addition to the filters. They are
+configured in your Cargo.toml
.
std
allows use of std
crate instead of the default core
. Enables using std::error
and
+set_boxed_logger
functionality.serde
enables support for serialization and deserialization of Level
and LevelFilter
.[dependencies]
+log = { version = "0.4", features = ["std", "serde"] }
+
+The 0.3 and 0.4 versions of the log
crate are almost entirely compatible. Log messages
+made using log
0.3 will forward transparently to a logger implementation using log
0.4. Log
+messages made using log
0.4 will forward to a logger implementation using log
0.3, but the
+module path and file name information associated with the message will unfortunately be lost.
debug | Logs a message at the debug level. + |
error | Logs a message at the error level. + |
info | Logs a message at the info level. + |
log | The standard logging macro. + |
log_enabled | Determines if a message logged at the specified level in that module will +be logged. + |
trace | Logs a message at the trace level. + |
warn | Logs a message at the warn level. + |
Metadata | Metadata about a log message. + |
MetadataBuilder | Builder for |
ParseLevelError | The type returned by |
Record | The "payload" of a log message. + |
RecordBuilder | Builder for |
SetLoggerError | The type returned by |
Level | An enum representing the available verbosity levels of the logger. + |
LevelFilter | An enum representing the available verbosity level filters of the logger. + |
STATIC_MAX_LEVEL | The statically resolved maximum log level. + |
Log | A trait encapsulating the operations required of a logger. + |
logger | Returns a reference to the logger. + |
max_level | Returns the current maximum log level. + |
set_boxed_logger | Sets the global logger to a |
set_logger | Sets the global logger to a |
set_logger_racy⚠ | A thread-unsafe version of |
set_max_level | Sets the global maximum log level. + |
Redirecting to macro.debug.html...
+ + + \ No newline at end of file diff --git a/tests/html/1.49.0/log/macro.debug.html b/tests/html/1.49.0/log/macro.debug.html new file mode 100644 index 0000000..d43692c --- /dev/null +++ b/tests/html/1.49.0/log/macro.debug.html @@ -0,0 +1,16 @@ +Logs a message at the debug level.
++use log::debug; + +let pos = Position { x: 3.234, y: -1.223 }; + +debug!("New position: x: {}, y: {}", pos.x, pos.y); +debug!(target: "app_events", "New position: x: {}, y: {}", pos.x, pos.y);
Redirecting to macro.error.html...
+ + + \ No newline at end of file diff --git a/tests/html/1.49.0/log/macro.error.html b/tests/html/1.49.0/log/macro.error.html new file mode 100644 index 0000000..689778d --- /dev/null +++ b/tests/html/1.49.0/log/macro.error.html @@ -0,0 +1,16 @@ +Logs a message at the error level.
++use log::error; + +let (err_info, port) = ("No connection", 22); + +error!("Error: {} on port {}", err_info, port); +error!(target: "app_events", "App Error: {}, Port: {}", err_info, 22);
Redirecting to macro.info.html...
+ + + \ No newline at end of file diff --git a/tests/html/1.49.0/log/macro.info.html b/tests/html/1.49.0/log/macro.info.html new file mode 100644 index 0000000..72f171f --- /dev/null +++ b/tests/html/1.49.0/log/macro.info.html @@ -0,0 +1,17 @@ +Logs a message at the info level.
++use log::info; + +let conn_info = Connection { port: 40, speed: 3.20 }; + +info!("Connected to port {} at {} Mb/s", conn_info.port, conn_info.speed); +info!(target: "connection_events", "Successfull connection, port: {}, speed: {}", + conn_info.port, conn_info.speed);
Redirecting to macro.log.html...
+ + + \ No newline at end of file diff --git a/tests/html/1.49.0/log/macro.log.html b/tests/html/1.49.0/log/macro.log.html new file mode 100644 index 0000000..befdeec --- /dev/null +++ b/tests/html/1.49.0/log/macro.log.html @@ -0,0 +1,21 @@ +The standard logging macro.
+This macro will generically log with the specified Level
and format!
+based argument list.
+use log::{log, Level}; + +let data = (42, "Forty-two"); +let private_data = "private"; + +log!(Level::Error, "Received errors: {}, {}", data.0, data.1); +log!(target: "app_events", Level::Warn, "App warning: {}, {}, {}", + data.0, data.1, private_data);
Redirecting to macro.log_enabled.html...
+ + + \ No newline at end of file diff --git a/tests/html/1.49.0/log/macro.log_enabled.html b/tests/html/1.49.0/log/macro.log_enabled.html new file mode 100644 index 0000000..e895af8 --- /dev/null +++ b/tests/html/1.49.0/log/macro.log_enabled.html @@ -0,0 +1,24 @@ +Determines if a message logged at the specified level in that module will +be logged.
+This can be used to avoid expensive computation of log message arguments if +the message would be ignored anyway.
++use log::Level::Debug; +use log::{debug, log_enabled}; + +if log_enabled!(Debug) { + let data = expensive_call(); + debug!("expensive debug data: {} {}", data.x, data.y); +} +if log_enabled!(target: "Global", Debug) { + let data = expensive_call(); + debug!(target: "Global", "expensive debug data: {} {}", data.x, data.y); +}
Redirecting to macro.trace.html...
+ + + \ No newline at end of file diff --git a/tests/html/1.49.0/log/macro.trace.html b/tests/html/1.49.0/log/macro.trace.html new file mode 100644 index 0000000..0c288c2 --- /dev/null +++ b/tests/html/1.49.0/log/macro.trace.html @@ -0,0 +1,18 @@ +Logs a message at the trace level.
++use log::trace; + +let pos = Position { x: 3.234, y: -1.223 }; + +trace!("Position is: x: {}, y: {}", pos.x, pos.y); +trace!(target: "app_events", "x is {} and y is {}", + if pos.x >= 0.0 { "positive" } else { "negative" }, + if pos.y >= 0.0 { "positive" } else { "negative" });
Redirecting to macro.warn.html...
+ + + \ No newline at end of file diff --git a/tests/html/1.49.0/log/macro.warn.html b/tests/html/1.49.0/log/macro.warn.html new file mode 100644 index 0000000..4658330 --- /dev/null +++ b/tests/html/1.49.0/log/macro.warn.html @@ -0,0 +1,16 @@ +Logs a message at the warn level.
++use log::warn; + +let warn_description = "Invalid Input"; + +warn!("Warning! {}!", warn_description); +warn!(target: "input_events", "App received warning: {}", warn_description);
Metadata about a log message.
+Metadata
structs are created when users of the library use
+logging macros.
They are consumed by implementations of the Log
trait in the
+enabled
method.
Record
s use Metadata
to determine the log message's severity
+and target.
Users should use the log_enabled!
macro in their code to avoid
+constructing expensive log messages.
+use log::{Record, Level, Metadata}; + +struct MyLogger; + +impl log::Log for MyLogger { + fn enabled(&self, metadata: &Metadata) -> bool { + metadata.level() <= Level::Info + } + + fn log(&self, record: &Record) { + if self.enabled(record.metadata()) { + println!("{} - {}", record.level(), record.args()); + } + } + fn flush(&self) {} +} +
impl<'a> Metadata<'a>
[src]pub fn builder() -> MetadataBuilder<'a>
[src]Returns a new builder.
+pub fn level(&self) -> Level
[src]The verbosity level of the message.
+pub fn target(&self) -> &'a str
[src]The name of the target of the directive.
+impl<'a> Clone for Metadata<'a>
[src]impl<'a> Debug for Metadata<'a>
[src]impl<'a> Eq for Metadata<'a>
[src]impl<'a> Hash for Metadata<'a>
[src]fn hash<__H: Hasher>(&self, state: &mut __H)
[src]fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]impl<'a> Ord for Metadata<'a>
[src]fn cmp(&self, other: &Metadata<'a>) -> Ordering
[src]#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]impl<'a> PartialEq<Metadata<'a>> for Metadata<'a>
[src]impl<'a> PartialOrd<Metadata<'a>> for Metadata<'a>
[src]fn partial_cmp(&self, other: &Metadata<'a>) -> Option<Ordering>
[src]fn lt(&self, other: &Metadata<'a>) -> bool
[src]fn le(&self, other: &Metadata<'a>) -> bool
[src]fn gt(&self, other: &Metadata<'a>) -> bool
[src]fn ge(&self, other: &Metadata<'a>) -> bool
[src]impl<'a> StructuralEq for Metadata<'a>
[src]impl<'a> StructuralPartialEq for Metadata<'a>
[src]impl<'a> RefUnwindSafe for Metadata<'a>
impl<'a> Send for Metadata<'a>
impl<'a> Sync for Metadata<'a>
impl<'a> Unpin for Metadata<'a>
impl<'a> UnwindSafe for Metadata<'a>
impl<T> Any for T where
T: 'static + ?Sized,
[src]impl<T> Borrow<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]impl<T> From<T> for T
[src]impl<T, U> Into<U> for T where
U: From<T>,
[src]impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
The resulting type after obtaining ownership.
+pub fn to_owned(&self) -> T
[src]pub fn clone_into(&self, target: &mut T)
[src]impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]type Error = Infallible
The type returned in the event of a conversion error.
+pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]Builder for Metadata
.
Typically should only be used by log library creators or for testing and "shim loggers".
+The MetadataBuilder
can set the different parameters of a Metadata
object, and returns
+the created object when build
is called.
+let target = "myApp"; +use log::{Level, MetadataBuilder}; +let metadata = MetadataBuilder::new() + .level(Level::Debug) + .target(target) + .build();
impl<'a> MetadataBuilder<'a>
[src]pub fn new() -> MetadataBuilder<'a>
[src]Construct a new MetadataBuilder
.
The default options are:
+level
: Level::Info
target
: ""
pub fn level(&mut self, arg: Level) -> &mut MetadataBuilder<'a>
[src]Setter for level
.
pub fn target(&mut self, target: &'a str) -> &mut MetadataBuilder<'a>
[src]Setter for target
.
pub fn build(&self) -> Metadata<'a>
[src]Returns a Metadata
object.
impl<'a> Debug for MetadataBuilder<'a>
[src]impl<'a> Eq for MetadataBuilder<'a>
[src]impl<'a> Hash for MetadataBuilder<'a>
[src]fn hash<__H: Hasher>(&self, state: &mut __H)
[src]fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]impl<'a> Ord for MetadataBuilder<'a>
[src]fn cmp(&self, other: &MetadataBuilder<'a>) -> Ordering
[src]#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]impl<'a> PartialEq<MetadataBuilder<'a>> for MetadataBuilder<'a>
[src]fn eq(&self, other: &MetadataBuilder<'a>) -> bool
[src]fn ne(&self, other: &MetadataBuilder<'a>) -> bool
[src]impl<'a> PartialOrd<MetadataBuilder<'a>> for MetadataBuilder<'a>
[src]fn partial_cmp(&self, other: &MetadataBuilder<'a>) -> Option<Ordering>
[src]fn lt(&self, other: &MetadataBuilder<'a>) -> bool
[src]fn le(&self, other: &MetadataBuilder<'a>) -> bool
[src]fn gt(&self, other: &MetadataBuilder<'a>) -> bool
[src]fn ge(&self, other: &MetadataBuilder<'a>) -> bool
[src]impl<'a> StructuralEq for MetadataBuilder<'a>
[src]impl<'a> StructuralPartialEq for MetadataBuilder<'a>
[src]impl<'a> RefUnwindSafe for MetadataBuilder<'a>
impl<'a> Send for MetadataBuilder<'a>
impl<'a> Sync for MetadataBuilder<'a>
impl<'a> Unpin for MetadataBuilder<'a>
impl<'a> UnwindSafe for MetadataBuilder<'a>
impl<T> Any for T where
T: 'static + ?Sized,
[src]impl<T> Borrow<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]impl<T> From<T> for T
[src]impl<T, U> Into<U> for T where
U: From<T>,
[src]impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]type Error = Infallible
The type returned in the event of a conversion error.
+pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]The type returned by from_str
when the string doesn't match any of the log levels.
impl Debug for ParseLevelError
[src]impl Display for ParseLevelError
[src]impl Error for ParseLevelError
[src]fn source(&self) -> Option<&(dyn Error + 'static)>
1.30.0[src]fn backtrace(&self) -> Option<&Backtrace>
[src]fn description(&self) -> &str
1.0.0[src]fn cause(&self) -> Option<&dyn Error>
1.0.0[src]impl PartialEq<ParseLevelError> for ParseLevelError
[src]fn eq(&self, other: &ParseLevelError) -> bool
[src]fn ne(&self, other: &ParseLevelError) -> bool
[src]impl StructuralPartialEq for ParseLevelError
[src]impl RefUnwindSafe for ParseLevelError
impl Send for ParseLevelError
impl Sync for ParseLevelError
impl Unpin for ParseLevelError
impl UnwindSafe for ParseLevelError
impl<T> Any for T where
T: 'static + ?Sized,
[src]impl<T> Borrow<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]impl<T> From<T> for T
[src]impl<T, U> Into<U> for T where
U: From<T>,
[src]impl<T> ToString for T where
T: Display + ?Sized,
[src]impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]type Error = Infallible
The type returned in the event of a conversion error.
+pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]The "payload" of a log message.
+Record
structures are passed as parameters to the log
+method of the Log
trait. Logger implementors manipulate these
+structures in order to display log messages. Record
s are automatically
+created by the log!
macro and so are not seen by log users.
Note that the level()
and target()
accessors are equivalent to
+self.metadata().level()
and self.metadata().target()
respectively.
+These methods are provided as a convenience for users of this structure.
The following example shows a simple logger that displays the level,
+module path, and message of any Record
that is passed to it.
+struct SimpleLogger; + +impl log::Log for SimpleLogger { + fn enabled(&self, metadata: &log::Metadata) -> bool { + true + } + + fn log(&self, record: &log::Record) { + if !self.enabled(record.metadata()) { + return; + } + + println!("{}:{} -- {}", + record.level(), + record.target(), + record.args()); + } + fn flush(&self) {} +}
impl<'a> Record<'a>
[src]pub fn builder() -> RecordBuilder<'a>
[src]Returns a new builder.
+pub fn args(&self) -> &Arguments<'a>
[src]The message body.
+pub fn metadata(&self) -> &Metadata<'a>
[src]Metadata about the log directive.
+pub fn level(&self) -> Level
[src]The verbosity level of the message.
+pub fn target(&self) -> &'a str
[src]The name of the target of the directive.
+pub fn module_path(&self) -> Option<&'a str>
[src]The module path of the message.
+pub fn module_path_static(&self) -> Option<&'static str>
[src]The module path of the message, if it is a 'static
string.
pub fn file(&self) -> Option<&'a str>
[src]The source file containing the message.
+pub fn file_static(&self) -> Option<&'static str>
[src]The module path of the message, if it is a 'static
string.
pub fn line(&self) -> Option<u32>
[src]The line containing the message.
+impl<'a> !RefUnwindSafe for Record<'a>
impl<'a> !Send for Record<'a>
impl<'a> !Sync for Record<'a>
impl<'a> Unpin for Record<'a>
impl<'a> !UnwindSafe for Record<'a>
impl<T> Any for T where
T: 'static + ?Sized,
[src]impl<T> Borrow<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]impl<T> From<T> for T
[src]impl<T, U> Into<U> for T where
U: From<T>,
[src]impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
The resulting type after obtaining ownership.
+pub fn to_owned(&self) -> T
[src]pub fn clone_into(&self, target: &mut T)
[src]impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]type Error = Infallible
The type returned in the event of a conversion error.
+pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]Builder for Record
.
Typically should only be used by log library creators or for testing and "shim loggers".
+The RecordBuilder
can set the different parameters of Record
object, and returns
+the created object when build
is called.
+use log::{Level, Record}; + +let record = Record::builder() + .args(format_args!("Error!")) + .level(Level::Error) + .target("myApp") + .file(Some("server.rs")) + .line(Some(144)) + .module_path(Some("server")) + .build();
Alternatively, use MetadataBuilder
:
+use log::{Record, Level, MetadataBuilder}; + +let error_metadata = MetadataBuilder::new() + .target("myApp") + .level(Level::Error) + .build(); + +let record = Record::builder() + .metadata(error_metadata) + .args(format_args!("Error!")) + .line(Some(433)) + .file(Some("app.rs")) + .module_path(Some("server")) + .build();
impl<'a> RecordBuilder<'a>
[src]pub fn new() -> RecordBuilder<'a>
[src]Construct new RecordBuilder
.
The default options are:
+args
: format_args!("")
metadata
: Metadata::builder().build()
module_path
: None
file
: None
line
: None
pub fn args(&mut self, args: Arguments<'a>) -> &mut RecordBuilder<'a>
[src]Set args
.
pub fn metadata(&mut self, metadata: Metadata<'a>) -> &mut RecordBuilder<'a>
[src]Set metadata
. Construct a Metadata
object with MetadataBuilder
.
pub fn level(&mut self, level: Level) -> &mut RecordBuilder<'a>
[src]Set Metadata::level
.
pub fn target(&mut self, target: &'a str) -> &mut RecordBuilder<'a>
[src]Set Metadata::target
pub fn module_path(&mut self, path: Option<&'a str>) -> &mut RecordBuilder<'a>
[src]Set module_path
pub fn module_path_static(
&mut self,
path: Option<&'static str>
) -> &mut RecordBuilder<'a>
[src]Set module_path
to a 'static
string
pub fn file(&mut self, file: Option<&'a str>) -> &mut RecordBuilder<'a>
[src]Set file
pub fn file_static(
&mut self,
file: Option<&'static str>
) -> &mut RecordBuilder<'a>
[src]Set file
to a 'static
string.
pub fn line(&mut self, line: Option<u32>) -> &mut RecordBuilder<'a>
[src]Set line
pub fn build(&self) -> Record<'a>
[src]Invoke the builder and return a Record
impl<'a> !RefUnwindSafe for RecordBuilder<'a>
impl<'a> !Send for RecordBuilder<'a>
impl<'a> !Sync for RecordBuilder<'a>
impl<'a> Unpin for RecordBuilder<'a>
impl<'a> !UnwindSafe for RecordBuilder<'a>
impl<T> Any for T where
T: 'static + ?Sized,
[src]impl<T> Borrow<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]impl<T> From<T> for T
[src]impl<T, U> Into<U> for T where
U: From<T>,
[src]impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]type Error = Infallible
The type returned in the event of a conversion error.
+pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]The type returned by set_logger
if set_logger
has already been called.
impl Debug for SetLoggerError
[src]impl Display for SetLoggerError
[src]impl Error for SetLoggerError
[src]impl RefUnwindSafe for SetLoggerError
impl Send for SetLoggerError
impl Sync for SetLoggerError
impl Unpin for SetLoggerError
impl UnwindSafe for SetLoggerError
impl<T> Any for T where
T: 'static + ?Sized,
[src]impl<T> Borrow<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]impl<T> From<T> for T
[src]impl<T, U> Into<U> for T where
U: From<T>,
[src]impl<T> ToString for T where
T: Display + ?Sized,
[src]impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]type Error = Infallible
The type returned in the event of a conversion error.
+pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]A trait encapsulating the operations required of a logger.
+fn enabled(&self, metadata: &Metadata<'_>) -> bool
Determines if a log message with the specified metadata would be +logged.
+This is used by the log_enabled!
macro to allow callers to avoid
+expensive computation of log message arguments if the message would be
+discarded anyway.
fn log(&self, record: &Record<'_>)
Logs the Record
.
Note that enabled
is not necessarily called before this method.
+Implementations of log
should perform all necessary filtering
+internally.
fn flush(&self)
Flushes any buffered records.
+The BlockRngCore
trait and implementation helpers
The BlockRngCore
trait exists to assist in the implementation of RNGs
+which generate a block of data in a cache instead of returning generated
+values directly.
Usage of this trait is optional, but provides two advantages:
+implementations only need to concern themselves with generation of the
+block, not the various RngCore
methods (especially fill_bytes
, where
+the optimal implementations are not trivial), and this allows
+ReseedingRng
(see rand
crate) perform periodic
+reseeding with very low overhead.
use rand_core::block::{BlockRngCore, BlockRng};
+
+struct MyRngCore;
+
+impl BlockRngCore for MyRngCore {
+ type Results = [u32; 16];
+
+ fn generate(&mut self, results: &mut Self::Results) {
+ unimplemented!()
+ }
+}
+
+impl SeedableRng for MyRngCore {
+ type Seed = unimplemented!();
+ fn from_seed(seed: Self::Seed) -> Self {
+ unimplemented!()
+ }
+}
+
+// optionally, also implement CryptoRng for MyRngCore
+
+// Final RNG.
+type MyRng = BlockRng<u32, MyRngCore>;
+
+BlockRng | A wrapper type implementing |
BlockRng64 | A wrapper type implementing |
BlockRngCore | A trait for RNGs which do not generate random numbers individually, but in
+blocks (typically |
A wrapper type implementing RngCore
for some type implementing
+BlockRngCore
with u32
array buffer; i.e. this can be used to implement
+a full RNG from just a generate
function.
The core
field may be accessed directly but the results buffer may not.
+PRNG implementations can simply use a type alias
+(pub type MyRng = BlockRng<MyRngCore>;
) but might prefer to use a
+wrapper type (pub struct MyRng(BlockRng<MyRngCore>);
); the latter must
+re-implement RngCore
but hides the implementation details and allows
+extra functionality to be defined on the RNG
+(e.g. impl MyRng { fn set_stream(...){...} }
).
BlockRng
has heavily optimized implementations of the RngCore
methods
+reading values from the results buffer, as well as
+calling BlockRngCore::generate
directly on the output array when
+fill_bytes
/ try_fill_bytes
is called on a large array. These methods
+also handle the bookkeeping of when to generate a new batch of values.
No whole generated u32
values are thown away and all values are consumed
+in-order. next_u32
simply takes the next available u32
value.
+next_u64
is implemented by combining two u32
values, least
+significant first. fill_bytes
and try_fill_bytes
consume a whole
+number of u32
values, converting each u32
to a byte slice in
+little-endian order. If the requested byte length is not a multiple of 4,
+some bytes will be discarded.
See also BlockRng64
which uses u64
array buffers. Currently there is
+no direct support for other buffer types.
For easy initialization BlockRng
also implements SeedableRng
.
core: R
The core part of the RNG, implementing the generate
function.
impl<R: BlockRngCore> BlockRng<R>
[src]pub fn new(core: R) -> BlockRng<R>
[src]Create a new BlockRng
from an existing RNG implementing
+BlockRngCore
. Results will be generated on first use.
pub fn index(&self) -> usize
[src]Get the index into the result buffer.
+If this is equal to or larger than the size of the result buffer then
+the buffer is "empty" and generate()
must be called to produce new
+results.
pub fn reset(&mut self)
[src]Reset the number of available results. +This will force a new set of results to be generated on next use.
+pub fn generate_and_set(&mut self, index: usize)
[src]Generate a new set of results immediately, setting the index to the +given value.
+impl<R: Clone + BlockRngCore + ?Sized> Clone for BlockRng<R> where
R::Results: Clone,
[src]impl<R: BlockRngCore + CryptoRng> CryptoRng for BlockRng<R>
[src]impl<R: BlockRngCore + Debug> Debug for BlockRng<R>
[src]impl<R: BlockRngCore<Item = u32>> RngCore for BlockRng<R> where
<R as BlockRngCore>::Results: AsRef<[u32]> + AsMut<[u32]>,
[src]fn next_u32(&mut self) -> u32
[src]fn next_u64(&mut self) -> u64
[src]fn fill_bytes(&mut self, dest: &mut [u8])
[src]fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error>
[src]impl<R: BlockRngCore + SeedableRng> SeedableRng for BlockRng<R>
[src]type Seed = R::Seed
Seed type, which is restricted to types mutably-dereferencable as u8
+arrays (we recommend [u8; N]
for some N
). Read more
fn from_seed(seed: Self::Seed) -> Self
[src]fn seed_from_u64(seed: u64) -> Self
[src]fn from_rng<S: RngCore>(rng: S) -> Result<Self, Error>
[src]fn from_entropy() -> Self
[src]impl<R: ?Sized> RefUnwindSafe for BlockRng<R> where
R: RefUnwindSafe,
<R as BlockRngCore>::Results: RefUnwindSafe,
impl<R: ?Sized> Send for BlockRng<R> where
R: Send,
<R as BlockRngCore>::Results: Send,
impl<R: ?Sized> Sync for BlockRng<R> where
R: Sync,
<R as BlockRngCore>::Results: Sync,
impl<R: ?Sized> Unpin for BlockRng<R> where
R: Unpin,
<R as BlockRngCore>::Results: Unpin,
impl<R: ?Sized> UnwindSafe for BlockRng<R> where
R: UnwindSafe,
<R as BlockRngCore>::Results: UnwindSafe,
impl<T> Any for T where
T: 'static + ?Sized,
[src]impl<T> Borrow<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]impl<T> From<T> for T
[src]impl<T, U> Into<U> for T where
U: From<T>,
[src]impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
The resulting type after obtaining ownership.
+pub fn to_owned(&self) -> T
[src]pub fn clone_into(&self, target: &mut T)
[src]impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]type Error = Infallible
The type returned in the event of a conversion error.
+pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]A wrapper type implementing RngCore
for some type implementing
+BlockRngCore
with u64
array buffer; i.e. this can be used to implement
+a full RNG from just a generate
function.
This is similar to BlockRng
, but specialized for algorithms that operate
+on u64
values.
No whole generated u64
values are thrown away and all values are consumed
+in-order. next_u64
simply takes the next available u64
value.
+next_u32
is however a bit special: half of a u64
is consumed, leaving
+the other half in the buffer. If the next function called is next_u32
+then the other half is then consumed, however both next_u64
and
+fill_bytes
discard the rest of any half-consumed u64
s when called.
fill_bytes
and try_fill_bytes
consume a whole number of u64
+values. If the requested length is not a multiple of 8, some bytes will be
+discarded.
core: R
The core part of the RNG, implementing the generate
function.
impl<R: BlockRngCore> BlockRng64<R>
[src]pub fn new(core: R) -> BlockRng64<R>
[src]Create a new BlockRng
from an existing RNG implementing
+BlockRngCore
. Results will be generated on first use.
pub fn index(&self) -> usize
[src]Get the index into the result buffer.
+If this is equal to or larger than the size of the result buffer then
+the buffer is "empty" and generate()
must be called to produce new
+results.
pub fn reset(&mut self)
[src]Reset the number of available results. +This will force a new set of results to be generated on next use.
+pub fn generate_and_set(&mut self, index: usize)
[src]Generate a new set of results immediately, setting the index to the +given value.
+impl<R: Clone + BlockRngCore + ?Sized> Clone for BlockRng64<R> where
R::Results: Clone,
[src]fn clone(&self) -> BlockRng64<R>
[src]fn clone_from(&mut self, source: &Self)
1.0.0[src]impl<R: BlockRngCore + Debug> Debug for BlockRng64<R>
[src]impl<R: BlockRngCore<Item = u64>> RngCore for BlockRng64<R> where
<R as BlockRngCore>::Results: AsRef<[u64]> + AsMut<[u64]>,
[src]fn next_u32(&mut self) -> u32
[src]fn next_u64(&mut self) -> u64
[src]fn fill_bytes(&mut self, dest: &mut [u8])
[src]fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error>
[src]impl<R: BlockRngCore + SeedableRng> SeedableRng for BlockRng64<R>
[src]type Seed = R::Seed
Seed type, which is restricted to types mutably-dereferencable as u8
+arrays (we recommend [u8; N]
for some N
). Read more
fn from_seed(seed: Self::Seed) -> Self
[src]fn seed_from_u64(seed: u64) -> Self
[src]fn from_rng<S: RngCore>(rng: S) -> Result<Self, Error>
[src]fn from_entropy() -> Self
[src]impl<R: ?Sized> RefUnwindSafe for BlockRng64<R> where
R: RefUnwindSafe,
<R as BlockRngCore>::Results: RefUnwindSafe,
impl<R: ?Sized> Send for BlockRng64<R> where
R: Send,
<R as BlockRngCore>::Results: Send,
impl<R: ?Sized> Sync for BlockRng64<R> where
R: Sync,
<R as BlockRngCore>::Results: Sync,
impl<R: ?Sized> Unpin for BlockRng64<R> where
R: Unpin,
<R as BlockRngCore>::Results: Unpin,
impl<R: ?Sized> UnwindSafe for BlockRng64<R> where
R: UnwindSafe,
<R as BlockRngCore>::Results: UnwindSafe,
impl<T> Any for T where
T: 'static + ?Sized,
[src]impl<T> Borrow<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]impl<T> From<T> for T
[src]impl<T, U> Into<U> for T where
U: From<T>,
[src]impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
The resulting type after obtaining ownership.
+pub fn to_owned(&self) -> T
[src]pub fn clone_into(&self, target: &mut T)
[src]impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]type Error = Infallible
The type returned in the event of a conversion error.
+pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]A trait for RNGs which do not generate random numbers individually, but in
+blocks (typically [u32; N]
). This technique is commonly used by
+cryptographic RNGs to improve performance.
See the module documentation for details.
+type Item
Results element type, e.g. u32
.
type Results: AsRef<[Self::Item]> + AsMut<[Self::Item]> + Default
Results type. This is the 'block' an RNG implementing BlockRngCore
+generates, which will usually be an array like [u32; 16]
.
Redirecting to ../../rand_core/struct.Error.html...
+ + + \ No newline at end of file diff --git a/tests/html/1.49.0/rand_core/impls/fn.fill_bytes_via_next.html b/tests/html/1.49.0/rand_core/impls/fn.fill_bytes_via_next.html new file mode 100644 index 0000000..329267b --- /dev/null +++ b/tests/html/1.49.0/rand_core/impls/fn.fill_bytes_via_next.html @@ -0,0 +1,7 @@ +pub fn fill_bytes_via_next<R: RngCore + ?Sized>(rng: &mut R, dest: &mut [u8])
Implement fill_bytes
via next_u64
and next_u32
, little-endian order.
The fastest way to fill a slice is usually to work as long as possible with
+integers. That is why this method mostly uses next_u64
, and only when
+there are 4 or less bytes remaining at the end of the slice it uses
+next_u32
once.
pub fn fill_via_u32_chunks(src: &[u32], dest: &mut [u8]) -> (usize, usize)
Implement fill_bytes
by reading chunks from the output buffer of a block
+based RNG.
The return values are (consumed_u32, filled_u8)
.
filled_u8
is the number of filled bytes in dest
, which may be less than
+the length of dest
.
+consumed_u32
is the number of words consumed from src
, which is the same
+as filled_u8 / 4
rounded up.
(from IsaacRng
)
+fn fill_bytes(&mut self, dest: &mut [u8]) { + let mut read_len = 0; + while read_len < dest.len() { + if self.index >= self.rsl.len() { + self.isaac(); + } + + let (consumed_u32, filled_u8) = + impls::fill_via_u32_chunks(&mut self.rsl[self.index..], + &mut dest[read_len..]); + + self.index += consumed_u32; + read_len += filled_u8; + } +}
pub fn fill_via_u64_chunks(src: &[u64], dest: &mut [u8]) -> (usize, usize)
Implement fill_bytes
by reading chunks from the output buffer of a block
+based RNG.
The return values are (consumed_u64, filled_u8)
.
+filled_u8
is the number of filled bytes in dest
, which may be less than
+the length of dest
.
+consumed_u64
is the number of words consumed from src
, which is the same
+as filled_u8 / 8
rounded up.
See fill_via_u32_chunks
for an example.
pub fn next_u32_via_fill<R: RngCore + ?Sized>(rng: &mut R) -> u32
Implement next_u32
via fill_bytes
, little-endian order.
pub fn next_u64_via_fill<R: RngCore + ?Sized>(rng: &mut R) -> u64
Implement next_u64
via fill_bytes
, little-endian order.
pub fn next_u64_via_u32<R: RngCore + ?Sized>(rng: &mut R) -> u64
Implement next_u64
via next_u32
, little-endian order.
Helper functions for implementing RngCore
functions.
For cross-platform reproducibility, these functions all use Little Endian:
+least-significant part first. For example, next_u64_via_u32
takes u32
+values x, y
, then outputs (y << 32) | x
. To implement next_u32
+from next_u64
in little-endian order, one should use next_u64() as u32
.
Byte-swapping (like the std to_le
functions) is only needed to convert
+to/from byte sequences, and since its purpose is reproducibility,
+non-reproducible sources (e.g. OsRng
) need not bother with it.
fill_bytes_via_next | Implement |
fill_via_u32_chunks | Implement |
fill_via_u64_chunks | Implement |
next_u32_via_fill | Implement |
next_u64_via_fill | Implement |
next_u64_via_u32 | Implement |
Random number generation traits
+This crate is mainly of interest to crates publishing implementations of
+RngCore
. Other users are encouraged to use the rand
crate instead
+which re-exports the main traits and error types.
RngCore
is the core trait implemented by algorithmic pseudo-random number
+generators and external random-number sources.
SeedableRng
is an extension trait for construction from fixed seeds and
+other random number generators.
Error
is provided for error-handling. It is safe to use in no_std
+environments.
The impls
and le
sub-modules include a few small functions to assist
+implementation of RngCore
.
block | The |
impls | Helper functions for implementing |
le | Little-Endian utilities + |
Error | Error type of random number generators + |
OsRng | A random number generator that retrieves randomness from from the +operating system. + |
CryptoRng | A marker trait used to indicate that an |
RngCore | The core of a random number generator. + |
SeedableRng | A random number generator that can be explicitly seeded. + |
pub fn read_u32_into(src: &[u8], dst: &mut [u32])
Reads unsigned 32 bit integers from src
into dst
.
+Borrowed from the byteorder
crate.
pub fn read_u64_into(src: &[u8], dst: &mut [u64])
Reads unsigned 64 bit integers from src
into dst
.
+Borrowed from the byteorder
crate.
Little-Endian utilities
+Little-Endian order has been chosen for internal usage; this makes some +useful functions available.
+read_u32_into | Reads unsigned 32 bit integers from |
read_u64_into | Reads unsigned 64 bit integers from |
Redirecting to ../../rand_core/struct.OsRng.html...
+ + + \ No newline at end of file diff --git a/tests/html/1.49.0/rand_core/sidebar-items.js b/tests/html/1.49.0/rand_core/sidebar-items.js new file mode 100644 index 0000000..36b365a --- /dev/null +++ b/tests/html/1.49.0/rand_core/sidebar-items.js @@ -0,0 +1 @@ +initSidebarItems({"mod":[["block","The `BlockRngCore` trait and implementation helpers"],["impls","Helper functions for implementing `RngCore` functions."],["le","Little-Endian utilities"]],"struct":[["Error","Error type of random number generators"],["OsRng","A random number generator that retrieves randomness from from the operating system."]],"trait":[["CryptoRng","A marker trait used to indicate that an [`RngCore`] or `BlockRngCore` implementation is supposed to be cryptographically secure."],["RngCore","The core of a random number generator."],["SeedableRng","A random number generator that can be explicitly seeded."]]}); \ No newline at end of file diff --git a/tests/html/1.49.0/rand_core/struct.Error.html b/tests/html/1.49.0/rand_core/struct.Error.html new file mode 100644 index 0000000..dcf2a4f --- /dev/null +++ b/tests/html/1.49.0/rand_core/struct.Error.html @@ -0,0 +1,47 @@ +Error type of random number generators
+In order to be compatible with std
and no_std
, this type has two
+possible implementations: with std
a boxed Error
trait object is stored,
+while with no_std
we merely store an error code.
impl Error
[src]pub fn new<E>(err: E) -> Self where
E: Into<Box<dyn Error + Send + Sync + 'static>>,
[src]Construct from any type supporting std::error::Error
Available only when configured with std
.
See also From<NonZeroU32>
, which is available with and without std
.
pub fn inner(&self) -> &(dyn Error + Send + Sync + 'static)
[src]Reference the inner error (std
only)
When configured with std
, this is a trivial operation and never
+panics. Without std
, this method is simply unavailable.
pub fn take_inner(self) -> Box<dyn Error + Send + Sync + 'static>
[src]Unwrap the inner error (std
only)
When configured with std
, this is a trivial operation and never
+panics. Without std
, this method is simply unavailable.
pub const INTERNAL_START: u32
[src]Codes below this point represent OS Errors (i.e. positive i32 values).
+Codes at or above this point, but below Error::CUSTOM_START
are
+reserved for use by the rand
and getrandom
crates.
pub const CUSTOM_START: u32
[src]Codes at or above this point can be used by users to define their own +custom errors.
+pub fn raw_os_error(&self) -> Option<i32>
[src]Extract the raw OS error code (if this error came from the OS)
+This method is identical to std::io::Error::raw_os_error()
, except
+that it works in no_std
contexts. If this method returns None
, the
+error value can still be formatted via the Diplay
implementation.
pub fn code(&self) -> Option<NonZeroU32>
[src]Retrieve the error code, if any.
+If this Error
was constructed via From<NonZeroU32>
, then this method
+will return this NonZeroU32
code (for no_std
this is always the
+case). Otherwise, this method will return None
.
impl Debug for Error
[src]impl Display for Error
[src]impl Error for Error
[src]fn source(&self) -> Option<&(dyn Error + 'static)>
[src]fn backtrace(&self) -> Option<&Backtrace>
[src]fn description(&self) -> &str
1.0.0[src]fn cause(&self) -> Option<&dyn Error>
1.0.0[src]impl From<Error> for Error
[src]impl From<Error> for Error
[src]impl From<NonZeroU32> for Error
[src]fn from(code: NonZeroU32) -> Self
[src]impl !RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl !UnwindSafe for Error
impl<T> Any for T where
T: 'static + ?Sized,
[src]impl<T> Borrow<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]impl<T> From<T> for T
[src]impl<T, U> Into<U> for T where
U: From<T>,
[src]impl<T> ToString for T where
T: Display + ?Sized,
[src]impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]type Error = Infallible
The type returned in the event of a conversion error.
+pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]A random number generator that retrieves randomness from from the +operating system.
+This is a zero-sized struct. It can be freely constructed with OsRng
.
The implementation is provided by the getrandom crate. Refer to +getrandom documentation for details.
+This struct is only available when specifying the crate feature getrandom
+or std
. When using the rand
lib, it is also available as rand::rngs::OsRng
.
It is possible that when used during early boot the first call to OsRng
+will block until the system's RNG is initialised. It is also possible
+(though highly unlikely) for OsRng
to fail on some platforms, most
+likely due to system mis-configuration.
After the first successful call, it is highly unlikely that failures or +significant delays will occur (although performance should be expected to +be much slower than a user-space PRNG).
++use rand_core::{RngCore, OsRng}; + +let mut key = [0u8; 16]; +OsRng.fill_bytes(&mut key); +let random_u64 = OsRng.next_u64();
impl Clone for OsRng
[src]impl Copy for OsRng
[src]impl CryptoRng for OsRng
[src]impl Debug for OsRng
[src]impl Default for OsRng
[src]impl RngCore for OsRng
[src]impl RefUnwindSafe for OsRng
impl Send for OsRng
impl Sync for OsRng
impl Unpin for OsRng
impl UnwindSafe for OsRng
impl<T> Any for T where
T: 'static + ?Sized,
[src]impl<T> Borrow<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]impl<T> From<T> for T
[src]impl<T, U> Into<U> for T where
U: From<T>,
[src]impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
The resulting type after obtaining ownership.
+pub fn to_owned(&self) -> T
[src]pub fn clone_into(&self, target: &mut T)
[src]impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]type Error = Infallible
The type returned in the event of a conversion error.
+pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]A marker trait used to indicate that an RngCore
or BlockRngCore
+implementation is supposed to be cryptographically secure.
Cryptographically secure generators, also known as CSPRNGs, should +satisfy an additional properties over other generators: given the first +k bits of an algorithm's output +sequence, it should not be possible using polynomial-time algorithms to +predict the next bit with probability significantly greater than 50%.
+Some generators may satisfy an additional property, however this is not +required by this trait: if the CSPRNG's state is revealed, it should not be +computationally-feasible to reconstruct output prior to this. Some other +generators allow backwards-computation and are consided reversible.
+Note that this trait is provided for guidance only and cannot guarantee +suitability for cryptographic applications. In general it should only be +implemented for well-reviewed code implementing well-regarded algorithms.
+Note also that use of a CryptoRng
does not protect against other
+weaknesses such as seeding from a weak entropy source or leaking state.
impl<'a, R: CryptoRng + ?Sized> CryptoRng for &'a mut R
[src]impl<R: CryptoRng + ?Sized> CryptoRng for Box<R>
[src]The core of a random number generator.
+This trait encapsulates the low-level functionality common to all
+generators, and is the "back end", to be implemented by generators.
+End users should normally use the Rng
trait from the rand
crate,
+which is automatically implemented for every type implementing RngCore
.
Three different methods for generating random data are provided since the
+optimal implementation of each is dependent on the type of generator. There
+is no required relationship between the output of each; e.g. many
+implementations of fill_bytes
consume a whole number of u32
or u64
+values and drop any remaining unused bytes.
The try_fill_bytes
method is a variant of fill_bytes
allowing error
+handling; it is not deemed sufficiently useful to add equivalents for
+next_u32
or next_u64
since the latter methods are almost always used
+with algorithmic generators (PRNGs), which are normally infallible.
Algorithmic generators implementing SeedableRng
should normally have
+portable, reproducible output, i.e. fix Endianness when converting values
+to avoid platform differences, and avoid making any changes which affect
+output (except by communicating that the release has breaking changes).
Typically implementators will implement only one of the methods available
+in this trait directly, then use the helper functions from the
+impls
module to implement the other methods.
It is recommended that implementations also implement:
+Debug
with a custom implementation which does not print any internal
+state (at least, CryptoRng
s should not risk leaking state through
+Debug
).Serialize
and Deserialize
(from Serde), preferably making Serde
+support optional at the crate level in PRNG libs.Clone
, if possible.Copy
(accidental copies may cause repeated values).Default
for pseudorandom generators, but instead
+implement SeedableRng
, to guide users towards proper seeding.
+External / hardware RNGs can choose to implement Default
.Eq
and PartialEq
could be implemented, but are probably not useful.A simple example, obviously not generating very random output:
+ ++#![allow(dead_code)] +use rand_core::{RngCore, Error, impls}; + +struct CountingRng(u64); + +impl RngCore for CountingRng { + fn next_u32(&mut self) -> u32 { + self.next_u64() as u32 + } + + fn next_u64(&mut self) -> u64 { + self.0 += 1; + self.0 + } + + fn fill_bytes(&mut self, dest: &mut [u8]) { + impls::fill_bytes_via_next(self, dest) + } + + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + Ok(self.fill_bytes(dest)) + } +}
fn next_u32(&mut self) -> u32
Return the next random u32
.
RNGs must implement at least one method from this trait directly. In
+the case this method is not implemented directly, it can be implemented
+using self.next_u64() as u32
or via
+fill_bytes
.
fn next_u64(&mut self) -> u64
Return the next random u64
.
RNGs must implement at least one method from this trait directly. In
+the case this method is not implemented directly, it can be implemented
+via next_u32
or via
+fill_bytes
.
fn fill_bytes(&mut self, dest: &mut [u8])
Fill dest
with random data.
RNGs must implement at least one method from this trait directly. In
+the case this method is not implemented directly, it can be implemented
+via next_u*
or
+via try_fill_bytes
; if this generator can
+fail the implementation must choose how best to handle errors here
+(e.g. panic with a descriptive message or log a warning and retry a few
+times).
This method should guarantee that dest
is entirely filled
+with new data, and may panic if this is impossible
+(e.g. reading past the end of a file that is being used as the
+source of randomness).
fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error>
Fill dest
entirely with random data.
This is the only method which allows an RNG to report errors while
+generating random data thus making this the primary method implemented
+by external (true) RNGs (e.g. OsRng
) which can fail. It may be used
+directly to generate keys and to seed (infallible) PRNGs.
Other than error handling, this method is identical to fill_bytes
;
+thus this may be implemented using Ok(self.fill_bytes(dest))
or
+fill_bytes
may be implemented with
+self.try_fill_bytes(dest).unwrap()
or more specific error handling.
impl Read for dyn RngCore
[src]fn read(&mut self, buf: &mut [u8]) -> Result<usize, Error>
[src]fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
1.36.0[src]fn is_read_vectored(&self) -> bool
[src]unsafe fn initializer(&self) -> Initializer
[src]fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
1.0.0[src]fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
1.0.0[src]fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
1.6.0[src]fn by_ref(&mut self) -> &mut Self
1.0.0[src]fn bytes(self) -> Bytes<Self>
1.0.0[src]fn chain<R>(self, next: R) -> Chain<Self, R> where
R: Read,
1.0.0[src]fn take(self, limit: u64) -> Take<Self>
1.0.0[src]impl<'a, R: RngCore + ?Sized> RngCore for &'a mut R
[src]fn next_u32(&mut self) -> u32
[src]fn next_u64(&mut self) -> u64
[src]fn fill_bytes(&mut self, dest: &mut [u8])
[src]fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error>
[src]impl<R: RngCore + ?Sized> RngCore for Box<R>
[src]fn next_u32(&mut self) -> u32
[src]fn next_u64(&mut self) -> u64
[src]fn fill_bytes(&mut self, dest: &mut [u8])
[src]fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error>
[src]impl RngCore for OsRng
[src]fn next_u32(&mut self) -> u32
[src]fn next_u64(&mut self) -> u64
[src]fn fill_bytes(&mut self, dest: &mut [u8])
[src]fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error>
[src]impl<R: BlockRngCore<Item = u32>> RngCore for BlockRng<R> where
<R as BlockRngCore>::Results: AsRef<[u32]> + AsMut<[u32]>,
[src]fn next_u32(&mut self) -> u32
[src]fn next_u64(&mut self) -> u64
[src]fn fill_bytes(&mut self, dest: &mut [u8])
[src]fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error>
[src]impl<R: BlockRngCore<Item = u64>> RngCore for BlockRng64<R> where
<R as BlockRngCore>::Results: AsRef<[u64]> + AsMut<[u64]>,
[src]A random number generator that can be explicitly seeded.
+This trait encapsulates the low-level functionality common to all +pseudo-random number generators (PRNGs, or algorithmic generators).
+type Seed: Sized + Default + AsMut<[u8]>
Seed type, which is restricted to types mutably-dereferencable as u8
+arrays (we recommend [u8; N]
for some N
).
It is recommended to seed PRNGs with a seed of at least circa 100 bits,
+which means an array of [u8; 12]
or greater to avoid picking RNGs with
+partially overlapping periods.
For cryptographic RNG's a seed of 256 bits is recommended, [u8; 32]
.
SeedableRng
for RNGs with large seedsNote that the required traits core::default::Default
and
+core::convert::AsMut<u8>
are not implemented for large arrays
+[u8; N]
with N
> 32. To be able to implement the traits required by
+SeedableRng
for RNGs with such large seeds, the newtype pattern can be
+used:
+use rand_core::SeedableRng; + +const N: usize = 64; +pub struct MyRngSeed(pub [u8; N]); +pub struct MyRng(MyRngSeed); + +impl Default for MyRngSeed { + fn default() -> MyRngSeed { + MyRngSeed([0; N]) + } +} + +impl AsMut<[u8]> for MyRngSeed { + fn as_mut(&mut self) -> &mut [u8] { + &mut self.0 + } +} + +impl SeedableRng for MyRng { + type Seed = MyRngSeed; + + fn from_seed(seed: MyRngSeed) -> MyRng { + MyRng(seed) + } +}
fn from_seed(seed: Self::Seed) -> Self
Create a new PRNG using the given seed.
+PRNG implementations are allowed to assume that bits in the seed are
+well distributed. That means usually that the number of one and zero
+bits are roughly equal, and values like 0, 1 and (size - 1) are unlikely.
+Note that many non-cryptographic PRNGs will show poor quality output
+if this is not adhered to. If you wish to seed from simple numbers, use
+seed_from_u64
instead.
All PRNG implementations should be reproducible unless otherwise noted:
+given a fixed seed
, the same sequence of output should be produced
+on all runs, library versions and architectures (e.g. check endianness).
+Any "value-breaking" changes to the generator should require bumping at
+least the minor version and documentation of the change.
It is not required that this function yield the same state as a +reference implementation of the PRNG given equivalent seed; if necessary +another constructor replicating behaviour from a reference +implementation can be added.
+PRNG implementations should make sure from_seed
never panics. In the
+case that some special values (like an all zero seed) are not viable
+seeds it is preferable to map these to alternative constant value(s),
+for example 0xBAD5EEDu32
or 0x0DDB1A5E5BAD5EEDu64
("odd biases? bad
+seed"). This is assuming only a small number of values must be rejected.
fn seed_from_u64(state: u64) -> Self
Create a new PRNG using a u64
seed.
This is a convenience-wrapper around from_seed
to allow construction
+of any SeedableRng
from a simple u64
value. It is designed such that
+low Hamming Weight numbers like 0 and 1 can be used and should still
+result in good, independent seeds to the PRNG which is returned.
This is not suitable for cryptography, as should be clear given that +the input size is only 64 bits.
+Implementations for PRNGs may provide their own implementations of +this function, but the default implementation should be good enough for +all purposes. Changing the implementation of this function should be +considered a value-breaking change.
+fn from_rng<R: RngCore>(rng: R) -> Result<Self, Error>
Create a new PRNG seeded from another Rng
.
This may be useful when needing to rapidly seed many PRNGs from a master +PRNG, and to allow forking of PRNGs. It may be considered deterministic.
+The master PRNG should be at least as high quality as the child PRNGs.
+When seeding non-cryptographic child PRNGs, we recommend using a
+different algorithm for the master PRNG (ideally a CSPRNG) to avoid
+correlations between the child PRNGs. If this is not possible (e.g.
+forking using small non-crypto PRNGs) ensure that your PRNG has a good
+mixing function on the output or consider use of a hash function with
+from_seed
.
Note that seeding XorShiftRng
from another XorShiftRng
provides an
+extreme example of what can go wrong: the new PRNG will be a clone
+of the parent.
PRNG implementations are allowed to assume that a good RNG is provided
+for seeding, and that it is cryptographically secure when appropriate.
+As of rand
0.7 / rand_core
0.5, implementations overriding this
+method should ensure the implementation satisfies reproducibility
+(in prior versions this was not required).
fn from_entropy() -> Self
Creates a new instance of the RNG seeded via getrandom
.
This method is the recommended way to construct non-deterministic PRNGs +since it is convenient and secure.
+In case the overhead of using getrandom
to seed many PRNGs is an
+issue, one may prefer to seed from a local PRNG, e.g.
+from_rng(thread_rng()).unwrap()
.
If getrandom
is unable to provide secure entropy this method will panic.
impl<R: BlockRngCore + SeedableRng> SeedableRng for BlockRng64<R>
[src]type Seed = R::Seed
fn from_seed(seed: Self::Seed) -> Self
[src]fn seed_from_u64(seed: u64) -> Self
[src]fn from_rng<S: RngCore>(rng: S) -> Result<Self, Error>
[src]impl<R: BlockRngCore + SeedableRng> SeedableRng for BlockRng<R>
[src]