fn main() {
let filter = EnvFilter::new("warn,[custom_span]=warn"); // only prints warn inside of span, not
// outside
let filter = EnvFilter::new("info,[custom_span]=warn"); // prints everything, even info inside
// of span
let filter = EnvFilter::new("off,[custom_span]=warn"); // prints nothing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #[tracing::instrument(level = "trace", skip(self))] | |
| pub fn start(mut self) -> Result<()> { | |
| let stop_event = self.main_loop.loop_().add_event(|| { | |
| debug!("Stop message received!"); | |
| }); | |
| std::thread::spawn(move || loop { | |
| let main_loop = self.main_loop.clone(); | |
| let msg = self.control.blocking_recv(); | |
| match msg { |
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
extern int __real_fork();
int __wrap_fork() {
printf("wrap fork\n");
__real_fork();PdfLatex is a tool that converts Latex sources into PDF. This is specifically very important for researchers, as they use it to publish their findings. It could be installed very easily using Linux terminal, though this seems an annoying task on Windows. Installation commands are given below.
- Install the TexLive base
sudo apt-get install texlive-latex-base
- Also install the recommended and extra fonts to avoid running into the error [1], when trying to use pdflatex on latex files with more fonts.
Often times we want to verify that an object is fully built before using it. In many cases, this is done at runtime, in some sort of build() method. This is an implementation that verifies completeness using generics at compile time.
/*
* A builder pattern that checks if every field is set before building at compile-time.
* This means, no runtime checks, if it compiles, it's fully initialized. Thus, there's no
* overhead of checking if the struct is valid.
*
* (It comes at the cost of being a bit verbose, though ergonomics could be improved with a
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * We can use transmute and cast instead of creating a new Struct {...}. This | |
| * technically makes it so that we don't have to push all the fields into the new struct. | |
| * However, it's most definitely not worth it, as the compiler will optimize the code anyway by | |
| * inlining the variables. | |
| * This is also unsafe, although we could wrap it in a macro to guarantee that the types are | |
| * the same size and correctly aligned. | |
| * I am not writting that macro. | |
| * Check https://github.com/idanarye/rust-typed-builder for a similar implementation (doesn't use | |
| * transmute casts), therefore it doesn't need MaybeUninit, it's just uses "()" |
NewerOlder