text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|>pub use message::Message; pub use error::{DecodeError, EncodeError};<|fim_prefix|>// repo: geniousli/prost path: /src/lib.rs #![doc(html_root_url = "https://docs.rs/prost/0.2.3")] extern crate bytes; <|fim_middle|>#[cfg(test)] #[macro_use] extern crate quickcheck; mod error; mod message; mod types; #...
code_fim
medium
{ "lang": "rust", "repo": "geniousli/prost", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: geniousli/prost path: /src/lib.rs #![doc(html_root_url = "https://docs.rs/prost/0.2.3")] <|fim_suffix|>#[doc(hidden)] pub mod encoding; pub use message::Message; pub use error::{DecodeError, EncodeError};<|fim_middle|>extern crate bytes; #[cfg(test)] #[macro_use] extern crate quickcheck; mod...
code_fim
medium
{ "lang": "rust", "repo": "geniousli/prost", "path": "/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zaeleus/noodles path: /noodles-bed/src/record/color.rs //! BED record color. use std::{error, fmt, num, str::FromStr}; const DELIMITER: char = ','; /// A BED record color. /// /// A color is represented as an RGB triplet, where each component ranges from 0 to 255, inclusive. #[derive(Clone, C...
code_fim
hard
{ "lang": "rust", "repo": "zaeleus/noodles", "path": "/noodles-bed/src/record/color.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match self { Self::Invalid => None, Self::InvalidComponent(e) => Some(e), } } } impl fmt::Display for ParseError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Self::Invalid => f.write_str("invalid input"), ...
code_fim
hard
{ "lang": "rust", "repo": "zaeleus/noodles", "path": "/noodles-bed/src/record/color.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vys534/discord-edited-changer path: /src/main.rs use std::io::{stdin, stdout, Write, Read}; use std::str; use std::io; fn insert_chars(m: Vec<&str>, pos: i32) -> Vec<&str> { let buf = &[0xe2, 0x80, 0xab]; let buf_str = match str::from_utf8(buf) { Ok(v) => v, Err(e) => pa...
code_fim
hard
{ "lang": "rust", "repo": "vys534/discord-edited-changer", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut decision = String::new(); let _ = stdout().flush(); stdin().read_line(&mut decision).expect("Could not parse your answer."); if decision.trim().to_lowercase().starts_with("y") { index = index_proposed; break } } print!("Finis...
code_fim
hard
{ "lang": "rust", "repo": "vys534/discord-edited-changer", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if houses.is_empty() { return vec![]; } let name = name(from); create_and_update_house_drawing(name, world, houses) } } fn name(at: &V2<usize>) -> String { format!("houses-{:?}", at) }<|fim_prefix|>// repo: TGElder/rust path: /frontier/src/artists/hou...
code_fim
hard
{ "lang": "rust", "repo": "TGElder/rust", "path": "/frontier/src/artists/house_artist.rs", "mode": "spm", "license": "CC-BY-4.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn draw( &self, world: &World, from: &V2<usize>, to: &V2<usize>, territory_colors: &M<Option<Color>>, ) -> Vec<Command> { let tiles = (from.x..to.x) .flat_map(|x| (from.y..to.y).map(move |y| v2(x, y))) .collect::<Vec<_>>()...
code_fim
hard
{ "lang": "rust", "repo": "TGElder/rust", "path": "/frontier/src/artists/house_artist.rs", "mode": "spm", "license": "CC-BY-4.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TGElder/rust path: /frontier/src/artists/house_artist.rs use super::*; use serde::{Deserialize, Serialize}; use commons::grid::Grid; use isometric::drawing::{create_and_update_house_drawing, House}; use isometric::Color; #[derive(Clone, Copy, Debug, PartialEq, Deserialize, Serialize)] pub str...
code_fim
hard
{ "lang": "rust", "repo": "TGElder/rust", "path": "/frontier/src/artists/house_artist.rs", "mode": "psm", "license": "CC-BY-4.0", "source": "the-stack-v2" }
<|fim_suffix|>async fn graphiql_route() -> Result<HttpResponse, Error> { graphiql_handler("/graphgl", None).await } async fn playground_route() -> Result<HttpResponse, Error> { playground_handler("/graphgl", None).await } async fn graphql_route( req: actix_web::HttpRequest, payload: actix_web::web::Pa...
code_fim
hard
{ "lang": "rust", "repo": "fcsonline/cratesql", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>async fn graphql_route( req: actix_web::HttpRequest, payload: actix_web::web::Payload, schema: web::Data<Schema>, ) -> Result<HttpResponse, Error> { let context = Database::new(); graphql_handler(&schema, &context, req, payload).await } fn establish_connection() -> PgConnection { do...
code_fim
hard
{ "lang": "rust", "repo": "fcsonline/cratesql", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fcsonline/cratesql path: /src/main.rs #![deny(warnings)] use std::{collections::HashMap, env}; #[macro_use] extern crate diesel; mod schema; use diesel::pg::PgConnection; use diesel::prelude::*; use chrono::NaiveDateTime; use dotenv::dotenv; use actix_cors::Cors; use actix_web::{http::header...
code_fim
hard
{ "lang": "rust", "repo": "fcsonline/cratesql", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Single producers, single consumer #[bench] fn bounded_1_tx(b: &mut Bencher) { let mut cx = noop_context(); b.iter(|| { let (tx, mut rx) = channel(); let mut tx = TestSender { tx, last: 0 }; for i in 0..1000 { assert_eq!(Poll::Ready(Some(i + 1)), tx.poll_ne...
code_fim
hard
{ "lang": "rust", "repo": "seunlanlege/futures-refcell", "path": "/benches/sync_mpsc.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: seunlanlege/futures-refcell path: /benches/sync_mpsc.rs #![feature(test)] extern crate test; use crate::test::Bencher; use { futures::{ ready, stream::{Stream, StreamExt}, sink::Sink, task::{Context, Poll}, }, futures_state_channel::{Sender, Receiver,...
code_fim
hard
{ "lang": "rust", "repo": "seunlanlege/futures-refcell", "path": "/benches/sync_mpsc.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> { let this = &mut *self; let mut tx = Pin::new(&mut this.tx); ready!(tx.as_mut().poll_ready(cx)).unwrap(); tx.as_mut().start_send(this.last + 1).unwrap(); this....
code_fim
hard
{ "lang": "rust", "repo": "seunlanlege/futures-refcell", "path": "/benches/sync_mpsc.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Lehnart/rust-games path: /asteroids/src/collide.rs use crate::logic::{Logic, Asteroid, Bullet}; use engine::geometry::AsRect; use engine::collide::collide; fn collide_shell_and_asteroids(asteroids : &mut Vec<Asteroid>, bullets : &mut Vec<Bullet>){ <|fim_suffix|>pub fn check_collision(logic: &m...
code_fim
hard
{ "lang": "rust", "repo": "Lehnart/rust-games", "path": "/asteroids/src/collide.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn check_collision(logic: &mut Logic) { collide_shell_and_asteroids(&mut logic.asteroids.vec, &mut logic.spaceship.bullets); }<|fim_prefix|>// repo: Lehnart/rust-games path: /asteroids/src/collide.rs use crate::logic::{Logic, Asteroid, Bullet}; use engine::geometry::AsRect; use engine::collide::...
code_fim
hard
{ "lang": "rust", "repo": "Lehnart/rust-games", "path": "/asteroids/src/collide.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[ignore] // negative stride #[test] fn strided_slice_4() { let graph = tfpb::graph() .node(placeholder_i32("input")) .node(const_i32("begin", &tensor1(&[1]))) .node(const_i32("end", &tensor1(&[0]))) .node(const_i32("stride", &tensor1(&[-1]))) .node( ...
code_fim
hard
{ "lang": "rust", "repo": "sonos/tract", "path": "/tensorflow/tests/ops_array_strided_slice.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> let graph = tfpb::graph() .node(placeholder_i32("input")) .node(const_i32("begin", &tensor1(&[0]))) .node(const_i32("end", &tensor1(&[0]))) .node(const_i32("stride", &tensor1(&[1]))) .node( tfpb::node() .name("op") .at...
code_fim
hard
{ "lang": "rust", "repo": "sonos/tract", "path": "/tensorflow/tests/ops_array_strided_slice.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sonos/tract path: /tensorflow/tests/ops_array_strided_slice.rs #![cfg(feature = "conform")] #![allow(non_snake_case)] extern crate env_logger; #[macro_use] extern crate log; #[macro_use] extern crate proptest; extern crate tract_tensorflow; mod utils; use crate::utils::*; use proptest::prelude...
code_fim
hard
{ "lang": "rust", "repo": "sonos/tract", "path": "/tensorflow/tests/ops_array_strided_slice.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>#[tokio::main] async fn main() { let song = learn_song().await.unwrap(); sing_song(song).await }<|fim_prefix|>// repo: anfernee/dotfiles path: /samples/rust/async/tokio_main.rs struct Song { } async fn learn_song() -> Option<Song> { println!("learn song"); Some(Song{}) } <|fim_middle|>...
code_fim
medium
{ "lang": "rust", "repo": "anfernee/dotfiles", "path": "/samples/rust/async/tokio_main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: anfernee/dotfiles path: /samples/rust/async/tokio_main.rs struct Song { } async fn learn_song() -> Option<Song> { println!("learn song"); Some(Song{}) } <|fim_suffix|>#[tokio::main] async fn main() { let song = learn_song().await.unwrap(); sing_song(song).await }<|fim_middle|>...
code_fim
medium
{ "lang": "rust", "repo": "anfernee/dotfiles", "path": "/samples/rust/async/tokio_main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: SINHASantos/grpc-rust path: /grpc/src/common/sink.rs use crate::client::types::ClientTypes; use crate::common::types::Types; use bytes::Bytes; use crate::marshall::Marshaller; use crate::or_static::arc::ArcOrStatic; use crate::proto::grpc_frame::write_grpc_frame_cb; use crate::result; use crate...
code_fim
hard
{ "lang": "rust", "repo": "SINHASantos/grpc-rust", "path": "/grpc/src/common/sink.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub(crate) struct SinkCommon<M: 'static, T: Types> { pub marshaller: ArcOrStatic<dyn Marshaller<M>>, pub sink: T::SinkUntyped, } impl<M: 'static, T: Types> SinkCommon<M, T> { pub fn poll(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), httpbis::Error>> { self.sink.poll(cx) } ...
code_fim
hard
{ "lang": "rust", "repo": "SINHASantos/grpc-rust", "path": "/grpc/src/common/sink.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn init_log() { pretty_env_logger::init(); debug!("start logging"); }<|fim_prefix|>// repo: VenmoTools/tcp-stack path: /src/lib.rs #[macro_use] extern crate log; extern crate pretty_env_logger; <|fim_middle|>pub mod net_types; pub mod tcp; pub mod data_link; pub mod result; pub mod reader_wr...
code_fim
medium
{ "lang": "rust", "repo": "VenmoTools/tcp-stack", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: VenmoTools/tcp-stack path: /src/lib.rs #[macro_use] extern crate log; extern crate pretty_env_logger; <|fim_suffix|>pub fn init_log() { pretty_env_logger::init(); debug!("start logging"); }<|fim_middle|>pub mod net_types; pub mod tcp; pub mod data_link; pub mod result; pub mod reader_wr...
code_fim
medium
{ "lang": "rust", "repo": "VenmoTools/tcp-stack", "path": "/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: systemsoverload/pagliascii path: /src/parser/nom_ext.rs use nom::branch::alt; use nom::bytes::complete::{tag, take_until, take_while, take_while1}; use nom::character::complete::newline; use nom::combinator::{eof, map, peek, recognize, rest_len, verify}; use nom::error::ParseError; use nom::sequ...
code_fim
hard
{ "lang": "rust", "repo": "systemsoverload/pagliascii", "path": "/src/parser/nom_ext.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub fn is_spacer(char: char) -> bool { match char { '\\' => false, _ => !char.is_alphanumeric(), } } pub fn take_line<'a, E: ParseError<Span<'a>>>(i: Span<'a>) -> PResult<'a, Span<'a>, E> { terminated(take_until("\n"), tag("\n"))(i) } pub fn ws_with_nl<'a, E: ParseError<Span<'...
code_fim
hard
{ "lang": "rust", "repo": "systemsoverload/pagliascii", "path": "/src/parser/nom_ext.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub fn take_line<'a, E: ParseError<Span<'a>>>(i: Span<'a>) -> PResult<'a, Span<'a>, E> { terminated(take_until("\n"), tag("\n"))(i) } pub fn ws_with_nl<'a, E: ParseError<Span<'a>>>(i: Span<'a>) -> PResult<'a, Span<'a>, E> { terminated(ws, tag("\n"))(i) }<|fim_prefix|>// repo: systemsoverload/pagli...
code_fim
hard
{ "lang": "rust", "repo": "systemsoverload/pagliascii", "path": "/src/parser/nom_ext.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AlbertoGP/x7 path: /src/parser.rs use crate::symbols::{Expr, LispResult, Num, ProgramError}; // s-expression parser using nom. // Supports the usual constructs (quotes, numbers, strings, comments) // HUGE thanks to the nom people (Geal, adamnemecek, MarcMcCaskey, et all) // who had an s_expres...
code_fim
hard
{ "lang": "rust", "repo": "AlbertoGP/x7", "path": "/src/parser.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> map( context("quote", preceded(tag("'"), cut(s_exp(many0(parse_expr))))), |exprs| Expr::Quote(exprs.into()), )(i) } fn parse_num<'a>(i: &'a str) -> IResult<&'a str, Expr, VerboseError<&'a str>> { map_res(recognize_float, |digit_str: &str| { digit_str.parse::<Num>().map...
code_fim
hard
{ "lang": "rust", "repo": "AlbertoGP/x7", "path": "/src/parser.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: joaodelgado/cobalt path: /backend/src/geiger.rs use std::io; use std::io::BufRead; use std::sync::{Arc, Mutex}; use std::time::Duration; use log::debug; use serial::prelude::*; use serial::SystemPort; use super::metrics::Monitoring; const CONVERTION_FACTOR: f64 = 0.008_120_370_370_37; pub st...
code_fim
hard
{ "lang": "rust", "repo": "joaodelgado/cobalt", "path": "/backend/src/geiger.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> port.reconfigure(&|settings| { settings.set_baud_rate(serial::Baud9600)?; settings.set_char_size(serial::Bits8); settings.set_parity(serial::ParityNone); settings.set_stop_bits(serial::Stop1); settings.set_flow_control(serial::FlowNone); ...
code_fim
hard
{ "lang": "rust", "repo": "joaodelgado/cobalt", "path": "/backend/src/geiger.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> compiled.push(0b11000000 + register_str_to_code(dest)); // read64 {dest} compiled } pub fn compile_write8(reg: String) -> Vec<u8> { let mut compiled: Vec<u8> = Vec::new(); compiled.push(0b10000000 + register_str_to_code(reg)); // write8 {reg} compiled } pub fn compile_write16(reg:...
code_fim
hard
{ "lang": "rust", "repo": "TheLocust3/full-stack-vm", "path": "/asm/src/compiler/memory.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TheLocust3/full-stack-vm path: /asm/src/compiler/memory.rs use register::register_str_to_code; pub fn compile_read8(dest: String) -> Vec<u8> { let mut compiled: Vec<u8> = Vec::new(); compiled.push(0b11111000 + register_str_to_code(dest)); // read8 {dest} compiled } pub fn compile...
code_fim
medium
{ "lang": "rust", "repo": "TheLocust3/full-stack-vm", "path": "/asm/src/compiler/memory.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: batconjurer/imgcmp path: /src/average_hash.rs use std::path::Path; use image::io::Reader as ImageReader; use image::imageops::FilterType; use fixedbitset::FixedBitSet; use crate::errors::Error; /// Computes a perceptual hash of an image as described at /// https://www.hackerfactor.com/blog/in...
code_fim
hard
{ "lang": "rust", "repo": "batconjurer/imgcmp", "path": "/src/average_hash.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// This is minimum required tests that must pass in order for the assignment to be complete. #[cfg(test)] mod test_assets { use super::*; #[test] fn test_asset_comparisons() { assert!(are_images_equal(Path::new("assets/cat.jpg"), Path::new("assets/c...
code_fim
hard
{ "lang": "rust", "repo": "batconjurer/imgcmp", "path": "/src/average_hash.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// The main function that determines if two functions are equal. This works in two steps: /// /// 1. Compute the `ahash` of both images /// 2. Check the if the resulting bit-strings are of hamming distance < 10 of each other pub fn are_images_equal(image_1: &Path, image_2: &Path) -> Result<bool, Error> {...
code_fim
hard
{ "lang": "rust", "repo": "batconjurer/imgcmp", "path": "/src/average_hash.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> *globals.term_offset = 0.into(); // end; } // no_print,pseudo,new_string: do_nothing; else if *globals.selector == no_print || *globals.selector == pseudo || *globals.selector == new_string { do_nothing!(); } // othercases write_ln(write_file[sel...
code_fim
hard
{ "lang": "rust", "repo": "harpsword/tex-rs", "path": "/src/tex_the_program/section_0057.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: harpsword/tex-rs path: /src/tex_the_program/section_0057.rs //! @ To end a line of text output, we call |print_ln|. // // @<Basic print...@>= // procedure print_ln; {prints an end-of-line} /// prints an end-of-line #[allow(unused_variables)] pub(crate) fn print_ln(mut globals: TeXGlobalsIoStrin...
code_fim
hard
{ "lang": "rust", "repo": "harpsword/tex-rs", "path": "/src/tex_the_program/section_0057.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>not affected const _: () = (); } use crate::io_support::write_ln_noargs; use crate::section_0004::make_globals_io_view; use crate::section_0004::make_globals_log_view; use crate::section_0004::TeXGlobals; use crate::section_0004::TeXGlobalsIoStringLogView; use crate::section_0004::TeXGlobalsIoView; u...
code_fim
hard
{ "lang": "rust", "repo": "harpsword/tex-rs", "path": "/src/tex_the_program/section_0057.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Deserialize, Serialize, Debug, Clone, ToSchema)] #[serde(rename_all = "camelCase")] pub struct DatasetDefinition { pub properties: AddDataset, pub meta_data: MetaDataDefinition, } #[derive(Deserialize, Serialize, Debug, Clone, ToSchema)] #[serde(rename_all = "camelCase")] pub struct Crea...
code_fim
hard
{ "lang": "rust", "repo": "geo-engine/geoengine", "path": "/services/src/api/model/services.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: geo-engine/geoengine path: /services/src/api/model/services.rs use crate::api::model::operators::{ GdalMetaDataList, GdalMetaDataRegular, GdalMetaDataStatic, GdalMetadataNetCdfCf, MockMetaData, OgrMetaData, }; use crate::datasets::listing::Provenance; use crate::datasets::upload::{Upload...
code_fim
hard
{ "lang": "rust", "repo": "geo-engine/geoengine", "path": "/services/src/api/model/services.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>fn render( users: Vec<User>, renderer: &Renderer, ) -> impl Future<Item = HttpResponse, Error = Error> { let template = Template::new( "user-list", json!({ "title": "Users", "users": users, }), ); renderer .send(template) ...
code_fim
hard
{ "lang": "rust", "repo": "brace-rs/brace-rs", "path": "/crates/brace-web-auth/src/lib/route/web/list.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> users: Vec<User>, renderer: &Renderer, ) -> impl Future<Item = HttpResponse, Error = Error> { let template = Template::new( "user-list", json!({ "title": "Users", "users": users, }), ); renderer .send(template) .map_err(E...
code_fim
medium
{ "lang": "rust", "repo": "brace-rs/brace-rs", "path": "/crates/brace-web-auth/src/lib/route/web/list.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: brace-rs/brace-rs path: /crates/brace-web-auth/src/lib/route/web/list.rs use actix_web::error::{Error, ErrorForbidden, ErrorInternalServerError}; use actix_web::web::Data; use actix_web::HttpResponse; use brace_db::Database; use brace_web::render::{Renderer, Template}; use futures::future::{err,...
code_fim
hard
{ "lang": "rust", "repo": "brace-rs/brace-rs", "path": "/crates/brace-web-auth/src/lib/route/web/list.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yurigorokhov/rust-redshift path: /tests/reader_tests.rs #[cfg(test)] mod test { extern crate redshift; use std::io::BufReader; #[test] fn basic_reader_test() { // Arrange let input_data = b"\"a\"|\"b\" \"c\"|\"d\"\n"; let mut reader = BufReader::new(&in...
code_fim
hard
{ "lang": "rust", "repo": "yurigorokhov/rust-redshift", "path": "/tests/reader_tests.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Arrange let input_data = b"\"tobe\\|nottobe\"|\"iama\\\"doublequote\" \"iama\\'singlequote\"|\"iama\\\\backslash\" \"iama\\|verticalbar\"|\"iama\\\nnewline\" \"iama\\\rcarriagereturn\"|\"iam\\\r\\\nwindows\""; let mut reader = BufReader::new(&input_data[..]); // Act ...
code_fim
hard
{ "lang": "rust", "repo": "yurigorokhov/rust-redshift", "path": "/tests/reader_tests.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>let lines = lines_from_file("input.txt"); for number1 in &lines { for number2 in &lines { if number1+number2 == 2020{ let result = number1*number2; println!("{:?}", result); return } } } } fn part_b(){ let lines = lines_from_file("input.txt"...
code_fim
medium
{ "lang": "rust", "repo": "derphilipp/aoc_2020", "path": "/rust/01/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: derphilipp/aoc_2020 path: /rust/01/src/main.rs use std::{ fs::File, io::{prelude::*, BufReader}, path::Path, }; use itertools::Itertools; fn lines_from_file(filename: impl AsRef<Path>) -> Vec<i32> { let file = File::open(filename).expect("no such file"); let buf = BufReader:...
code_fim
hard
{ "lang": "rust", "repo": "derphilipp/aoc_2020", "path": "/rust/01/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Xiaobin0860/plastic path: /plastic_core/src/cartridge/mappers/mapper1.rs use super::super::mapper::{Mapper, MappingResult}; use crate::common::{Device, MirroringMode}; pub struct Mapper1 { writing_shift_register: u8, /// 4bit0 /// ----- /// CPPMM /// ||||| /// |||++- Mi...
code_fim
hard
{ "lang": "rust", "repo": "Xiaobin0860/plastic", "path": "/plastic_core/src/cartridge/mappers/mapper1.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn get_prg_bank(&self) -> u8 { self.prg_bank & 0b1111 } fn is_prg_32kb_mode(&self) -> bool { self.control_register & 0b01000 == 0 } /// this should be used in combination with `is_PRG_32kb_mode` /// this function will assume that the mapper is in 16kb mode ///...
code_fim
hard
{ "lang": "rust", "repo": "Xiaobin0860/plastic", "path": "/plastic_core/src/cartridge/mappers/mapper1.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let new_tranform = transform * local_transform; self.global_transform = new_tranform; } } fn compute_transform(translation: Vec3, rotation: Quaternion<f32>, scale: Vec3) -> Mat4 { let translation = Mat4::from_translation(translation); let rotation = cgmath::Matrix4::from(rotat...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/cheese", "path": "/src/animation/node.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Node { fn apply_transform(&mut self, transform: Mat4) { let local_transform = compute_transform( self.local_translation, self.local_rotation, self.local_scale, ); let new_tranform = transform * local_transform; self.global_trans...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/cheese", "path": "/src/animation/node.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/cheese path: /src/animation/node.rs // This file was originally copied from gltf-viewer-rs: // https://github.com/adrien-ben/gltf-viewer-rs/blob/master/model/src/node.rs use cgmath::Quaternion; use ultraviolet::{Mat4, Vec3}; #[derive(Clone, Debug, Default)] pub struct Nodes { nodes...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/cheese", "path": "/src/animation/node.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let res_var = ProjectiveVar::<BandersnatchParameters, FpVar<Fq>>::new_witness( cs.clone(), || Ok(self.res), ) .unwrap(); #[cfg(debug_assertions)] println!("cs for result var : {}", cs.num_constraints() - _cs_no); ...
code_fim
hard
{ "lang": "rust", "repo": "zhenfeizhang/bandersnatch", "path": "/bandersnatch/examples/constraint_count_bandersnatch.rs", "mode": "spm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zhenfeizhang/bandersnatch path: /bandersnatch/examples/constraint_count_bandersnatch.rs use ark_ec::ProjectiveCurve; use ark_ff::{BigInteger, PrimeField, UniformRand}; use ark_r1cs_std::{ alloc::AllocVar, boolean::Boolean, eq::EqGadget, fields::fp::FpVar, groups::{curves::sho...
code_fim
hard
{ "lang": "rust", "repo": "zhenfeizhang/bandersnatch", "path": "/bandersnatch/examples/constraint_count_bandersnatch.rs", "mode": "psm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|>fn fix_program(program: &[Instruction]) -> Option<Patch> { for i in 0..program.len() { if let Instruction::Acc(_) = program[i] { continue; } let mut patched_program = program.to_vec(); patched_program[i] = match patched_program[i] { Instruction:...
code_fim
hard
{ "lang": "rust", "repo": "cauebs/advent-of-code-2020", "path": "/src/bin/day08.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let program = include_str!("../../inputs/day08.txt") .lines() .filter_map(|line| line.parse().ok()) .collect::<Vec<Instruction>>(); println!("{}", execute(&program).unwrap_err()); println!("{}", fix_program(&program).unwrap().correct_output); }<|fim_prefix|...
code_fim
hard
{ "lang": "rust", "repo": "cauebs/advent-of-code-2020", "path": "/src/bin/day08.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cauebs/advent-of-code-2020 path: /src/bin/day08.rs #![feature(str_split_once)] use std::{collections::HashSet, str::FromStr}; #[derive(Clone)] enum Instruction { Acc(i32), Jmp(i32), Nop(i32), } impl FromStr for Instruction { type Err = (); fn from_str(s: &str) -> Result<S...
code_fim
hard
{ "lang": "rust", "repo": "cauebs/advent-of-code-2020", "path": "/src/bin/day08.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kaivol/drone-stm32f4-hal path: /src/uart/mappings/usart1.rs use crate::{uart_setup_init, rx_drv_init, tx_drv_init, trx_drv_init, pins::{*, traits::*}}; use drone_stm32_map::periph::gpio::pin::*; use drone_stm32_map::periph::uart::Usart1; use drone_stm32f4_dma_drv::DmaStCh4; use drone_stm32f4_gpi...
code_fim
medium
{ "lang": "rust", "repo": "kaivol/drone-stm32f4-hal", "path": "/src/uart/mappings/usart1.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>tx_drv_init!(Usart1; Dma2Ch7, DmaStCh4); trx_drv_init!(Usart1; Dma2Ch7, DmaStCh4; Dma2Ch2, DmaStCh4); trx_drv_init!(Usart1; Dma2Ch7, DmaStCh4; Dma2Ch5, DmaStCh4); pin_impl!(RxPinExt for UartPins<Usart1, ...>.rx, GpioA10, AlternateMode<PinAf7>; Undefined, Tx -> Defined, Tx); pin_impl!(RxPinExt for UartPi...
code_fim
medium
{ "lang": "rust", "repo": "kaivol/drone-stm32f4-hal", "path": "/src/uart/mappings/usart1.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pin_impl!(TxPinExt for UartPins<Usart1, ...>.tx, GpioA9, AlternateMode<PinAf7>; Tx, Undefined -> Tx, Defined); pin_impl!(TxPinExt for UartPins<Usart1, ...>.tx, GpioB6, AlternateMode<PinAf7>; Tx, Undefined -> Tx, Defined);<|fim_prefix|>// repo: kaivol/drone-stm32f4-hal path: /src/uart/mappings/usart1.rs u...
code_fim
hard
{ "lang": "rust", "repo": "kaivol/drone-stm32f4-hal", "path": "/src/uart/mappings/usart1.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: royshan/tantivy path: /src/postings/mod.rs /// Postings module /// /// Postings, also called inverted lists, is the key datastructure /// to full-text search. mod postings; mod recorder; mod serializer; mod postings_writer; mod term_info; mod chained_postings; mod vec_postings; mod segment_pos...
code_fim
hard
{ "lang": "rust", "repo": "royshan/tantivy", "path": "/src/postings/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_intersection() { { let left = Box::new(VecPostings::from(vec!(1, 3, 9))); let right = Box::new(VecPostings::from(vec!(3, 4, 9, 18))); let mut intersection = IntersectionDocSet::new(vec!(left, right)); assert!(intersection.adva...
code_fim
hard
{ "lang": "rust", "repo": "royshan/tantivy", "path": "/src/postings/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dbrodie/rex path: /tests/util/mock_filesystem.rs use std::path::{Path, PathBuf}; use std::io; use std::str; use std::io::{Cursor, Read, Write}; use std::ops::DerefMut; use std::collections::hash_map::{HashMap, Entry}; use std::sync::{Arc, Mutex}; use std::mem; use std::marker::PhantomData; use ...
code_fim
hard
{ "lang": "rust", "repo": "dbrodie/rex", "path": "/tests/util/mock_filesystem.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn can_open<P: AsRef<Path>>(_p: P) -> io::Result<()> { Ok(()) } fn save<P: AsRef<Path>>(path: P) -> io::Result<Self::FSWrite> { let backend = T::get_backend(); let mut file_map = backend.files.lock().unwrap(); let file = file_map.entry(path.as_ref().into()).or_...
code_fim
hard
{ "lang": "rust", "repo": "dbrodie/rex", "path": "/tests/util/mock_filesystem.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: backwardn/bao path: /benches/bench.rs #![feature(test)] extern crate test; #[cfg(feature = "std")] use bao::{decode, encode}; use rand::prelude::*; use std::io::prelude::*; use std::io::{Cursor, SeekFrom::Start}; use test::Bencher; // 64 bytes, just enough input to fill a single BLAKE2s block...
code_fim
hard
{ "lang": "rust", "repo": "backwardn/bao", "path": "/benches/bench.rs", "mode": "psm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut input = RandomInput::new(b, MEDIUM); b.iter(|| bao::hash(input.get())); } #[bench] fn bench_bao_hash_slice_long(b: &mut Bencher) { let mut input = RandomInput::new(b, LONG); b.iter(|| bao::hash(input.get())); } #[bench] fn bench_bao_hasher_short(b: &mut Bencher) { let mut inp...
code_fim
hard
{ "lang": "rust", "repo": "backwardn/bao", "path": "/benches/bench.rs", "mode": "spm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_suffix|> let input = RandomInput::new(b, SHORT).get().to_vec(); let (outboard, hash) = encode::outboard(&input); let mut output = [1; bao::BUF_SIZE]; b.iter(|| { let mut decoder = decode::Decoder::new_outboard(&*input, &*outboard, &hash); while decoder.read(&mut output).unwrap() > 0...
code_fim
hard
{ "lang": "rust", "repo": "backwardn/bao", "path": "/benches/bench.rs", "mode": "spm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_suffix|> &mut self, doc: &mut Automerge, patch_log: &mut PatchLog, obj: ObjId, prop: String, action: OpType, ) -> Result<Option<OpId>, AutomergeError> { if prop.is_empty() { return Err(AutomergeError::EmptyStringKey); } let id...
code_fim
hard
{ "lang": "rust", "repo": "automerge/automerge", "path": "/rust/automerge/src/transaction/inner.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: automerge/automerge path: /rust/automerge/src/transaction/inner.rs [tracing::instrument(skip(self, metadata))] pub(crate) fn export(self, metadata: &OpSetMetadata) -> Change { use crate::storage::{change::PredOutOfOrder, convert::op_as_actor_id}; let actor = metadata.actors....
code_fim
hard
{ "lang": "rust", "repo": "automerge/automerge", "path": "/rust/automerge/src/transaction/inner.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let id = self.next_id(); let prop_index = doc.ops_mut().m.props.cache(prop.clone()); let key = Key::Map(prop_index); let prop: Prop = prop.into(); let query = doc.ops() .seek_ops_by_prop(&obj, prop.clone(), ListEncoding::List, self.scope....
code_fim
hard
{ "lang": "rust", "repo": "automerge/automerge", "path": "/rust/automerge/src/transaction/inner.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> header.insert(String::from("version"), to_value(self.version.to_owned())?); header.insert( String::from("traffic_class"), to_value(self.traffic_class.to_owned())?, ); header.insert( String::from("flow_label"), to_value(self.fl...
code_fim
medium
{ "lang": "rust", "repo": "kbrebanov/snout", "path": "/src/parser/ipv6.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kbrebanov/snout path: /src/parser/ipv6.rs use pnet::packet::ipv6::Ipv6Packet; use serde_json::{Map, Value, to_value}; use serde_json::error::Error; pub struct Ipv6Header { version: u8, traffic_class: u8, flow_label: u32, payload_length: u16, next_header: String, hop_limi...
code_fim
hard
{ "lang": "rust", "repo": "kbrebanov/snout", "path": "/src/parser/ipv6.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gobanos/some-platformer path: /server/src/game.rs use sync::state::StateHandle; use sync::C2GReceiver; use std::time::Duration; use lib::sync::message::{Client, Server}; use lib::world::gameworld::GameWorld; /// The game handle server logic: /// - Processing client messages /// - Update the w...
code_fim
hard
{ "lang": "rust", "repo": "gobanos/some-platformer", "path": "/server/src/game.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Update the game state pub fn update(&mut self, _elapsed_time: Duration) { // Poll messages from clients while let Ok((msg, author)) = self.receiver.try_recv() { debug!("Game got a message from {:?}: {:?}", author, msg); match msg { // Th...
code_fim
hard
{ "lang": "rust", "repo": "gobanos/some-platformer", "path": "/server/src/game.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oxidecomputer/stm32-rs-nightlies path: /stm32g0/src/stm32g081/tamp/scr.rs #[doc = "Writer for register SCR"] pub type W = crate::W<u32, super::SCR>; #[doc = "Register SCR `reset()`'s with value 0"] impl crate::ResetValue for super::SCR { type Type = u32; #[inline(always)] fn reset_va...
code_fim
hard
{ "lang": "rust", "repo": "oxidecomputer/stm32-rs-nightlies", "path": "/stm32g0/src/stm32g081/tamp/scr.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> ...
code_fim
hard
{ "lang": "rust", "repo": "oxidecomputer/stm32-rs-nightlies", "path": "/stm32g0/src/stm32g081/tamp/scr.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>ys)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 19)) | (((value as u32) & 0x01) << 19); self.w } } #[doc = "Write proxy for field `CITAMP5F`"] pub struct CITAMP5F_W<'a> { w: &'a mut W, } impl<'a> CITAMP5F_W<'a> { #[doc = r"Sets the f...
code_fim
hard
{ "lang": "rust", "repo": "oxidecomputer/stm32-rs-nightlies", "path": "/stm32g0/src/stm32g081/tamp/scr.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: RustWorks/butane path: /butane_core/src/db/pg.rs der]>, ) -> Result<RawQueryResult<'a>> { let mut sqlquery = String::new(); helper::sql_select(columns, table, &mut sqlquery); let mut values: Vec<SqlVal> = Vec::new(); if let Some(expr) = expr { sqlq...
code_fim
hard
{ "lang": "rust", "repo": "RustWorks/butane", "path": "/butane_core/src/db/pg.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> // Unfortunately this is a type method rather than an instance // method, so we don't actually know what we can // support. Declare acceptance of all and do any actual type // checking in from_sql. true } } fn check_columns(row: &postgres::Row, cols: &[Column])...
code_fim
hard
{ "lang": "rust", "repo": "RustWorks/butane", "path": "/butane_core/src/db/pg.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>struct PgTransaction<'c> { trans: Option<RefCell<postgres::Transaction<'c>>>, } impl<'c> PgTransaction<'c> { fn new(trans: postgres::Transaction<'c>) -> Self { PgTransaction { trans: Some(RefCell::new(trans)), } } fn get(&self) -> Result<&RefCell<postgres::Trans...
code_fim
hard
{ "lang": "rust", "repo": "RustWorks/butane", "path": "/butane_core/src/db/pg.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> let yes_raw = utils::get_input(); let yes = response_as_bool(yes_raw.to_owned()); if !yes { break; }; } }<|fim_prefix|>// repo: michaelgrigoryan25/makegen path: /src/interactive/task_prompt.rs use crate::{ constants::{ ERROR_COMMAND_CANNOT_BE_E...
code_fim
hard
{ "lang": "rust", "repo": "michaelgrigoryan25/makegen", "path": "/src/interactive/task_prompt.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: michaelgrigoryan25/makegen path: /src/interactive/task_prompt.rs use crate::{ constants::{ ERROR_COMMAND_CANNOT_BE_EMPTY, ERROR_TASK_CANNOT_BE_EMPTY, PROMPT_ADD_TASKS, PROMPT_CONTINUE_ADDING_TASKS, PROMPT_ENTER_TASK_COMMAND, PROMPT_ENTER_TASK_NAME, }, interactive::res...
code_fim
medium
{ "lang": "rust", "repo": "michaelgrigoryan25/makegen", "path": "/src/interactive/task_prompt.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: terry90/micro-iot path: /src/models/thing.rs #![allow(proc_macro_derive_resolution_fallback)] use chrono::NaiveDateTime; use diesel::dsl::insert_into; use diesel::prelude::*; use diesel::sqlite::SqliteConnection; use models::iot_data::IOTData; use rocket::http::Status; use rocket::request::{self...
code_fim
hard
{ "lang": "rust", "repo": "terry90/micro-iot", "path": "/src/models/thing.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn from_request(request: &'a Request<'r>) -> request::Outcome<ThingKey, ()> { let keys: Vec<_> = request.headers().get("x-thing-key").collect(); if keys.len() != 1 { return Outcome::Failure((Status::Unauthorized, ())); } let key = match WebToken::from_str(k...
code_fim
hard
{ "lang": "rust", "repo": "terry90/micro-iot", "path": "/src/models/thing.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn checksum(&mut self, digest: &mut Vec<u8>) { if !self.is_checked { // 补0x80, 然后填充0对齐到56字节, 然后按从低字节到高字节填充位长度 let mut tmp = [0u8; 1+63+8]; tmp[0] = 0x80; let pad_len = 55usize.wrapping_sub(self.len) % 64; let len = (self.len << 3) as ...
code_fim
hard
{ "lang": "rust", "repo": "mengsuenyan/rcrypto", "path": "/src/md5/md5.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mengsuenyan/rcrypto path: /src/md5/md5.rs //! MD5(Message Digest Algorithm v-5) //! RFC-1321 //! https://www.cnblogs.com/mengsuenyan/p/12697709.html use crate::Digest; pub(super) const MD5_BLOCK_SIZE: usize = 64; pub(super) const MD5_DIGEST_BITS_LEN: usize = 16 << 3; pub(super) const MD5...
code_fim
hard
{ "lang": "rust", "repo": "mengsuenyan/rcrypto", "path": "/src/md5/md5.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> self.is_checked = false; } fn checksum(&mut self, digest: &mut Vec<u8>) { if !self.is_checked { // 补0x80, 然后填充0对齐到56字节, 然后按从低字节到高字节填充位长度 let mut tmp = [0u8; 1+63+8]; tmp[0] = 0x80; let pad_len = 55usize.wrapping_sub(self.len) % 64; ...
code_fim
hard
{ "lang": "rust", "repo": "mengsuenyan/rcrypto", "path": "/src/md5/md5.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Bugvi-Benjamin-M/Kattis path: /rust/missing-numbers/src/main.rs use std::io; use std::collections::HashSet; fn input () -> String { let mut ret = String::new(); io::stdin().read_line(&mut ret).expect("Failed to read from stdin"); ret } fn main() { let n:u16 = input().trim(...
code_fim
hard
{ "lang": "rust", "repo": "Bugvi-Benjamin-M/Kattis", "path": "/rust/missing-numbers/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if last == n { println!("good job"); } else { let mut diff: Vec<&u16> = correct_range.difference(&recitations).collect(); diff.sort(); for elem in diff { println!("{}", elem); } } }<|fim_prefix|>// repo: Bugvi-Benjamin-M/Kattis path...
code_fim
hard
{ "lang": "rust", "repo": "Bugvi-Benjamin-M/Kattis", "path": "/rust/missing-numbers/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let correct_range: HashSet<u16> = (1..last+1).collect(); if last == n { println!("good job"); } else { let mut diff: Vec<&u16> = correct_range.difference(&recitations).collect(); diff.sort(); for elem in diff { println!("{}", elem); } ...
code_fim
hard
{ "lang": "rust", "repo": "Bugvi-Benjamin-M/Kattis", "path": "/rust/missing-numbers/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TakaakiFuruse/jump-kun path: /src/dir_check.rs use dirs::home_dir; use ignore::gitignore::{Gitignore, GitignoreBuilder}; use jwalk::{ClientState, DirEntry}; use std::fs::File; <|fim_suffix|>pub fn must_be_included<C: ClientState>(entry: &DirEntry<C>, jump_kun_ignore: &Gitignore) -> bool { i...
code_fim
hard
{ "lang": "rust", "repo": "TakaakiFuruse/jump-kun", "path": "/src/dir_check.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn must_be_included<C: ClientState>(entry: &DirEntry<C>, jump_kun_ignore: &Gitignore) -> bool { if entry.file_type.is_dir() { jump_kun_ignore.matched(entry.path(), true).is_none() } else { false } }<|fim_prefix|>// repo: TakaakiFuruse/jump-kun path: /src/dir_check.rs use d...
code_fim
hard
{ "lang": "rust", "repo": "TakaakiFuruse/jump-kun", "path": "/src/dir_check.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> &self, buf: RT::Buf, local: Option<ipv4::Endpoint>, remote: ipv4::Endpoint, ) -> Result<(), Fail> { // First, try to send the packet immediately. if let Some(link_addr) = self.arp.try_query(remote.addr) { let datagram = UdpDatagram { ...
code_fim
hard
{ "lang": "rust", "repo": "stjordanis/demikernel", "path": "/src/rust/catnip/src/protocols/udp/peer.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stjordanis/demikernel path: /src/rust/catnip/src/protocols/udp/peer.rs // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. use super::datagram::{ UdpDatagram, UdpHeader, }; use crate::{ fail::Fail, file_table::{ File, FileDescriptor, ...
code_fim
hard
{ "lang": "rust", "repo": "stjordanis/demikernel", "path": "/src/rust/catnip/src/protocols/udp/peer.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[inline] pub fn circulate(mut thread: Rc<RefCell<JavaThread>>) { let mut reader = BytecodeReader::new(); init(); println!("start {:?}", Local::now()); loop { // let mut borrow_thread = (*thread).borrow_mut(); let current_frame = (*thread).borrow().current_frame(); ...
code_fim
hard
{ "lang": "rust", "repo": "comradeHsu/lark", "path": "/src/interpreter.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: comradeHsu/lark path: /src/interpreter.rs use crate::instructions::base::bytecode_reader::BytecodeReader; use crate::instructions::new_instruction; use crate::native::init; use crate::oops::class::Class; use crate::oops::object::Object; use crate::runtime::thread::JavaThread; use crate::utils::b...
code_fim
hard
{ "lang": "rust", "repo": "comradeHsu/lark", "path": "/src/interpreter.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> assert!(!is_valid_passphrase("aa bb cc dd aa")); } #[test] fn example3() { assert!(is_valid_passphrase("aa bb cc dd aaa")); } #[test] fn example4() { assert!(is_valid_passphrase_anagrams("abcde fghij")); } #[test] fn example5() { asser...
code_fim
hard
{ "lang": "rust", "repo": "HomoCodens/adventofcode_2017_rust", "path": "/src/day4.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }