text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: MoeAl-Ani/authentication_microservice path: /src/entities/srp/srp_entities.rs use serde::{Deserialize, Serialize}; use serde_json; #[derive(Deserialize, Serialize, Debug)] pub struct Link { pub rel: String, pub href: String, } #[derive(Deserialize, Serialize, Debug)] pub struct SrpStep...
code_fim
medium
{ "lang": "rust", "repo": "MoeAl-Ani/authentication_microservice", "path": "/src/entities/srp/srp_entities.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Deserialize, Serialize, Debug)] pub struct SrpStep2Request { pub identity: String, pub m1_str: String, } #[derive(Deserialize, Serialize, Debug)] pub struct SrpStep2Response { pub m2_str: String, }<|fim_prefix|>// repo: MoeAl-Ani/authentication_microservice path: /src/entities/srp/s...
code_fim
medium
{ "lang": "rust", "repo": "MoeAl-Ani/authentication_microservice", "path": "/src/entities/srp/srp_entities.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Self { v4: sort_votes(votes_v4), v6: sort_votes(votes_v6), } } pub async fn get() -> Result<Self> { let http_source = Http::new()?; let ips = http_source.get_ips().await; Ok(Self::from_ips(ips)) } pub fn v4(&self) -> Option<...
code_fim
hard
{ "lang": "rust", "repo": "vladvasiliu/query_external_ip", "path": "/src/lib.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vladvasiliu/query_external_ip path: /src/lib.rs //! # query_external_ip //! //! Get the external IPv4 and IPv6 of the computer by querying online services. //! //! ## Example //! //! ``` //! use query_external_ip::Consensus; //! //! async fn get_ip() { //! match Consensus::get().await { //! ...
code_fim
hard
{ "lang": "rust", "repo": "vladvasiliu/query_external_ip", "path": "/src/lib.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: awforsythe/dscontrol-server path: /src/db.rs use std::env; use postgres::{Client, NoTls, Error}; fn var(name: &str, default: &str) -> String { <|fim_suffix|> let db_user = var("DB_USER", "postgres"); let db_pass = var("DB_PASS", ""); format!("postgresql://{}@{}:{}/{}", if db_...
code_fim
medium
{ "lang": "rust", "repo": "awforsythe/dscontrol-server", "path": "/src/db.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let db_user = var("DB_USER", "postgres"); let db_pass = var("DB_PASS", ""); format!("postgresql://{}@{}:{}/{}", if db_pass.is_empty() { db_user.to_owned() } else { format!("{}:{}", db_user, db_pass) }, var("DB_HOST", "localhost"), var("DB_PORT", "5432"), var("DB...
code_fim
medium
{ "lang": "rust", "repo": "awforsythe/dscontrol-server", "path": "/src/db.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dsbarnes/learning-rust path: /chapter8/list_of_numbers/src/lib.rs pub mod data_structures { use std::collections::HashMap; pub struct Numbers(Vec<i32>); impl Numbers { pub fn mean(&self) -> f32 { let sum: i32 = self.0.iter().sum(); sum as f32 / self...
code_fim
hard
{ "lang": "rust", "repo": "dsbarnes/learning-rust", "path": "/chapter8/list_of_numbers/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> numbers.iter().for_each(|(number, total)| { if total > &count { count = *total; result = **number; } }); result } } pub fn init(list: Vec<i32>) -> Numbers { Numbers(list) ...
code_fim
hard
{ "lang": "rust", "repo": "dsbarnes/learning-rust", "path": "/chapter8/list_of_numbers/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lunacookies/aoc-old path: /src/bin/houses.rs use aoc::houses::Moves; const INPUT: &str = include_str!("houses_input"); <|fim_suffix|> println!( "without Robo-Santa: {}", moves.num_houses_with_presents(false), ); println!("with Robo-Santa: {}", moves.num_houses_with_p...
code_fim
medium
{ "lang": "rust", "repo": "lunacookies/aoc-old", "path": "/src/bin/houses.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> println!( "without Robo-Santa: {}", moves.num_houses_with_presents(false), ); println!("with Robo-Santa: {}", moves.num_houses_with_presents(true)); }<|fim_prefix|>// repo: lunacookies/aoc-old path: /src/bin/houses.rs use aoc::houses::Moves; const INPUT: &str = include_str!("...
code_fim
medium
{ "lang": "rust", "repo": "lunacookies/aoc-old", "path": "/src/bin/houses.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let moves = Moves::new(INPUT.trim()).unwrap(); println!( "without Robo-Santa: {}", moves.num_houses_with_presents(false), ); println!("with Robo-Santa: {}", moves.num_houses_with_presents(true)); }<|fim_prefix|>// repo: lunacookies/aoc-old path: /src/bin/houses.rs use aoc...
code_fim
easy
{ "lang": "rust", "repo": "lunacookies/aoc-old", "path": "/src/bin/houses.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fluffypony/tari path: /base_layer/wallet/src/text_message_service/error.rs // Copyright 2019. The Tari Project // // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the // following conditions are met: // // 1. Redistributions of sourc...
code_fim
hard
{ "lang": "rust", "repo": "fluffypony/tari", "path": "/base_layer/wallet/src/text_message_service/error.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug, Error)] pub enum TextMessageError { MessageFormatError(MessageFormatError), MessageError(MessageError), OutboundError(DhtOutboundError), CommsServicesError(CommsError), HexError(HexError), DatabaseError(DieselError), TransportChannelError(TransportChannelError),...
code_fim
hard
{ "lang": "rust", "repo": "fluffypony/tari", "path": "/base_layer/wallet/src/text_message_service/error.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!( Lawn::parse("-1 3".to_string()), Err("Invalid width for Lawn in \"-1 3\" because of invalid digit found in string".to_string()) ); assert_eq!( Lawn::parse("ae 3".to_string()), Err("Invalid width for Lawn in \"ae 3\" because of invalid digit found in string".to_string()) ); ...
code_fim
hard
{ "lang": "rust", "repo": "joe-mojo/xke_rusty_mower", "path": "/src/lawn.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: joe-mojo/xke_rusty_mower path: /src/lawn.rs use std::num::ParseIntError; #[derive(Debug, Clone, PartialEq)] pub struct Lawn { pub width: usize, pub height: usize } fn parse_usize(maybe_line: Option<&str>, what: &str) -> Result<usize, String> { maybe_line.map(|wstr:&str| Ok(wstr)) .unwrap_...
code_fim
hard
{ "lang": "rust", "repo": "joe-mojo/xke_rusty_mower", "path": "/src/lawn.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn parse_should_return_the_right_error() { assert_eq!( Lawn::parse("-1 3".to_string()), Err("Invalid width for Lawn in \"-1 3\" because of invalid digit found in string".to_string()) ); assert_eq!( Lawn::parse("ae 3".to_string()), Err("Invalid width for Lawn in \"ae 3\" because...
code_fim
hard
{ "lang": "rust", "repo": "joe-mojo/xke_rusty_mower", "path": "/src/lawn.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zhiruchen/rust-code path: /enum-match/src/main.rs #[derive(Debug)] enum CNProvince { GanSu, HeBei, ShanDong, } #[derive(Debug)] enum Coin { Penny, Nickel, Dime, Quarter(CNProvince), } <|fim_suffix|> match coin { Coin::Penny => 1, Coin::Nickel => ...
code_fim
medium
{ "lang": "rust", "repo": "zhiruchen/rust-code", "path": "/enum-match/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match x { Some(i) => Some(i+1), None => None, } } fn main() { println!("{}", value_in_cents(Coin::Dime)); println!("{}", value_in_cents(Coin::Quarter(CNProvince::GanSu))); println!("Hello, world!"); let five = Some(5); let six = plus_one(five); let none =...
code_fim
medium
{ "lang": "rust", "repo": "zhiruchen/rust-code", "path": "/enum-match/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut list = vec![]; for (row, cells) in records.iter_rows().into_iter().enumerate() { for (col, text) in cells.into_iter().enumerate() { let text = text.as_ref().replace('\t', &" ".repeat(self.0)); list.push(((row, col), text)); } ...
code_fim
hard
{ "lang": "rust", "repo": "zhiburt/tabled", "path": "/tabled/src/settings/formatting/tab_size.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zhiburt/tabled path: /tabled/src/settings/formatting/tab_size.rs use crate::{ grid::records::{Records, RecordsMut}, settings::TableOption, }; /// Set a tab size. /// /// The size is used in order to calculate width correctly. /// /// Default value is 4 (basically 1 '\t' equals 4 spaces)...
code_fim
medium
{ "lang": "rust", "repo": "zhiburt/tabled", "path": "/tabled/src/settings/formatting/tab_size.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<R, D, C> TableOption<R, D, C> for TabSize where for<'a> &'a R: Records, R: RecordsMut<String>, { fn change(self, records: &mut R, _: &mut C, _: &mut D) { let mut list = vec![]; for (row, cells) in records.iter_rows().into_iter().enumerate() { for (col, text) in...
code_fim
medium
{ "lang": "rust", "repo": "zhiburt/tabled", "path": "/tabled/src/settings/formatting/tab_size.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn if_let() { let config_max = Some(3u8); if let Some(max) = config_max { println!("The maximum is configured to be {}", max); } }<|fim_prefix|>// repo: dev-bloke/examples path: /rust/simple/options/src/main.rs fn main() { simple_options(); if_let(); } fn simple_options() { <...
code_fim
hard
{ "lang": "rust", "repo": "dev-bloke/examples", "path": "/rust/simple/options/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dev-bloke/examples path: /rust/simple/options/src/main.rs fn main() { simple_options(); if_let(); } <|fim_suffix|> let config_max = Some(3u8); if let Some(max) = config_max { println!("The maximum is configured to be {}", max); } }<|fim_middle|>fn simple_options() { ...
code_fim
hard
{ "lang": "rust", "repo": "dev-bloke/examples", "path": "/rust/simple/options/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mexus/bluez-battery path: /src/device.rs use std::fmt; use anyhow::Result; use dbus::arg::RefArg; use regex::Regex; use crate::get_string_property; /// A device description. #[derive(Debug, Hash, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)] #[cfg_attr(feature = "with_serde", derive(serde::Se...
code_fim
hard
{ "lang": "rust", "repo": "mexus/bluez-battery", "path": "/src/device.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if let Some(alias) = &self.alias { if alias != &self.name { write!(f, "{} ({}, {})", alias, self.name, self.address) } else { write!(f, "{} ({})", alias, self.address) } } else { write!(f, "{} ({})", self.name,...
code_fim
hard
{ "lang": "rust", "repo": "mexus/bluez-battery", "path": "/src/device.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Hossein-Noroozpour/vulkust path: /vulkust/src/render/mesh.rs ons::BTreeMap; use std::mem::size_of; use std::sync::{Arc, RwLock, Weak}; use cgmath; use cgmath::prelude::*; use gltf; #[repr(u8)] #[cfg_attr(debug_mode, derive(Debug))] pub enum TypeId { Base = 1, } pub trait Mesh: Object { ...
code_fim
hard
{ "lang": "rust", "repo": "Hossein-Noroozpour/vulkust", "path": "/vulkust/src/render/mesh.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn new_with_gx3d(engine: &Engine, reader: &mut Gx3DReader, my_id: Id) -> Self { let number_of_vertex_attribute = reader.read_u8() as usize; #[cfg(debug_mode)] { if number_of_vertex_attribute != 12 { vx_unexpected!(); } } ...
code_fim
hard
{ "lang": "rust", "repo": "Hossein-Noroozpour/vulkust", "path": "/vulkust/src/render/mesh.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Hossein-Noroozpour/vulkust path: /vulkust/src/render/mesh.rs tatic as StaticBuffer; use super::command::Buffer as CmdBuffer; use super::engine::Engine; use super::object::{Base as ObjectBase, Object}; use std::collections::BTreeMap; use std::mem::size_of; use std::sync::{Arc, RwLock, Weak}; use...
code_fim
hard
{ "lang": "rust", "repo": "Hossein-Noroozpour/vulkust", "path": "/vulkust/src/render/mesh.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>se maybe //! for some use cases it can cause regressions. //! //! Cargo.toml: //! ```toml //! [dependencies] //! jemallocator = "0.1" //! ``` //! //! `your_code.rs`: //! ```rust //! #[global_allocator] //! static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; //! ```<|fim_prefix|>// repo: spaceja...
code_fim
hard
{ "lang": "rust", "repo": "spacejam/sled", "path": "/src/doc/performance_guide/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: spacejam/sled path: /src/doc/performance_guide/mod.rs //! ## Built-In Profiler //! //! To get a summary of latency histograms relating to different operations //! you've used on a sled database, sled can print a nice table when the Db is //! dropped by disabling the `no_metrics` default feature ...
code_fim
hard
{ "lang": "rust", "repo": "spacejam/sled", "path": "/src/doc/performance_guide/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: NovaDenizen/bitwise path: /build.rs extern crate rustc_version; use rustc_version::{version, version_meta, Channel}; <|fim_suffix|> // Set cfg flags depending on release channel match version_meta().unwrap().channel { Channel::Nightly => { println!("cargo:rustc-cfg=RU...
code_fim
medium
{ "lang": "rust", "repo": "NovaDenizen/bitwise", "path": "/build.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Set cfg flags depending on release channel match version_meta().unwrap().channel { Channel::Nightly => { println!("cargo:rustc-cfg=RUSTC_IS_NIGHTLY"); }, _ => {} }; }<|fim_prefix|>// repo: NovaDenizen/bitwise path: /build.rs extern crate rustc_version; u...
code_fim
medium
{ "lang": "rust", "repo": "NovaDenizen/bitwise", "path": "/build.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: parazodiac/Volans path: /src-rs/src/filter.rs use std::error::Error; use std::fs::File; use std::io::BufWriter; use std::io::Write; use std::path::Path; use clap::ArgMatches; use rust_htslib::bam; use rust_htslib::bam::{Read, Record}; use crate::fragments::Fragment; use itertools::Itertools; ...
code_fim
hard
{ "lang": "rust", "repo": "parazodiac/Volans", "path": "/src-rs/src/filter.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> false } fn is_chimeric(alignments: &[Record], counter: &mut FragStats) -> bool { assert_eq!(alignments.len(), 2); let mut aln = alignments.first().unwrap(); let mut maln = alignments.last().unwrap(); if aln.is_reverse() { std::mem::swap(&mut aln, &mut maln); } // both...
code_fim
hard
{ "lang": "rust", "repo": "parazodiac/Volans", "path": "/src-rs/src/filter.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: trevday/rust-raytracer path: /src/main.rs // Local modules mod aggregate; mod base; mod camera; mod color; mod material; mod matrix; mod pdf; mod point; mod progress; mod ray; mod resources; mod scene; mod shape; mod texture; mod transform; mod utils; mod vector; mod volume; // External/std lib...
code_fim
hard
{ "lang": "rust", "repo": "trevday/rust-raytracer", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> { let out_colors = &mut (*thread_colors .lock() .expect("Thread failed to acquire output data lock.")); out_colors[((x * res_y) + y) as usize] = out_colors[((x * res_y) + y) as usize] + pixel_color; } { ...
code_fim
hard
{ "lang": "rust", "repo": "trevday/rust-raytracer", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pi-pi3/julia-rs path: /examples/repl.rs extern crate julia; use std::io::{self, Write}; use julia::api::{Julia, Value}; fn main() { <|fim_suffix|> io::stdout().write_all(b">>> ").unwrap(); io::stdout().flush().unwrap(); io::stdin().read_line(&mut input).unwrap(); ...
code_fim
medium
{ "lang": "rust", "repo": "pi-pi3/julia-rs", "path": "/examples/repl.rs", "mode": "psm", "license": "Zlib", "source": "the-stack-v2" }
<|fim_suffix|> loop { let mut input = String::new(); io::stdout().write_all(b">>> ").unwrap(); io::stdout().flush().unwrap(); io::stdin().read_line(&mut input).unwrap(); let ret = jl.eval_string(&input).unwrap_or_else(|_| { println!("invalid expression"); ...
code_fim
medium
{ "lang": "rust", "repo": "pi-pi3/julia-rs", "path": "/examples/repl.rs", "mode": "spm", "license": "Zlib", "source": "the-stack-v2" }
<|fim_suffix|> let travis = Travis { language: "rust".to_string(), rust: vec!["stable".to_string(), "nightly".to_string()], env: vec![ "CRATE=boards/feather_m4 EXAMPLES=\"--example=blinky_basic --example=blinky_rtfm\"".to_string(), "CRATE=boards/gemma_m0 FEATURES=\"--features=u...
code_fim
hard
{ "lang": "rust", "repo": "keithduncan/travis-pipeline", "path": "/src/buildkite.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> agents }, env: env_for_travis_env(&env), soft_fail: Vec::new(), }; if let Some(allow) = travis.matrix.as_ref().and_then(|matrix| matrix.get("allow_failures")) { let optional = allow .iter() .any(|ref case| { // TODO make this generic for the iproduct fields if let So...
code_fim
hard
{ "lang": "rust", "repo": "keithduncan/travis-pipeline", "path": "/src/buildkite.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: keithduncan/travis-pipeline path: /src/buildkite.rs use std::{ collections::HashMap as Map, convert::From, }; use serde::Serialize; use super::travis::{self, Travis}; #[derive(Serialize, Debug, PartialEq, Eq)] pub struct Buildkite { steps: Vec<Step>, } #[derive(Serialize, Debug, PartialEq...
code_fim
hard
{ "lang": "rust", "repo": "keithduncan/travis-pipeline", "path": "/src/buildkite.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let node = Node { test: Some(String::from("test")), }; let xml = se::to_string(&node).unwrap(); assert_eq!( xml.as_str(), r#"<?xml version="1.0" encoding="UTF-8"?><Node><Child>test</Child></Node>"# ); assert_eq!(node, de::from_str::<Node>(xml.as_str()).unwra...
code_fim
hard
{ "lang": "rust", "repo": "QAQtutu/easy-xml", "path": "/easy-xml/tests/types.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[derive(PartialEq, Debug, XmlDeserialize, XmlSerialize)] struct Node { #[easy_xml(text)] test: Option<i32>, } let xml = r#"<Node>123</Node>"#; let node = de::from_str::<Node>(xml).unwrap(); assert_eq!(node.test, Some(123)); let xml = r#"<Node>err</Node>"#; ...
code_fim
hard
{ "lang": "rust", "repo": "QAQtutu/easy-xml", "path": "/easy-xml/tests/types.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: QAQtutu/easy-xml path: /easy-xml/tests/types.rs use easy_xml::{de, se}; #[macro_use] extern crate easy_xml_derive; #[test] fn test_for_option() { #[derive(PartialEq, Debug, XmlDeserialize, XmlSerialize)] struct Node { #[easy_xml(rename = "Child")] test: Option<String>, ...
code_fim
hard
{ "lang": "rust", "repo": "QAQtutu/easy-xml", "path": "/easy-xml/tests/types.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pragmatrix/tears path: /src/model.rs use crate::Cmd; /// A trait describing a model. pub trait Model<Msg: Send> { /// The update function updates the current state of the model. /// /// It applies uses the <|fim_suffix|>s meant to send back a Msg when finished. fn update(&mut se...
code_fim
medium
{ "lang": "rust", "repo": "pragmatrix/tears", "path": "/src/model.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>s meant to send back a Msg when finished. fn update(&mut self, msg: Msg) -> Cmd<Msg>; }<|fim_prefix|>// repo: pragmatrix/tears path: /src/model.rs use crate::Cmd; /// A trait describing a model. pub trait Model<Msg: Send> { /// The update function updates the current state of the model. /// ...
code_fim
medium
{ "lang": "rust", "repo": "pragmatrix/tears", "path": "/src/model.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// General index for a node in a merkle tree. pub type NodeIndex = u64; pub const BYTES_PER_CHUNK: usize = 32;<|fim_prefix|>// repo: jrhea/proof path: /src/lib.rs //! Merkle proof partials are a format for inclusion proofs of specific leaves in a merkle tree. //! //! This library is written to conform ...
code_fim
hard
{ "lang": "rust", "repo": "jrhea/proof", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jrhea/proof path: /src/lib.rs //! Merkle proof partials are a format for inclusion proofs of specific leaves in a merkle tree. //! //! This library is written to conform with the evolving Ethereum 2.0 specification for //! [merkle proofs](https://github.com/ethereum/eth2.0-specs/blob/dev/specs/l...
code_fim
medium
{ "lang": "rust", "repo": "jrhea/proof", "path": "/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: HelloYeew/taiko-rust path: /src/main.rs mod gameplay; mod consts; mod types; mod ui; mod score; use bevy::{input::system::exit_on_esc_system, prelude::*, diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin}}; use gameplay::NotesPlugin; use ui::UIPlugin; use score...
code_fim
medium
{ "lang": "rust", "repo": "HelloYeew/taiko-rust", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> App::build() // Set antialiasing to use 4 samples .insert_resource(Msaa { samples: 4 }) // Set WindowDescriptor Resource to change title and size .insert_resource(WindowDescriptor { title: "Taikrust".to_string(), width: 1366., height:...
code_fim
medium
{ "lang": "rust", "repo": "HelloYeew/taiko-rust", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match scope.paths().lookup(&name) { Some(path) => Ok(ExprVal::ImportPath(path)), None => { err.add( pos, format!("unresolved path \"{}\"", name) ); Err(Err(Failed)) } ...
code_fim
hard
{ "lang": "rust", "repo": "railwayhistory/railmap", "path": "/src/map/functions.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: railwayhistory/railmap path: /src/map/functions.rs /// The function we support during import. use femtomap::render::Color; use crate::import::Failed; use crate::import::eval; use crate::import::eval::ExprVal; use super::feature::label; use super::theme::Railwayhistory; /// All known functions...
code_fim
hard
{ "lang": "rust", "repo": "railwayhistory/railmap", "path": "/src/map/functions.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: k0pernicus/aoc2020 path: /ex18/src/main.rs #[macro_use] extern crate aoc_helper; use aoc_helper::commandline::AOCApp; use aoc_helper::file; use std::process; mod lib; use lib::expr; fn main() { <|fim_suffix|> let input_content = file::get_content::<String>(input_filename.unwrap()); if...
code_fim
medium
{ "lang": "rust", "repo": "k0pernicus/aoc2020", "path": "/ex18/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let args = get_app_args!(); let input_filename = args.get_input_filename(); let input_content = file::get_content::<String>(input_filename.unwrap()); if let Err(error) = input_content { println!("Got an error when reading input file: {}", error); process::exit(1); }; ...
code_fim
medium
{ "lang": "rust", "repo": "k0pernicus/aoc2020", "path": "/ex18/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: antifuchs/fibonacci_codec path: /src/lib.rs //! Traits and functions for encoding and decoding (slices of) //! positive integers using Fibonacci Coding. //! //! Fibonacci coding is a method for representing a continuous stream //! of (positive) integers using a variable number of bits -- e.g., /...
code_fim
hard
{ "lang": "rust", "repo": "antifuchs/fibonacci_codec", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>``` rust //! use fibonacci_codec::Encode; //! //! let numbers: Vec<u16> = vec![1, 50, 3003]; //! let encoded = &numbers.fib_encode().unwrap(); //! // code words: "11" (1), "001001011" (50), "000010010000100011" (3003) //! // These encoded words take up 4 bytes instead of 6 (3*16 bits)! //! assert_eq!(enco...
code_fim
hard
{ "lang": "rust", "repo": "antifuchs/fibonacci_codec", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pierreyoda/solar-rust path: /src/bin/main.rs mod app; mod blueprints; mod game; mod objects; mod render; mod textures; mod ui; extern crate rand; extern crate gfx_device_gl; extern crate piston_window; extern crate graphics; #[macro_use] extern crate conrod; <|fim_suffix|> match app::SolarR...
code_fim
easy
{ "lang": "rust", "repo": "pierreyoda/solar-rust", "path": "/src/bin/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match app::SolarRustApp::new().run() { Err(why) => println!("Error while running solar-rust:\n{}", why), Ok(_) => (), } }<|fim_prefix|>// repo: pierreyoda/solar-rust path: /src/bin/main.rs mod app; mod blueprints; mod game; mod objects; mod render; mod textures; mod ui; <|fim_mid...
code_fim
medium
{ "lang": "rust", "repo": "pierreyoda/solar-rust", "path": "/src/bin/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hussainhyder23/API-Rust-Actix path: /src/schema.rs table! { profiles (profileid) { profileid -> Int4, profilename -> Text, created_at -> Timestamp, userr_id -> Int4, } } <|fim_suffix|>allow_tables_to_appear_in_same_query!( profiles, users, );<|fim...
code_fim
hard
{ "lang": "rust", "repo": "hussainhyder23/API-Rust-Actix", "path": "/src/schema.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>allow_tables_to_appear_in_same_query!( profiles, users, );<|fim_prefix|>// repo: hussainhyder23/API-Rust-Actix path: /src/schema.rs table! { profiles (profileid) { profileid -> Int4, profilename -> Text, created_at -> Timestamp, userr_id -> Int4, } } <|fim...
code_fim
hard
{ "lang": "rust", "repo": "hussainhyder23/API-Rust-Actix", "path": "/src/schema.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn get() -> std::io::Result<ForemanConfig> { let sc = ShortCrypt::new(SECRET); let mut file = File::open("config")?; let mut encrypted_config = String::new(); file.read_to_string(&mut encrypted_config)?; let decripted_config = sc.decrypt_qr_code_alphanumeric(&encrypted_config).u...
code_fim
hard
{ "lang": "rust", "repo": "oknozor/spark-atelier-cli", "path": "/src/foreman_config.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let serialized = serde_json::to_string(&config).unwrap(); let sc = ShortCrypt::new(SECRET); let encrypted_file = sc.encrypt_to_qr_code_alphanumeric(&serialized); let mut file = File::create("config")?; file.write_all(encrypted_file.as_bytes())?; Ok(()) } pub fn get() -> std::io...
code_fim
hard
{ "lang": "rust", "repo": "oknozor/spark-atelier-cli", "path": "/src/foreman_config.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oknozor/spark-atelier-cli path: /src/foreman_config.rs use crate::dashboard::Team; use short_crypt::ShortCrypt; use std::fs; use std::fs::File; use std::io::prelude::*; const SECRET: &str = "LACLEFMEGALONGUEPOURCRYPTERLESTRUC"; #[derive(Serialize, Deserialize, Debug)] pub struct ForemanConfig ...
code_fim
hard
{ "lang": "rust", "repo": "oknozor/spark-atelier-cli", "path": "/src/foreman_config.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /third_party/rust_crates/vendor/base64ct-1.0.1/tests/url.rs //! URL-safe Base64 tests #[macro_use] mod common; /// URL-safe Base64 with `=` padding mod padded { use crate::common::*; use base64ct::Base64Url; const TEST_VECTORS: &[TestVector] = &[ Tes...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/third_party/rust_crates/vendor/base64ct-1.0.1/tests/url.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> let input = "QME/vQVMciqjwvIRc8Bp6kl9NSlrzCRl9vnQQQh716k\n"; let mut buf = [0u8; 1024]; assert_eq!( Base64UrlUnpadded::decode(input, &mut buf), Err(Error::InvalidEncoding) ); } #[test] fn unpadded_reject_trailing_equals() { let i...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/third_party/rust_crates/vendor/base64ct-1.0.1/tests/url.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|>/// URL-safe Base64 *without* padding mod unpadded { use crate::common::*; use base64ct::Base64UrlUnpadded; const TEST_VECTORS: &[TestVector] = &[ TestVector { raw: b"", b64: "" }, TestVector { raw: b"\0", b64: "AA", }, TestVector { ...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/third_party/rust_crates/vendor/base64ct-1.0.1/tests/url.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|>use its scoped let b = &mut a; *b += 2; } // a can still be used println!("{}", a); // this will work because of the ref for i in &z { println!("i = {}", i); // but we cannot do this z.push(5); } }<|fim_prefix|>// repo: ejfamanas/rust-trainin...
code_fim
hard
{ "lang": "rust", "repo": "ejfamanas/rust-training", "path": "/lifetime_and_memory/borrowing/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ejfamanas/rust-training path: /lifetime_and_memory/borrowing/src/main.rs fn main() { println!("Hello, world!"); // in this reference, the reference is immutable let print_vector = |x:&Vec<i32>| -> () { println!("{:?}", x); }; let v = vec![3,2,1]; // instead of let...
code_fim
hard
{ "lang": "rust", "repo": "ejfamanas/rust-training", "path": "/lifetime_and_memory/borrowing/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn trace_next_instruction(&mut self, pc: usize, instruction: u8, current_gas: U256) -> bool { //self.vm_tracer // .trace_next_instruction(pc, instruction, current_gas) true } fn trace_prepare_execute( &mut self, pc: usize, instruction: u8, ...
code_fim
hard
{ "lang": "rust", "repo": "nagarajmanjunath/durian", "path": "/src/stateless_ext.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> &mut self, gas: &U256, value: &U256, code: &[u8], parent_version: &U256, address_scheme: CreateContractAddress, trap: bool, ) -> ::std::result::Result<ContractCreateResult, TrapKind> { println!("hello"); Ok(ContractCreateResult::F...
code_fim
hard
{ "lang": "rust", "repo": "nagarajmanjunath/durian", "path": "/src/stateless_ext.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nagarajmanjunath/durian path: /src/stateless_ext.rs use std::{sync::Arc}; use ethereum_types::{Address, H256, U256}; use parity_bytes::Bytes; use machine::{ externalities::{OriginInfo, OutputPolicy}, substate::Substate, Machine, }; use state_provider::StateProvider; use trace::{Trace...
code_fim
hard
{ "lang": "rust", "repo": "nagarajmanjunath/durian", "path": "/src/stateless_ext.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>g network operations on Crypto.com Chain. Payments, on the //! other hand, are handled by `WalletClient` in `client-core` crate. pub mod network_ops; #[doc(inline)] pub use self::network_ops::NetworkOpsClient;<|fim_prefix|>// repo: leejw51crypto/chain path: /client-network/src/lib.rs #![deny(missing_doc...
code_fim
medium
{ "lang": "rust", "repo": "leejw51crypto/chain", "path": "/client-network/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: leejw51crypto/chain path: /client-network/src/lib.rs #![deny(missing_docs, unsafe_code, unstable_features)] //! Crypto.com Chain currently has two realms: //!<|fim_suffix|>in `client-core` crate. pub mod network_ops; #[doc(inline)] pub use self::network_ops::NetworkOpsClient;<|fim_middle|> //! ...
code_fim
hard
{ "lang": "rust", "repo": "leejw51crypto/chain", "path": "/client-network/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>in `client-core` crate. pub mod network_ops; #[doc(inline)] pub use self::network_ops::NetworkOpsClient;<|fim_prefix|>// repo: leejw51crypto/chain path: /client-network/src/lib.rs #![deny(missing_docs, unsafe_code, unstable_features)] //! Crypto.com Chain currently has two realms: //!<|fim_middle|> //! ...
code_fim
hard
{ "lang": "rust", "repo": "leejw51crypto/chain", "path": "/client-network/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: seija-engine/seija-old path: /src/core/update_limiter.rs use std::time::{Instant,Duration}; use std::thread::{sleep,yield_now}; #[derive(Clone)] pub enum LimitSetting { Unlimited, Yield(u32), Sleep(u32), SleepAndYield(u32) } impl Default for LimitSetting { fn default() -> S...
code_fim
hard
{ "lang": "rust", "repo": "seija-engine/seija-old", "path": "/src/core/update_limiter.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> loop { let elapsed = Instant::now() - self.last_call; if elapsed >= self.frame_duration { break } else { sleep(self.frame_duration - elapsed) } } } }<|fim_prefix|>// repo: seija-engine/seija-old path: /src...
code_fim
hard
{ "lang": "rust", "repo": "seija-engine/seija-old", "path": "/src/core/update_limiter.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Emerentius/ProjectEuler path: /p116_red_green_or_blue_tiles/src/main.rs #![feature(test)] extern crate test; /* fn count_tilings(n_tiles: i64, block_len: i64) -> i64 { let mut sum = 0; for pos in (0..n_tiles - block_len + 1) { sum += 1 + count_tilings(n_tiles-pos-block_len, bloc...
code_fim
medium
{ "lang": "rust", "repo": "Emerentius/ProjectEuler", "path": "/p116_red_green_or_blue_tiles/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let mut n_tilings_red = [0; N_PLUS]; let mut n_tilings_green = [0; N_PLUS]; let mut n_tilings_blue = [0; N_PLUS]; n_tilings_red[2] = 1u64; n_tilings_green[3] = 1u64; n_tilings_blue[4] = 1u64; for n_tiles in 3..N_PLUS { for pos in 0..n_tiles - 2 + 1 { ...
code_fim
medium
{ "lang": "rust", "repo": "Emerentius/ProjectEuler", "path": "/p116_red_green_or_blue_tiles/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn step(&mut self, _: Self::Input, _: Self::Clock) -> Result<Self::Output, Self::Error> { self.i .next() .ok_or(()) } }<|fim_prefix|>// repo: turion/rust_signal_functions path: /src/from_iterator.rs use crate::*; use std::iter::*; pub struct FromIter<I> { i: ...
code_fim
medium
{ "lang": "rust", "repo": "turion/rust_signal_functions", "path": "/src/from_iterator.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.i .next() .ok_or(()) } }<|fim_prefix|>// repo: turion/rust_signal_functions path: /src/from_iterator.rs use crate::*; use std::iter::*; pub struct FromIter<I> { i: I, } <|fim_middle|>impl<I: Iterator> StreamFunction for FromIter<I> { type Input = (); ...
code_fim
hard
{ "lang": "rust", "repo": "turion/rust_signal_functions", "path": "/src/from_iterator.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: turion/rust_signal_functions path: /src/from_iterator.rs use crate::*; use std::iter::*; pub struct FromIter<I> { i: I, } <|fim_suffix|> fn step(&mut self, _: Self::Input, _: Self::Clock) -> Result<Self::Output, Self::Error> { self.i .next() .ok_or(()) ...
code_fim
medium
{ "lang": "rust", "repo": "turion/rust_signal_functions", "path": "/src/from_iterator.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: CodeGradox/brainfuck path: /src/main.rs use std::io::Read; use std::io::BufRead; use std::fs::File; use std::env; fn main() { let mut tape = [0u8; 1000]; let mut head = 0; let mut buf_pos = 0; let stdin = std::io::stdin(); let file = env::args().nth(1).expect("No argument g...
code_fim
hard
{ "lang": "rust", "repo": "CodeGradox/brainfuck", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if tape[head] != 0 { let mut level = 0; while buf_pos > 0 { buf_pos -= 1; match buf[buf_pos] { ']' => level += 1, '[' if level == 0 => break, ...
code_fim
hard
{ "lang": "rust", "repo": "CodeGradox/brainfuck", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_pow_g1() { let g1p = FixedBaseCurvePow::build(&G1Projective::prime_subgroup_generator()); let mut rng = rand::thread_rng(); let num: Fr = rng.gen(); let mut expect = G1Projective::prime_subgroup_generator(); expect.mul_assign(num); as...
code_fim
hard
{ "lang": "rust", "repo": "hkbudb/vchain-plus", "path": "/src/acc/utils.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hkbudb/vchain-plus path: /src/acc/utils.rs use ark_ec::ProjectiveCurve; use ark_ff::{BigInteger, FpParameters, PrimeField}; // Ref: https://github.com/blynn/pbc/blob/fbf4589036ce4f662e2d06905862c9e816cf9d08/arith/field.c#L251-L330 pub struct FixedBaseCurvePow<G: ProjectiveCurve> { table: Ve...
code_fim
hard
{ "lang": "rust", "repo": "hkbudb/vchain-plus", "path": "/src/acc/utils.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl Source for Torus { fn sample(&self, x: f32, y: f32, z: f32) -> f32 { torus(x - 0.5, y - 0.5, z - 0.5) } }<|fim_prefix|>// repo: CyberSys/planetary-destruction-simulator path: /src/game/simulation/geometry/torus.rs use isosurface::source::Source; /// The distance-field equation for a...
code_fim
easy
{ "lang": "rust", "repo": "CyberSys/planetary-destruction-simulator", "path": "/src/game/simulation/geometry/torus.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: CyberSys/planetary-destruction-simulator path: /src/game/simulation/geometry/torus.rs use isosurface::source::Source; /// The distance-field equation for a torus pub fn torus(x: f32, y: f32, z: f32) -> f32 { const R1: f32 = 1.0 / 4.0; const R2: f32 = 1.0 / 10.0; let q_x = ((x * x + ...
code_fim
easy
{ "lang": "rust", "repo": "CyberSys/planetary-destruction-simulator", "path": "/src/game/simulation/geometry/torus.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Publish { /// Returns reference to publish packet pub fn packet(&self) -> &codec::Publish { &self.0 } /// Returns reference to publish packet pub fn packet_mut(&mut self) -> &mut codec::Publish { &mut self.0 } pub fn ack(self) -> ControlResult { i...
code_fim
hard
{ "lang": "rust", "repo": "KirillSleta/actix-mqtt", "path": "/src/v3/client/control.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub(super) fn proto_error(err: error::ProtocolError) -> Self { ControlMessage::ProtocolError(ProtocolError::new(err)) } pub(super) fn peer_gone(err: Option<io::Error>) -> Self { ControlMessage::PeerGone(PeerGone(err)) } /// Initiate clean disconnect pub fn disconn...
code_fim
medium
{ "lang": "rust", "repo": "KirillSleta/actix-mqtt", "path": "/src/v3/client/control.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: KirillSleta/actix-mqtt path: /src/v3/client/control.rs use std::io; pub use crate::v3::control::{ Closed, ControlResult, Disconnect, Error, PeerGone, ProtocolError, }; use crate::v3::{codec, control::ControlResultKind, error}; #[derive(Debug)] pub enum ControlMessage<E> { /// Unhandled...
code_fim
hard
{ "lang": "rust", "repo": "KirillSleta/actix-mqtt", "path": "/src/v3/client/control.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: quininer/tlslookup path: /src/main.rs extern crate futures; extern crate tokio_core; extern crate native_tls; extern crate trust_dns; extern crate trust_dns_proto; extern crate trust_dns_native_tls; <|fim_suffix|> let mut builder = TlsClientStreamBuilder::new(); builder.add_ca(Certificat...
code_fim
hard
{ "lang": "rust", "repo": "quininer/tlslookup", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut client = ClientFuture::new(fut, han, &handle, None); let fut = client.lookup(Query::query(target, RecordType::A)) .map(|msg| for record in msg.answers() { if let Some(ip) = record.rdata().to_ip_addr() { println!("{}", ip); } }); ...
code_fim
hard
{ "lang": "rust", "repo": "quininer/tlslookup", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut builder = TlsClientStreamBuilder::new(); builder.add_ca(Certificate::from_der(DNS_QUAD9_NET) .map_err(|err| io::Error::new(io::ErrorKind::Other, err))? ); let (fut, han) = builder.build(host, String::from("dns.quad9.net"), &handle); let mut client = ClientFuture::new(f...
code_fim
medium
{ "lang": "rust", "repo": "quininer/tlslookup", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn literal_string() { let mut interpreter = Interpreter::new(); let expr = Expr::Literal(ExprLiteral { token: Token::new( TokenType::String, "string".to_owned(), Literal::String("string".into()), 1,...
code_fim
hard
{ "lang": "rust", "repo": "AZanellato/rlox", "path": "/src/lox/interpreter/interpreter.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AZanellato/rlox path: /src/lox/interpreter/interpreter.rs use super::environment::Environment; use crate::lox::expr::Var as Var_expr; use crate::lox::expr::{Assignment, Binary, Expr, Literal, Logical, Unary}; use crate::lox::stmt::{Block, IfStmt, Stmt, Var, While}; use crate::lox::token; use der...
code_fim
hard
{ "lang": "rust", "repo": "AZanellato/rlox", "path": "/src/lox/interpreter/interpreter.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: caemor/epd-waveshare-examples path: /epd1in54_blue/src/main.rs #![no_main] #![no_std] #![feature(alloc_error_handler)] extern crate alloc; use alloc::string::ToString; #[allow(unused_imports)] // set the panic handler #[allow(unused_imports)] use panic_semihosting; use cortex_m_rt::entry; us...
code_fim
hard
{ "lang": "rust", "repo": "caemor/epd-waveshare-examples", "path": "/epd1in54_blue/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>hms::OptimalFit); let _ = textwrap::fill(&input.0, &options); });<|fim_prefix|>// repo: GuillaumeGomez/textwrap path: /fuzz/fuzz_targets/fill_optimal_fit.rs #![no_main] use libfuzzer_sys::fuzz_target; use textwrap::wrap_algorithms; use textwrap::Options; fuzz_target!(|input: (String, usize)| <|fim_m...
code_fim
medium
{ "lang": "rust", "repo": "GuillaumeGomez/textwrap", "path": "/fuzz/fuzz_targets/fill_optimal_fit.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: GuillaumeGomez/textwrap path: /fuzz/fuzz_targets/fill_optimal_fit.rs #![no_main] use libfuzzer_sys::fuzz_target; use textwrap::wrap_algorithms; use textwrap::Options; fuzz_target!(|input: (String, usize)| <|fim_suffix|>hms::OptimalFit); let _ = textwrap::fill(&input.0, &options); });<|fim_m...
code_fim
medium
{ "lang": "rust", "repo": "GuillaumeGomez/textwrap", "path": "/fuzz/fuzz_targets/fill_optimal_fit.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fdumontmd/adventofcode path: /2021/day08/src/main.rs use std::collections::{HashMap, HashSet}; const INPUT: &str = include_str!("input"); fn part01(input: &str) -> usize { input .lines() .map(|l| { l.split('|') .nth(1) .expect(&fo...
code_fim
hard
{ "lang": "rust", "repo": "fdumontmd/adventofcode", "path": "/2021/day08/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // need to sort all the entries let parts: Vec<_> = input.split(" | ").collect(); let mut samples: HashSet<_> = parts[0].split_whitespace().map(sort_segment).collect(); let digits: Vec<_> = parts[1].split_whitespace().map(sort_segment).collect(); let mut mapping: HashMap<String, u64> ...
code_fim
hard
{ "lang": "rust", "repo": "fdumontmd/adventofcode", "path": "/2021/day08/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }