Debian Codegraph @

examples/streaming.rs

raw symbols SCIP
1 #[allow(unused_imports)]
2 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::{stdinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/stdio/stdin()., Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#, Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#};
3
4 #[cfg(all(
5 feature = "public_imp",
6 any(target_arch = "x86", target_arch = "x86_64")
7 ))]
8 fn mainrust-analyzer cargo simdutf8 0.1.5 main().() -> Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()> {
9 use simdutf8rust-analyzer cargo simdutf8 0.1.5 crate/::basicrust-analyzer cargo simdutf8 0.1.5 basic/::imprust-analyzer cargo simdutf8 0.1.5 basic/imp/::Utf8Validatorrust-analyzer cargo simdutf8 0.1.5 basic/imp/Utf8Validator#;
10
11 unsafe {
12 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::is_x86_feature_detectedrust-analyzer cargo std_detect https://github.com/rust-lang/rust/library/ detect/arch/x86/is_x86_feature_detected!!("avx2") {
13 panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("This example only works with CPUs supporting AVX 2");
14 }
15
16 let mut validator = simdutf8rust-analyzer cargo simdutf8 0.1.5 crate/::basicrust-analyzer cargo simdutf8 0.1.5 basic/::imprust-analyzer cargo simdutf8 0.1.5 basic/imp/::x86rust-analyzer cargo simdutf8 0.1.5 basic/imp/x86/::avx2rust-analyzer cargo simdutf8 0.1.5 basic/imp/x86/avx2/::Utf8ValidatorImprust-analyzer cargo simdutf8 0.1.5 implementation/x86/avx2/Utf8ValidatorImp#::newrust-analyzer cargo simdutf8 0.1.5 implementation/x86/avx2/impl#[Utf8ValidatorImp][Utf8Validator]new().();
17 let mut buf = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![0; 8192];
18 loop {
19 let bytes_read = stdinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/stdio/stdin().().readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/stdio/impl#[Stdin][Read]read().(buf.as_mutrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`AsMut<[T]>`]as_mut().())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
20 if bytes_read rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().0 {
21 break;
22 }
23 validator.updaterust-analyzer cargo simdutf8 0.1.5 implementation/x86/avx2/impl#[Utf8ValidatorImp][Utf8Validator]update().(&buf);
24 }
25
26 if validator.finalizerust-analyzer cargo simdutf8 0.1.5 implementation/x86/avx2/impl#[Utf8ValidatorImp][Utf8Validator]finalize().().is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().() {
27 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("Input is valid UTF-8");
28 } else {
29 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("Input is not valid UTF-8");
30 }
31 }
32
33 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
34 }
35
36 /// Dummy main. This example requires the crate feature `public_imp`.
37 #[cfg(not(all(
38 feature = "public_imp",
39 any(target_arch = "x86", target_arch = "x86_64")
40 )))]
41 fn main() {}