Julio Biason
1 year ago
9 changed files with 392 additions and 0 deletions
@ -0,0 +1,7 @@ |
|||||||
|
# This file is automatically @generated by Cargo. |
||||||
|
# It is not intended for manual editing. |
||||||
|
version = 3 |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "diritertest" |
||||||
|
version = "0.1.0" |
@ -0,0 +1,8 @@ |
|||||||
|
[package] |
||||||
|
name = "diritertest" |
||||||
|
version = "0.1.0" |
||||||
|
edition = "2021" |
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html |
||||||
|
|
||||||
|
[dependencies] |
@ -0,0 +1,3 @@ |
|||||||
|
# DirIterTest |
||||||
|
|
||||||
|
An iterator over directories (and subdirectories). |
@ -0,0 +1,48 @@ |
|||||||
|
//! Iterator over directories
|
||||||
|
|
||||||
|
use std::collections::VecDeque; |
||||||
|
use std::fs::DirEntry; |
||||||
|
use std::fs::ReadDir; |
||||||
|
use std::path::Path; |
||||||
|
use std::path::PathBuf; |
||||||
|
|
||||||
|
pub struct DirIter { |
||||||
|
curr_dir: ReadDir, |
||||||
|
remaining_dirs: VecDeque<PathBuf>, |
||||||
|
} |
||||||
|
|
||||||
|
impl DirIter { |
||||||
|
pub fn new(start: &Path) -> std::io::Result<Self> { |
||||||
|
Ok(Self { |
||||||
|
curr_dir: start.read_dir()?, |
||||||
|
remaining_dirs: VecDeque::new(), |
||||||
|
}) |
||||||
|
} |
||||||
|
|
||||||
|
pub fn advance(&mut self) -> Option<PathBuf> { |
||||||
|
let next = self.curr_dir.next(); |
||||||
|
match next { |
||||||
|
Some(Ok(x)) => { |
||||||
|
if x.path().is_dir() { |
||||||
|
self.remaining_dirs.push_back(x.path()); |
||||||
|
self.advance() |
||||||
|
} else { |
||||||
|
Some(x.path()) |
||||||
|
} |
||||||
|
} |
||||||
|
Some(Err(_)) | None => { |
||||||
|
let next_dir = self.remaining_dirs.pop_front()?; |
||||||
|
self.curr_dir = std::fs::read_dir(next_dir).ok()?; |
||||||
|
self.advance() |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
impl Iterator for DirIter { |
||||||
|
type Item = PathBuf; |
||||||
|
|
||||||
|
fn next(&mut self) -> Option<Self::Item> { |
||||||
|
self.advance() |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,21 @@ |
|||||||
|
use std::path::Path; |
||||||
|
|
||||||
|
use crate::diriter::DirIter; |
||||||
|
|
||||||
|
mod diriter; |
||||||
|
|
||||||
|
fn main() { |
||||||
|
let mut all_iter = DirIter::new(&Path::new(".")).unwrap(); |
||||||
|
while let Some(path) = all_iter.next() { |
||||||
|
println!(">> {:?}", path); |
||||||
|
} |
||||||
|
|
||||||
|
println!("-----------------------"); |
||||||
|
|
||||||
|
let all_iter = DirIter::new(&Path::new(".")).unwrap(); |
||||||
|
for path in all_iter { |
||||||
|
println!(">>> {:?}", path); |
||||||
|
} |
||||||
|
|
||||||
|
println!("Hello, world!"); |
||||||
|
} |
@ -0,0 +1,275 @@ |
|||||||
|
# This file is automatically @generated by Cargo. |
||||||
|
# It is not intended for manual editing. |
||||||
|
version = 3 |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "aho-corasick" |
||||||
|
version = "1.0.5" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "0c378d78423fdad8089616f827526ee33c19f2fddbd5de1629152c9593ba4783" |
||||||
|
dependencies = [ |
||||||
|
"memchr", |
||||||
|
] |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "cfg-if" |
||||||
|
version = "1.0.0" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "lazy_static" |
||||||
|
version = "1.4.0" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "log" |
||||||
|
version = "0.4.20" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "matchers" |
||||||
|
version = "0.1.0" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" |
||||||
|
dependencies = [ |
||||||
|
"regex-automata 0.1.10", |
||||||
|
] |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "memchr" |
||||||
|
version = "2.6.3" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c" |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "nu-ansi-term" |
||||||
|
version = "0.46.0" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" |
||||||
|
dependencies = [ |
||||||
|
"overload", |
||||||
|
"winapi", |
||||||
|
] |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "once_cell" |
||||||
|
version = "1.18.0" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "overload" |
||||||
|
version = "0.1.1" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "pin-project-lite" |
||||||
|
version = "0.2.13" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "proc-macro2" |
||||||
|
version = "1.0.67" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328" |
||||||
|
dependencies = [ |
||||||
|
"unicode-ident", |
||||||
|
] |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "quote" |
||||||
|
version = "1.0.33" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" |
||||||
|
dependencies = [ |
||||||
|
"proc-macro2", |
||||||
|
] |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "regex" |
||||||
|
version = "1.9.5" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "697061221ea1b4a94a624f67d0ae2bfe4e22b8a17b6a192afb11046542cc8c47" |
||||||
|
dependencies = [ |
||||||
|
"aho-corasick", |
||||||
|
"memchr", |
||||||
|
"regex-automata 0.3.8", |
||||||
|
"regex-syntax 0.7.5", |
||||||
|
] |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "regex-automata" |
||||||
|
version = "0.1.10" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" |
||||||
|
dependencies = [ |
||||||
|
"regex-syntax 0.6.29", |
||||||
|
] |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "regex-automata" |
||||||
|
version = "0.3.8" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "c2f401f4955220693b56f8ec66ee9c78abffd8d1c4f23dc41a23839eb88f0795" |
||||||
|
dependencies = [ |
||||||
|
"aho-corasick", |
||||||
|
"memchr", |
||||||
|
"regex-syntax 0.7.5", |
||||||
|
] |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "regex-syntax" |
||||||
|
version = "0.6.29" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "regex-syntax" |
||||||
|
version = "0.7.5" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "sharded-slab" |
||||||
|
version = "0.1.4" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31" |
||||||
|
dependencies = [ |
||||||
|
"lazy_static", |
||||||
|
] |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "smallvec" |
||||||
|
version = "1.11.0" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "syn" |
||||||
|
version = "2.0.35" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "59bf04c28bee9043ed9ea1e41afc0552288d3aba9c6efdd78903b802926f4879" |
||||||
|
dependencies = [ |
||||||
|
"proc-macro2", |
||||||
|
"quote", |
||||||
|
"unicode-ident", |
||||||
|
] |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "synctracingtest" |
||||||
|
version = "0.1.0" |
||||||
|
dependencies = [ |
||||||
|
"tracing", |
||||||
|
"tracing-subscriber", |
||||||
|
] |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "thread_local" |
||||||
|
version = "1.1.7" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" |
||||||
|
dependencies = [ |
||||||
|
"cfg-if", |
||||||
|
"once_cell", |
||||||
|
] |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "tracing" |
||||||
|
version = "0.1.37" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" |
||||||
|
dependencies = [ |
||||||
|
"cfg-if", |
||||||
|
"pin-project-lite", |
||||||
|
"tracing-attributes", |
||||||
|
"tracing-core", |
||||||
|
] |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "tracing-attributes" |
||||||
|
version = "0.1.26" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" |
||||||
|
dependencies = [ |
||||||
|
"proc-macro2", |
||||||
|
"quote", |
||||||
|
"syn", |
||||||
|
] |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "tracing-core" |
||||||
|
version = "0.1.31" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" |
||||||
|
dependencies = [ |
||||||
|
"once_cell", |
||||||
|
"valuable", |
||||||
|
] |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "tracing-log" |
||||||
|
version = "0.1.3" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" |
||||||
|
dependencies = [ |
||||||
|
"lazy_static", |
||||||
|
"log", |
||||||
|
"tracing-core", |
||||||
|
] |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "tracing-subscriber" |
||||||
|
version = "0.3.17" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "30a651bc37f915e81f087d86e62a18eec5f79550c7faff886f7090b4ea757c77" |
||||||
|
dependencies = [ |
||||||
|
"matchers", |
||||||
|
"nu-ansi-term", |
||||||
|
"once_cell", |
||||||
|
"regex", |
||||||
|
"sharded-slab", |
||||||
|
"smallvec", |
||||||
|
"thread_local", |
||||||
|
"tracing", |
||||||
|
"tracing-core", |
||||||
|
"tracing-log", |
||||||
|
] |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "unicode-ident" |
||||||
|
version = "1.0.12" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "valuable" |
||||||
|
version = "0.1.0" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "winapi" |
||||||
|
version = "0.3.9" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" |
||||||
|
dependencies = [ |
||||||
|
"winapi-i686-pc-windows-gnu", |
||||||
|
"winapi-x86_64-pc-windows-gnu", |
||||||
|
] |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "winapi-i686-pc-windows-gnu" |
||||||
|
version = "0.4.0" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" |
||||||
|
|
||||||
|
[[package]] |
||||||
|
name = "winapi-x86_64-pc-windows-gnu" |
||||||
|
version = "0.4.0" |
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index" |
||||||
|
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" |
@ -0,0 +1,10 @@ |
|||||||
|
[package] |
||||||
|
name = "synctracingtest" |
||||||
|
version = "0.1.0" |
||||||
|
edition = "2021" |
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html |
||||||
|
|
||||||
|
[dependencies] |
||||||
|
tracing = "0.1.37" |
||||||
|
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] } |
@ -0,0 +1,3 @@ |
|||||||
|
# SyncTracingTest |
||||||
|
|
||||||
|
Testing if `tracing` works when we are not in an async environment. |
@ -0,0 +1,17 @@ |
|||||||
|
use std::path::Path; |
||||||
|
|
||||||
|
use tracing_subscriber::prelude::*; |
||||||
|
|
||||||
|
fn main() { |
||||||
|
tracing_subscriber::registry() |
||||||
|
.with(tracing_subscriber::fmt::layer()) |
||||||
|
.with(tracing_subscriber::EnvFilter::from_default_env()) |
||||||
|
.init(); |
||||||
|
println!("Hello, world!"); |
||||||
|
|
||||||
|
let a = 2; |
||||||
|
let p = Path::new("pilulito"); |
||||||
|
|
||||||
|
tracing::debug!(a); |
||||||
|
tracing::info!(?p); |
||||||
|
} |
Loading…
Reference in new issue