pub struct LoggerConfigBuilder { /* private fields */ }Implementations§
Source§impl LoggerConfigBuilder
impl LoggerConfigBuilder
Sourcepub fn show_file_info(self, show: bool) -> Self
pub fn show_file_info(self, show: bool) -> Self
Examples found in repository?
examples/stdout_only.rs (line 17)
13fn main() {
14 // Initialize logger with stdout only (no file output) with colors
15 let config = LoggerConfig::builder()
16 .level(LevelFilter::Debug) // Show Debug level and above
17 .show_file_info(false) // Don't show file and line information
18 .use_colors(true) // Use colors in output
19 .build();
20
21 if let Err(e) = init_stdout_logger(config) {
22 eprintln!("Failed to initialize logger: {e}");
23 return;
24 }
25
26 println!("Logger initialized! Output will only appear on stdout.");
27 println!("Notice that TRACE level messages won't show because we set Debug as minimum level.");
28 println!("Also note that file and line information is hidden for cleaner output.");
29
30 // Log messages at different levels to demonstrate filtering
31 trace!("This is a TRACE message - you won't see this");
32 debug!("This is a DEBUG message - visible");
33 info!("This is an INFO message - visible");
34 warn!("This is a WARNING message - visible");
35 error!("This is an ERROR message - visible");
36
37 // Log messages with dynamic content
38 for i in 1..=3 {
39 let value = i * 10;
40 debug!("Debug calculation: {i} * 10 = {value}");
41 info!("Processing item #{i} with value {value}");
42 }
43
44 info!("Example completed");
45}More examples
examples/basic_usage.rs (line 23)
15fn main() {
16 // Initialize logger with file output and colored stdout
17 let log_path = "application.log";
18
19 // Create a custom configuration with the builder pattern
20 // This shows how to configure every aspect of the logger
21 let config = LoggerConfig::builder()
22 .level(LevelFilter::Trace) // Show all log levels, including TRACE
23 .show_file_info(true) // Include file and line info in logs
24 .show_date_in_stdout(false) // Only show time (HH:MM:SS) in console output
25 .use_colors(true) // Use colors for different log levels
26 .build();
27
28 if let Err(e) = init_logger_with_config(Some(log_path), config) {
29 eprintln!("Failed to initialize logger: {e}");
30 return;
31 }
32
33 println!("Logger initialized! Check {log_path} for log output.");
34 println!("Log messages will appear both on stdout and in the log file.");
35 println!("Notice that stdout logs show time only while the file includes dates.");
36
37 // Log messages at different levels to demonstrate the hierarchy
38 // All of these will appear because we set level to Trace
39 trace!("This is a TRACE message"); // Lowest level, normally hidden
40 debug!("This is a DEBUG message"); // For developer information
41 info!("This is an INFO message"); // Normal application events
42 warn!("This is a WARNING message"); // Important but non-critical issues
43 error!("This is an ERROR message"); // Critical issues that need attention
44
45 // Simulate some application activity
46 for i in 1..=5 {
47 info!("Application is running... iteration {i}");
48 sleep(Duration::from_millis(500));
49 }
50
51 // Log a final message
52 info!("Application finished successfully");
53
54 println!("\nAfter running this example, check the 'application.log' file");
55 println!("to see how logs are formatted differently for file output.");
56}examples/log_level_numeric.rs (line 47)
26fn main() {
27 // Read LOG_LEVEL from environment
28 let log_level = match std::env::var("LOG_LEVEL") {
29 Ok(level) => match level.parse::<u8>() {
30 Ok(level) => match level {
31 0 => LevelFilter::Off,
32 1 => LevelFilter::Error,
33 2 => LevelFilter::Warn,
34 3 => LevelFilter::Info,
35 4 => LevelFilter::Debug,
36 _ => LevelFilter::Trace,
37 },
38 Err(_) => LevelFilter::Warn,
39 },
40 Err(_) => LevelFilter::Warn,
41 };
42
43 // Configure logger with module filters
44 if let Err(e) = init_logger_with_config(
45 Some("log_level_numeric.log"),
46 LoggerConfig::builder()
47 .show_file_info(true)
48 .level(log_level)
49 .filter_module("log_level_numeric::noisy_library", LevelFilter::Error) // Only errors from noisy_library
50 .build(),
51 ) {
52 eprintln!("Failed to initialize logger: {}", e);
53 std::process::exit(1);
54 }
55
56 println!("=== LOG_LEVEL Numeric Example ===");
57 println!(
58 "Current LOG_LEVEL: {:?}",
59 std::env::var("LOG_LEVEL").unwrap_or_else(|_| "not set (using Warn)".to_string())
60 );
61 println!("Effective level: {:?}", log_level);
62 println!("\nLOG_LEVEL values:");
63 println!(" 0 = Off");
64 println!(" 1 = Error");
65 println!(" 2 = Warn");
66 println!(" 3 = Info");
67 println!(" 4 = Debug");
68 println!(" 5+ = Trace");
69 println!("\n--- Application Logs ---\n");
70
71 // Log messages at different levels
72 trace!("This is a TRACE message (level 5+)");
73 debug!("This is a DEBUG message (level 4)");
74 info!("This is an INFO message (level 3)");
75 warn!("This is a WARN message (level 2)");
76 error!("This is an ERROR message (level 1)");
77
78 // Call noisy library (its logs should be suppressed)
79 println!("\nCalling noisy_library (its logs are filtered to Error only):");
80 noisy_library::do_work();
81
82 println!("\n--- End of Logs ---");
83 println!("\nNote: Logs from 'noisy_library' are filtered to Error level only,");
84 println!("so you should not see its debug, info, or warn messages.");
85}Sourcepub fn show_date_in_stdout(self, show: bool) -> Self
pub fn show_date_in_stdout(self, show: bool) -> Self
Examples found in repository?
examples/basic_usage.rs (line 24)
15fn main() {
16 // Initialize logger with file output and colored stdout
17 let log_path = "application.log";
18
19 // Create a custom configuration with the builder pattern
20 // This shows how to configure every aspect of the logger
21 let config = LoggerConfig::builder()
22 .level(LevelFilter::Trace) // Show all log levels, including TRACE
23 .show_file_info(true) // Include file and line info in logs
24 .show_date_in_stdout(false) // Only show time (HH:MM:SS) in console output
25 .use_colors(true) // Use colors for different log levels
26 .build();
27
28 if let Err(e) = init_logger_with_config(Some(log_path), config) {
29 eprintln!("Failed to initialize logger: {e}");
30 return;
31 }
32
33 println!("Logger initialized! Check {log_path} for log output.");
34 println!("Log messages will appear both on stdout and in the log file.");
35 println!("Notice that stdout logs show time only while the file includes dates.");
36
37 // Log messages at different levels to demonstrate the hierarchy
38 // All of these will appear because we set level to Trace
39 trace!("This is a TRACE message"); // Lowest level, normally hidden
40 debug!("This is a DEBUG message"); // For developer information
41 info!("This is an INFO message"); // Normal application events
42 warn!("This is a WARNING message"); // Important but non-critical issues
43 error!("This is an ERROR message"); // Critical issues that need attention
44
45 // Simulate some application activity
46 for i in 1..=5 {
47 info!("Application is running... iteration {i}");
48 sleep(Duration::from_millis(500));
49 }
50
51 // Log a final message
52 info!("Application finished successfully");
53
54 println!("\nAfter running this example, check the 'application.log' file");
55 println!("to see how logs are formatted differently for file output.");
56}Sourcepub fn use_colors(self, use_colors: bool) -> Self
pub fn use_colors(self, use_colors: bool) -> Self
Examples found in repository?
examples/stdout_only.rs (line 18)
13fn main() {
14 // Initialize logger with stdout only (no file output) with colors
15 let config = LoggerConfig::builder()
16 .level(LevelFilter::Debug) // Show Debug level and above
17 .show_file_info(false) // Don't show file and line information
18 .use_colors(true) // Use colors in output
19 .build();
20
21 if let Err(e) = init_stdout_logger(config) {
22 eprintln!("Failed to initialize logger: {e}");
23 return;
24 }
25
26 println!("Logger initialized! Output will only appear on stdout.");
27 println!("Notice that TRACE level messages won't show because we set Debug as minimum level.");
28 println!("Also note that file and line information is hidden for cleaner output.");
29
30 // Log messages at different levels to demonstrate filtering
31 trace!("This is a TRACE message - you won't see this");
32 debug!("This is a DEBUG message - visible");
33 info!("This is an INFO message - visible");
34 warn!("This is a WARNING message - visible");
35 error!("This is an ERROR message - visible");
36
37 // Log messages with dynamic content
38 for i in 1..=3 {
39 let value = i * 10;
40 debug!("Debug calculation: {i} * 10 = {value}");
41 info!("Processing item #{i} with value {value}");
42 }
43
44 info!("Example completed");
45}More examples
examples/basic_usage.rs (line 25)
15fn main() {
16 // Initialize logger with file output and colored stdout
17 let log_path = "application.log";
18
19 // Create a custom configuration with the builder pattern
20 // This shows how to configure every aspect of the logger
21 let config = LoggerConfig::builder()
22 .level(LevelFilter::Trace) // Show all log levels, including TRACE
23 .show_file_info(true) // Include file and line info in logs
24 .show_date_in_stdout(false) // Only show time (HH:MM:SS) in console output
25 .use_colors(true) // Use colors for different log levels
26 .build();
27
28 if let Err(e) = init_logger_with_config(Some(log_path), config) {
29 eprintln!("Failed to initialize logger: {e}");
30 return;
31 }
32
33 println!("Logger initialized! Check {log_path} for log output.");
34 println!("Log messages will appear both on stdout and in the log file.");
35 println!("Notice that stdout logs show time only while the file includes dates.");
36
37 // Log messages at different levels to demonstrate the hierarchy
38 // All of these will appear because we set level to Trace
39 trace!("This is a TRACE message"); // Lowest level, normally hidden
40 debug!("This is a DEBUG message"); // For developer information
41 info!("This is an INFO message"); // Normal application events
42 warn!("This is a WARNING message"); // Important but non-critical issues
43 error!("This is an ERROR message"); // Critical issues that need attention
44
45 // Simulate some application activity
46 for i in 1..=5 {
47 info!("Application is running... iteration {i}");
48 sleep(Duration::from_millis(500));
49 }
50
51 // Log a final message
52 info!("Application finished successfully");
53
54 println!("\nAfter running this example, check the 'application.log' file");
55 println!("to see how logs are formatted differently for file output.");
56}Sourcepub fn level(self, level: LevelFilter) -> Self
pub fn level(self, level: LevelFilter) -> Self
Examples found in repository?
examples/stdout_only.rs (line 16)
13fn main() {
14 // Initialize logger with stdout only (no file output) with colors
15 let config = LoggerConfig::builder()
16 .level(LevelFilter::Debug) // Show Debug level and above
17 .show_file_info(false) // Don't show file and line information
18 .use_colors(true) // Use colors in output
19 .build();
20
21 if let Err(e) = init_stdout_logger(config) {
22 eprintln!("Failed to initialize logger: {e}");
23 return;
24 }
25
26 println!("Logger initialized! Output will only appear on stdout.");
27 println!("Notice that TRACE level messages won't show because we set Debug as minimum level.");
28 println!("Also note that file and line information is hidden for cleaner output.");
29
30 // Log messages at different levels to demonstrate filtering
31 trace!("This is a TRACE message - you won't see this");
32 debug!("This is a DEBUG message - visible");
33 info!("This is an INFO message - visible");
34 warn!("This is a WARNING message - visible");
35 error!("This is an ERROR message - visible");
36
37 // Log messages with dynamic content
38 for i in 1..=3 {
39 let value = i * 10;
40 debug!("Debug calculation: {i} * 10 = {value}");
41 info!("Processing item #{i} with value {value}");
42 }
43
44 info!("Example completed");
45}More examples
examples/basic_usage.rs (line 22)
15fn main() {
16 // Initialize logger with file output and colored stdout
17 let log_path = "application.log";
18
19 // Create a custom configuration with the builder pattern
20 // This shows how to configure every aspect of the logger
21 let config = LoggerConfig::builder()
22 .level(LevelFilter::Trace) // Show all log levels, including TRACE
23 .show_file_info(true) // Include file and line info in logs
24 .show_date_in_stdout(false) // Only show time (HH:MM:SS) in console output
25 .use_colors(true) // Use colors for different log levels
26 .build();
27
28 if let Err(e) = init_logger_with_config(Some(log_path), config) {
29 eprintln!("Failed to initialize logger: {e}");
30 return;
31 }
32
33 println!("Logger initialized! Check {log_path} for log output.");
34 println!("Log messages will appear both on stdout and in the log file.");
35 println!("Notice that stdout logs show time only while the file includes dates.");
36
37 // Log messages at different levels to demonstrate the hierarchy
38 // All of these will appear because we set level to Trace
39 trace!("This is a TRACE message"); // Lowest level, normally hidden
40 debug!("This is a DEBUG message"); // For developer information
41 info!("This is an INFO message"); // Normal application events
42 warn!("This is a WARNING message"); // Important but non-critical issues
43 error!("This is an ERROR message"); // Critical issues that need attention
44
45 // Simulate some application activity
46 for i in 1..=5 {
47 info!("Application is running... iteration {i}");
48 sleep(Duration::from_millis(500));
49 }
50
51 // Log a final message
52 info!("Application finished successfully");
53
54 println!("\nAfter running this example, check the 'application.log' file");
55 println!("to see how logs are formatted differently for file output.");
56}examples/log_level_numeric.rs (line 48)
26fn main() {
27 // Read LOG_LEVEL from environment
28 let log_level = match std::env::var("LOG_LEVEL") {
29 Ok(level) => match level.parse::<u8>() {
30 Ok(level) => match level {
31 0 => LevelFilter::Off,
32 1 => LevelFilter::Error,
33 2 => LevelFilter::Warn,
34 3 => LevelFilter::Info,
35 4 => LevelFilter::Debug,
36 _ => LevelFilter::Trace,
37 },
38 Err(_) => LevelFilter::Warn,
39 },
40 Err(_) => LevelFilter::Warn,
41 };
42
43 // Configure logger with module filters
44 if let Err(e) = init_logger_with_config(
45 Some("log_level_numeric.log"),
46 LoggerConfig::builder()
47 .show_file_info(true)
48 .level(log_level)
49 .filter_module("log_level_numeric::noisy_library", LevelFilter::Error) // Only errors from noisy_library
50 .build(),
51 ) {
52 eprintln!("Failed to initialize logger: {}", e);
53 std::process::exit(1);
54 }
55
56 println!("=== LOG_LEVEL Numeric Example ===");
57 println!(
58 "Current LOG_LEVEL: {:?}",
59 std::env::var("LOG_LEVEL").unwrap_or_else(|_| "not set (using Warn)".to_string())
60 );
61 println!("Effective level: {:?}", log_level);
62 println!("\nLOG_LEVEL values:");
63 println!(" 0 = Off");
64 println!(" 1 = Error");
65 println!(" 2 = Warn");
66 println!(" 3 = Info");
67 println!(" 4 = Debug");
68 println!(" 5+ = Trace");
69 println!("\n--- Application Logs ---\n");
70
71 // Log messages at different levels
72 trace!("This is a TRACE message (level 5+)");
73 debug!("This is a DEBUG message (level 4)");
74 info!("This is an INFO message (level 3)");
75 warn!("This is a WARN message (level 2)");
76 error!("This is an ERROR message (level 1)");
77
78 // Call noisy library (its logs should be suppressed)
79 println!("\nCalling noisy_library (its logs are filtered to Error only):");
80 noisy_library::do_work();
81
82 println!("\n--- End of Logs ---");
83 println!("\nNote: Logs from 'noisy_library' are filtered to Error level only,");
84 println!("so you should not see its debug, info, or warn messages.");
85}pub fn module_filters(self, filters: ModuleFilters) -> Self
Sourcepub fn filter_module(
self,
module: impl Into<String>,
level: LevelFilter,
) -> Self
pub fn filter_module( self, module: impl Into<String>, level: LevelFilter, ) -> Self
Add a filter for a specific module.
This is a convenience method to add module-level filters without creating a ModuleFilters struct manually.
§Example
use fstdout_logger::LoggerConfigBuilder;
use log::LevelFilter;
let config = LoggerConfigBuilder::default()
.filter_module("rustls", LevelFilter::Error)
.filter_module("tokio_rustls", LevelFilter::Error)
.build();Examples found in repository?
examples/log_level_numeric.rs (line 49)
26fn main() {
27 // Read LOG_LEVEL from environment
28 let log_level = match std::env::var("LOG_LEVEL") {
29 Ok(level) => match level.parse::<u8>() {
30 Ok(level) => match level {
31 0 => LevelFilter::Off,
32 1 => LevelFilter::Error,
33 2 => LevelFilter::Warn,
34 3 => LevelFilter::Info,
35 4 => LevelFilter::Debug,
36 _ => LevelFilter::Trace,
37 },
38 Err(_) => LevelFilter::Warn,
39 },
40 Err(_) => LevelFilter::Warn,
41 };
42
43 // Configure logger with module filters
44 if let Err(e) = init_logger_with_config(
45 Some("log_level_numeric.log"),
46 LoggerConfig::builder()
47 .show_file_info(true)
48 .level(log_level)
49 .filter_module("log_level_numeric::noisy_library", LevelFilter::Error) // Only errors from noisy_library
50 .build(),
51 ) {
52 eprintln!("Failed to initialize logger: {}", e);
53 std::process::exit(1);
54 }
55
56 println!("=== LOG_LEVEL Numeric Example ===");
57 println!(
58 "Current LOG_LEVEL: {:?}",
59 std::env::var("LOG_LEVEL").unwrap_or_else(|_| "not set (using Warn)".to_string())
60 );
61 println!("Effective level: {:?}", log_level);
62 println!("\nLOG_LEVEL values:");
63 println!(" 0 = Off");
64 println!(" 1 = Error");
65 println!(" 2 = Warn");
66 println!(" 3 = Info");
67 println!(" 4 = Debug");
68 println!(" 5+ = Trace");
69 println!("\n--- Application Logs ---\n");
70
71 // Log messages at different levels
72 trace!("This is a TRACE message (level 5+)");
73 debug!("This is a DEBUG message (level 4)");
74 info!("This is an INFO message (level 3)");
75 warn!("This is a WARN message (level 2)");
76 error!("This is an ERROR message (level 1)");
77
78 // Call noisy library (its logs should be suppressed)
79 println!("\nCalling noisy_library (its logs are filtered to Error only):");
80 noisy_library::do_work();
81
82 println!("\n--- End of Logs ---");
83 println!("\nNote: Logs from 'noisy_library' are filtered to Error level only,");
84 println!("so you should not see its debug, info, or warn messages.");
85}Sourcepub fn build(self) -> LoggerConfig
pub fn build(self) -> LoggerConfig
Examples found in repository?
examples/stdout_only.rs (line 19)
13fn main() {
14 // Initialize logger with stdout only (no file output) with colors
15 let config = LoggerConfig::builder()
16 .level(LevelFilter::Debug) // Show Debug level and above
17 .show_file_info(false) // Don't show file and line information
18 .use_colors(true) // Use colors in output
19 .build();
20
21 if let Err(e) = init_stdout_logger(config) {
22 eprintln!("Failed to initialize logger: {e}");
23 return;
24 }
25
26 println!("Logger initialized! Output will only appear on stdout.");
27 println!("Notice that TRACE level messages won't show because we set Debug as minimum level.");
28 println!("Also note that file and line information is hidden for cleaner output.");
29
30 // Log messages at different levels to demonstrate filtering
31 trace!("This is a TRACE message - you won't see this");
32 debug!("This is a DEBUG message - visible");
33 info!("This is an INFO message - visible");
34 warn!("This is a WARNING message - visible");
35 error!("This is an ERROR message - visible");
36
37 // Log messages with dynamic content
38 for i in 1..=3 {
39 let value = i * 10;
40 debug!("Debug calculation: {i} * 10 = {value}");
41 info!("Processing item #{i} with value {value}");
42 }
43
44 info!("Example completed");
45}More examples
examples/basic_usage.rs (line 26)
15fn main() {
16 // Initialize logger with file output and colored stdout
17 let log_path = "application.log";
18
19 // Create a custom configuration with the builder pattern
20 // This shows how to configure every aspect of the logger
21 let config = LoggerConfig::builder()
22 .level(LevelFilter::Trace) // Show all log levels, including TRACE
23 .show_file_info(true) // Include file and line info in logs
24 .show_date_in_stdout(false) // Only show time (HH:MM:SS) in console output
25 .use_colors(true) // Use colors for different log levels
26 .build();
27
28 if let Err(e) = init_logger_with_config(Some(log_path), config) {
29 eprintln!("Failed to initialize logger: {e}");
30 return;
31 }
32
33 println!("Logger initialized! Check {log_path} for log output.");
34 println!("Log messages will appear both on stdout and in the log file.");
35 println!("Notice that stdout logs show time only while the file includes dates.");
36
37 // Log messages at different levels to demonstrate the hierarchy
38 // All of these will appear because we set level to Trace
39 trace!("This is a TRACE message"); // Lowest level, normally hidden
40 debug!("This is a DEBUG message"); // For developer information
41 info!("This is an INFO message"); // Normal application events
42 warn!("This is a WARNING message"); // Important but non-critical issues
43 error!("This is an ERROR message"); // Critical issues that need attention
44
45 // Simulate some application activity
46 for i in 1..=5 {
47 info!("Application is running... iteration {i}");
48 sleep(Duration::from_millis(500));
49 }
50
51 // Log a final message
52 info!("Application finished successfully");
53
54 println!("\nAfter running this example, check the 'application.log' file");
55 println!("to see how logs are formatted differently for file output.");
56}examples/log_level_numeric.rs (line 50)
26fn main() {
27 // Read LOG_LEVEL from environment
28 let log_level = match std::env::var("LOG_LEVEL") {
29 Ok(level) => match level.parse::<u8>() {
30 Ok(level) => match level {
31 0 => LevelFilter::Off,
32 1 => LevelFilter::Error,
33 2 => LevelFilter::Warn,
34 3 => LevelFilter::Info,
35 4 => LevelFilter::Debug,
36 _ => LevelFilter::Trace,
37 },
38 Err(_) => LevelFilter::Warn,
39 },
40 Err(_) => LevelFilter::Warn,
41 };
42
43 // Configure logger with module filters
44 if let Err(e) = init_logger_with_config(
45 Some("log_level_numeric.log"),
46 LoggerConfig::builder()
47 .show_file_info(true)
48 .level(log_level)
49 .filter_module("log_level_numeric::noisy_library", LevelFilter::Error) // Only errors from noisy_library
50 .build(),
51 ) {
52 eprintln!("Failed to initialize logger: {}", e);
53 std::process::exit(1);
54 }
55
56 println!("=== LOG_LEVEL Numeric Example ===");
57 println!(
58 "Current LOG_LEVEL: {:?}",
59 std::env::var("LOG_LEVEL").unwrap_or_else(|_| "not set (using Warn)".to_string())
60 );
61 println!("Effective level: {:?}", log_level);
62 println!("\nLOG_LEVEL values:");
63 println!(" 0 = Off");
64 println!(" 1 = Error");
65 println!(" 2 = Warn");
66 println!(" 3 = Info");
67 println!(" 4 = Debug");
68 println!(" 5+ = Trace");
69 println!("\n--- Application Logs ---\n");
70
71 // Log messages at different levels
72 trace!("This is a TRACE message (level 5+)");
73 debug!("This is a DEBUG message (level 4)");
74 info!("This is an INFO message (level 3)");
75 warn!("This is a WARN message (level 2)");
76 error!("This is an ERROR message (level 1)");
77
78 // Call noisy library (its logs should be suppressed)
79 println!("\nCalling noisy_library (its logs are filtered to Error only):");
80 noisy_library::do_work();
81
82 println!("\n--- End of Logs ---");
83 println!("\nNote: Logs from 'noisy_library' are filtered to Error level only,");
84 println!("so you should not see its debug, info, or warn messages.");
85}Trait Implementations§
Source§impl Debug for LoggerConfigBuilder
impl Debug for LoggerConfigBuilder
Source§impl Default for LoggerConfigBuilder
impl Default for LoggerConfigBuilder
Source§fn default() -> LoggerConfigBuilder
fn default() -> LoggerConfigBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for LoggerConfigBuilder
impl RefUnwindSafe for LoggerConfigBuilder
impl Send for LoggerConfigBuilder
impl Sync for LoggerConfigBuilder
impl Unpin for LoggerConfigBuilder
impl UnwindSafe for LoggerConfigBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more