Struct Logger

Source
pub struct Logger<T: IntoRunCondition> { /* private fields */ }
Expand description

A struct implementing IntoRunCondition which can be used to log a call to select. For more details you can visit the individual methods.

§Examples

let tree = Node::root().with_children(&[
    Node::new(false, 7).with_children(&[
        Node::new(true, 4),
        Node::new(true, 2),
    ]),
    Node::new(false, 5).with_children(&[
        Node::new(true, 8),
        Node::new(true, 9)
    ]),
]);

let mut bot = Bot::new(true);
let mut logger = Logger::new(ToCompletion);
assert_eq!(bot.select(&tree, &mut logger), Some(1));

assert_eq!(logger.depth(), 2);
// the total duration of `bot.select`
assert!(logger.duration() < Duration::from_secs(1));

Implementations§

Source§

impl<T: IntoRunCondition> Logger<T>

Source

pub fn new(condition: T) -> Self

Creates a new Logger wrapping condition.

Source

pub fn steps(&self) -> u32

Returns the total amount of times step was called during the last call to select.

Source

pub fn depth(&self) -> u32

Returns the deepest completed depth of the last call to select.

Source

pub fn completed(&self) -> bool

Returns true if last call to select was completed and false if it was cancelled by the run condition.

Source

pub fn duration(&self) -> Duration

Returns the total time spend during the last call to select.

Source

pub fn into_inner(self) -> T::RunCondition

consumes self and returns the wrapped condition

Trait Implementations§

Source§

impl<T: IntoRunCondition> Debug for Logger<T>
where T::RunCondition: Debug,

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'a, T: IntoRunCondition> IntoRunCondition for &'a mut Logger<T>

Source§

type RunCondition = InnerLogger<'a, T>

Source§

fn into_run_condition(self) -> InnerLogger<'a, T>

consumes self and returns a RunCondition.

Auto Trait Implementations§

§

impl<T> Freeze for Logger<T>

§

impl<T> RefUnwindSafe for Logger<T>

§

impl<T> Send for Logger<T>

§

impl<T> Sync for Logger<T>

§

impl<T> Unpin for Logger<T>

§

impl<T> UnwindSafe for Logger<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Tap for T

Source§

fn tap<F>(self, f: F) -> T
where F: FnOnce(&mut T),

Executes a closure on an object, returning it afterwards. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

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

Source§

type Error = <U as TryFrom<T>>::Error

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

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.