Benign cargo Download

display.rs

Rust test marker or harness
SHA-25659a9ca41f5fe42be0db700a9180e58e33eaff7a08fcbfd7b24f0286544613915
MaleculeMd(Pa)

Evidence

imports std::fmt::Display lines 7–19
7:31… y::with_config(&data, base64::STANDARD);
8//!
9//! assert_eq!("base64: AAECAw==", format!("base64: {}", wrapper));
10//! ```
11
12use super::chunked_encoder::ChunkedEncoder;
13use super::Config;
14use std::fmt::{Display, Formatter};
15use std::{fmt, str};
16
17/// A convenience wrapper for base64'ing bytes into a format string without heap allocation.
18pub struct Base64Display<'a> {
19 …
English function-word token "the" lines 23–26
23:15… 4Display<'a> {
24 /// Create a `Base64Display` with the provided config.
25 pub fn with_config(bytes: &[u8], config: Config) -> Base64Display {
26 …
imports super::super::chunked_encoder::tests::chunked_encode_matches_normal_encode_random lines 48–66
48:39… mance is needed, write your own display wrapper that uses
49 // unsafe here to gain about 10-15%.
50 self.f
51 .write_str(str::from_utf8(encoded).expect("base64 data was not utf8"))
52 }
53}
54
55#[cfg(test)]
56mod tests {
57 use super::super::chunked_encoder::tests::{chunked_encode_matches_normal_encode_random,
58 SinkTestHelper};
59 use super::super::*;
60 use super::*;
61
62 #[test]
63 fn basic_display() {
64 assert_eq!(
65 "~$Zm9vYmFy#*",
66 format!("~${}#*", Base64Display::with_conf …

Keyboard shortcuts on this page: j for the next sample, k for the previous one, x to go back to the feed, d to download the original bytes, r to re-queue the sample for analysis.