Struct behold::Behold[][src]

pub struct Behold { /* fields omitted */ }

The core data structure - stores shared global context and instance specific configuration

Methods

impl Behold
[src]

Create a new Behold instance

Set the value of the global Behold context

Examples

use behold::behold;
behold().when_context("do-it").show("Hello world!".to_string())

Will output nothing.

use behold::behold;
behold().set_context("do-it", true);
behold().when_context("do-it").show("Hello world!".to_string())

Will produce the output:

This example is not tested
"Hello world!"

Return a Behold instance that appends output with the specified tag

Examples

use behold::behold;
behold().tag("apples").show("Hello world!".to_string());

Will produce the output:

This example is not tested
"Hello world!, apples"

Produce a behold instance which can speak up or not, depending on the parameter

Examples

use behold::behold;
behold().when(0 % 2 == 1).show("Hello world!".to_string())

Will output nothing.

use behold::behold;
behold().when(0 % 2 == 0).show("Hello world!".to_string())

Will output

This example is not tested
"Hello world!, apples"

Produce a behold instance which can speak up or not, depending on the specified context

Examples

use behold::behold;
behold().when_context("do-it").show("Hello world!".to_string())

Will output nothing.

use behold::behold;
behold().set_context("do-it", true);
behold().when_context("do-it").show("Hello world!".to_string())

Will output

This example is not tested
"Hello world!"

Print the provided string if this behold instance is configured to speak up

Examples

use behold::behold;
behold().show("Hello world!".to_string());

Will produce the output:

This example is not tested
"Hello world!"

Call the provided function if this behold instance is configured to speak up

Examples

use behold::behold;
behold().call(&|| { println!("Hello world!"); } );

Will output:

This example is not tested
"Hello world!"

Whereas the following:

 use behold::behold;
 behold().when(false).call(&|| { println!("Hello world!"); } );

Will output nothing.

Trait Implementations

impl Clone for Behold
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Auto Trait Implementations

impl Send for Behold

impl Sync for Behold