text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> quote! { 0 #( + #recurse )* } } _ => unimplemented!(), }, _ => unimplemented!(), } } fn data(crate_path: &TokenStream, data: &Data) -> TokenStream { match data { Data::Struct(data) => match &data.f...
code_fim
hard
{ "lang": "rust", "repo": "ChangeCaps/quartz", "path": "/quartz-render/derive/src/uniform.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ChangeCaps/quartz path: /quartz-render/derive/src/uniform.rs use proc_macro2::{Span, TokenStream}; use quote::{quote, quote_spanned}; use syn::spanned::Spanned; use syn::{parse_macro_input, parse_quote, Data, DataStruct, DeriveInput, Fields}; pub fn derive_uniform(input: proc_macro::TokenStream...
code_fim
hard
{ "lang": "rust", "repo": "ChangeCaps/quartz", "path": "/quartz-render/derive/src/uniform.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sajuthankappan/strava-data-rs path: /src/models/polyline_map.rs use serde::{Deserialize, Serialize}; #[derive(Debug, Serialize, Deserialize)] pub struct<|fim_suffix|>on<String>, /// The summary polyline of the map pub summary_polyline: Option<String> }<|fim_middle|> PolylineMap { /// The ...
code_fim
medium
{ "lang": "rust", "repo": "sajuthankappan/strava-data-rs", "path": "/src/models/polyline_map.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>on<String>, /// The summary polyline of the map pub summary_polyline: Option<String> }<|fim_prefix|>// repo: sajuthankappan/strava-data-rs path: /src/models/polyline_map.rs use serde::{Deserialize, Serialize}; #[derive(Debug, Serialize, Deserialize)] pub struct<|fim_middle|> PolylineMap { /// The ...
code_fim
medium
{ "lang": "rust", "repo": "sajuthankappan/strava-data-rs", "path": "/src/models/polyline_map.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alexbush/hahabot path: /src/main.rs use carapax::{ access::{ AccessHandler, AccessRule, InMemoryAccessPolicy, PrincipalChat }, Api, Config, Dispatcher, longpoll::LongPoll, LoggingErrorHandler, ErrorPolicy, ErrorHandler, Hand...
code_fim
hard
{ "lang": "rust", "repo": "alexbush/hahabot", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> dispatcher.set_error_handler(MyErrorHandler); dispatcher.add_handler(handle_start); dispatcher.add_handler(handle_stop); dispatcher.add_handler(handle_corona); dispatcher.add_handler(handle_anekdot); dispatcher.add_handler(handle_bashorg); dispatcher.add_handler(handle_ithappe...
code_fim
hard
{ "lang": "rust", "repo": "alexbush/hahabot", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug, Deserialize)] struct BotConfig { token: String, chats: Option<Vec<i64>>, users: Option<Vec<String>>, } struct MyErrorHandler; #[async_trait] impl ErrorHandler for MyErrorHandler { async fn handle(&mut self, _: HandlerError) -> ErrorPolicy { ErrorPolicy::Continue ...
code_fim
hard
{ "lang": "rust", "repo": "alexbush/hahabot", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn flush(&self) {} } pub fn init() -> Result<(), SetLoggerError> { log::set_boxed_logger(Box::new(Logger {})) }<|fim_prefix|>// repo: jarod/ndk-logger path: /src/lib.rs extern crate log; mod ffi; use std::os::raw::{c_char, c_int}; use log::{Level, Log, Metadata, Record, SetLoggerError}; use ff...
code_fim
hard
{ "lang": "rust", "repo": "jarod/ndk-logger", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jarod/ndk-logger path: /src/lib.rs extern crate log; mod ffi; use std::os::raw::{c_char, c_int}; use log::{Level, Log, Metadata, Record, SetLoggerError}; use ffi::android_LogPriority; pub struct Logger; impl Log for Logger { fn enabled(&self, _metadata: &Metadata) -> bool { <|fim_suffix|...
code_fim
medium
{ "lang": "rust", "repo": "jarod/ndk-logger", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let classes = TagAttributes::remove_attr(&mut attributes, "class").map(TagAttributes::map_classes); let value = TagAttributes::remove_attr(&mut attributes, "value"); let kind = TagAttributes::remove_attr(&mut attributes, "type"); let checked = TagAttributes::rem...
code_fim
hard
{ "lang": "rust", "repo": "mibac138/yew", "path": "/crates/macro/src/html_tree/html_tag/tag_attributes.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn map_listener(listener: TagListener) -> ParseResult<TokenStream> { let TagListener { name, event_name, handler, } = listener; match handler { Expr::Closure(closure) => { let ExprClosure { inp...
code_fim
hard
{ "lang": "rust", "repo": "mibac138/yew", "path": "/crates/macro/src/html_tree/html_tag/tag_attributes.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mibac138/yew path: /crates/macro/src/html_tree/html_tag/tag_attributes.rs use crate::html_tree::HtmlProp as TagAttribute; use crate::PeekValue; use lazy_static::lazy_static; use proc_macro2::TokenStream; use quote::{quote, quote_spanned, ToTokens}; use std::collections::HashMap; use syn::parse::...
code_fim
hard
{ "lang": "rust", "repo": "mibac138/yew", "path": "/crates/macro/src/html_tree/html_tag/tag_attributes.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if !target_class.value().contains("navbar-menu") && tag_name != "svg" { self.close_navbar_mobile = true; } else { self.close_navbar_mobile = false } ...
code_fim
hard
{ "lang": "rust", "repo": "dancespiele/b1MT", "path": "/crate/src/app.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn get_dot(index: usize, lang: Translations) -> Html { let menus = vec![ lang.home, lang.tokenomics, lang.use_cases, lang.buy, lang.partners, lang.road_map, lang.community, ]; let dots = get_dots_icons(); match index { 0 => ...
code_fim
hard
{ "lang": "rust", "repo": "dancespiele/b1MT", "path": "/crate/src/app.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dancespiele/b1MT path: /crate/src/app.rs de::*, route::Route, switch::Permissive, Switch, }; use yew_styles::{ carousel::{Carousel, CarouselDot}, layouts::{ container::{AlignContent, AlignItems, Container, Direction, JustifyContent, Mode, Wrap}, item::{AlignSe...
code_fim
hard
{ "lang": "rust", "repo": "dancespiele/b1MT", "path": "/crate/src/app.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mystor/dist-xprs-example path: /rt/nsIEditorStyleSheets.rs // // DO NOT EDIT. THIS FILE IS GENERATED FROM ../../../dist/idl/nsIEditorStyleSheets.idl // #[repr(C)] pub struct nsIEditorStyleSheets { vtable: *const nsIEditorStyleSheetsVTable, /// This field is a phantomdata to ensure th...
code_fim
hard
{ "lang": "rust", "repo": "mystor/dist-xprs-example", "path": "/rt/nsIEditorStyleSheets.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /* void addOverrideStyleSheet (in AString aURL); */ #[inline] pub unsafe fn addOverrideStyleSheet(&self, aURL: &[u16]) -> Result<(), nsresult> { let aURL = nsString::from(aURL); match ((*self.vtable).addOverrideStyleSheet)(self as *const _, &*aURL) { NS_OK => {}, ...
code_fim
hard
{ "lang": "rust", "repo": "mystor/dist-xprs-example", "path": "/rt/nsIEditorStyleSheets.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[repr(C)] pub struct nsIEditorStyleSheetsVTable { pub __base: nsISupportsVTable, /* void replaceStyleSheet (in AString aURL); */ pub replaceStyleSheet: unsafe extern "C" fn (this: *const nsIEditorStyleSheets, aURL: *const nsAString) -> nsresult, /* void addStyleSheet (in AString aURL); ...
code_fim
hard
{ "lang": "rust", "repo": "mystor/dist-xprs-example", "path": "/rt/nsIEditorStyleSheets.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wellbehavedsoftware/wbs-monitoring path: /src/legacy/check_md_raid.rs //Rust file extern crate regex; extern crate getopts; use getopts::Options; use std::env; use std::process; use std::fs::File; use std::io::Read; use std::path::Path; use regex::Regex; fn print_usage (program: &str, opts: O...
code_fim
hard
{ "lang": "rust", "repo": "wellbehavedsoftware/wbs-monitoring", "path": "/src/legacy/check_md_raid.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> } // Get the devices info of current md status and template let md_raid_devices_string = re.replace_all (& md_raid, ""); let template_devices_string = re.replace_all (& template, ""); // Compare the devices let blank_line_re = Regex::new (r"\n *\n").unwrap (); let md_raid_devices: Vec <...
code_fim
hard
{ "lang": "rust", "repo": "wellbehavedsoftware/wbs-monitoring", "path": "/src/legacy/check_md_raid.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> } let space_re = Regex::new (r" +").unwrap (); for md_raid_device in md_raid_devices.iter () { let normalized_md_raid_device = space_re.replace_all (& md_raid_device, " "); let md_raid_device_tokens: Vec<&str> = normalized_md_raid_device.trim().split(" ").collect(); let mut is_present =...
code_fim
hard
{ "lang": "rust", "repo": "wellbehavedsoftware/wbs-monitoring", "path": "/src/legacy/check_md_raid.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: digitalbitbox/bitbox02-firmware path: /src/rust/bitbox02/src/ui/ui_stub.rs // Copyright 2020 Shift Crypto AG // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // ...
code_fim
hard
{ "lang": "rust", "repo": "digitalbitbox/bitbox02-firmware", "path": "/src/rust/bitbox02/src/ui/ui_stub.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if !self.is_pushed { panic!("component not pushed"); } } } pub fn trinary_input_string_create<'a, F>( params: &TrinaryInputStringParams, mut confirm_callback: F, _cancel_callback: Option<ContinueCancelCb<'a>>, ) -> Component<'a> where F: FnMut(SafeInputStri...
code_fim
hard
{ "lang": "rust", "repo": "digitalbitbox/bitbox02-firmware", "path": "/src/rust/bitbox02/src/ui/ui_stub.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub fn trinary_input_string_set_input(_component: &mut Component, _word: &str) { panic!("not implemented") } pub fn with_lock_animation<F: Fn()>(f: F) { f() } pub fn screen_stack_pop_all() {} pub fn progress_create<'a>(_title: &str) -> Component<'a> { Component { is_pushed: false, ...
code_fim
hard
{ "lang": "rust", "repo": "digitalbitbox/bitbox02-firmware", "path": "/src/rust/bitbox02/src/ui/ui_stub.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> use schema::products::dsl::*; let new_product = new_product.into_inner(); let mon = new_product.days_active.contains(&chrono::Weekday::Mon); let tue = new_product.days_active.contains(&chrono::Weekday::Tue); let wed = new_product.days_active.contains(&chrono::Weekday::Wed); let thu...
code_fim
hard
{ "lang": "rust", "repo": "AurelienMoisson/cafet-pay", "path": "/backend/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AurelienMoisson/cafet-pay path: /backend/src/main.rs #![feature(proc_macro_hygiene, decl_macro)] #[macro_use] extern crate diesel; #[macro_use] extern crate log; #[macro_use] extern crate rocket_contrib; #[macro_use] extern crate rocket; use chrono::{DateTime, Utc}; use diesel::prelude::*; use...
code_fim
hard
{ "lang": "rust", "repo": "AurelienMoisson/cafet-pay", "path": "/backend/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: maboesanman/cargo-llvm-codecov-converter path: /src/codecov.rs use serde::{Serialize, Serializer}; use std::collections::BTreeMap; use std::collections::HashMap; #[derive(Serialize)] pub struct CodeCov<'a> { pub coverage: HashMap<&'a str, BTreeMap<usize, CodeCovLineCoverage>>, } #[derive(C...
code_fim
hard
{ "lang": "rust", "repo": "maboesanman/cargo-llvm-codecov-converter", "path": "/src/codecov.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if hits.len() == 0 { serializer.serialize_none() } else { let regions_hit = hits.iter().filter(|hit| hit.count > 0).count(); let regions = hits.len(); if regions_hit == 0 || regions_hit == regions { let hits = hits.iter().map...
code_fim
hard
{ "lang": "rust", "repo": "maboesanman/cargo-llvm-codecov-converter", "path": "/src/codecov.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> matches } /* * Expects cell to be path. Returns true if turn could be needed * at point. * * # # # # # * ### ## ## ## ## ## ## * # # # etc */ fn is_corner(board: &Vec<Vec<bool>>, x: usize, y: usize) -> boo...
code_fim
hard
{ "lang": "rust", "repo": "joeyfb/aoc19-intcoder", "path": "/src/board.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: joeyfb/aoc19-intcoder path: /src/board.rs use std::collections::HashMap; use std::collections::HashSet; #[derive(Hash, Eq, PartialEq, Debug)] struct Coor { x: usize, y: usize, } impl Coor { pub fn clone(&self) -> Coor { Coor { x: self.x, y: self.y } } } #[derive(Hash, ...
code_fim
hard
{ "lang": "rust", "repo": "joeyfb/aoc19-intcoder", "path": "/src/board.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: porglezomp/pixel-canvas path: /examples/march.rs use pixel_canvas::prelude::*; use rand; use rand_distr::{Distribution, Normal}; use rayon::prelude::*; #[derive(Debug)] struct Camera { pos: Vec3, dir: Vec3, } #[derive(Debug)] struct Hit { point: Vec3, normal: Vec3, } fn render...
code_fim
hard
{ "lang": "rust", "repo": "porglezomp/pixel-canvas", "path": "/examples/march.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let canvas = Canvas::new(300, 720) .hidpi(false) .title("Mountains") .state(Camera { pos: xyz(0.0, 0.0, 5.0), dir: xyz(0.0, 1.0, 0.0), }) .render_on_change(true); let dist = Normal::new(0.0, 0.001).unwrap(); canvas.render(move |c...
code_fim
hard
{ "lang": "rust", "repo": "porglezomp/pixel-canvas", "path": "/examples/march.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bitcoinmw/rust-tor path: /tor-proto/src/crypto/handshake/fast.rs //! Implementation for the (deprecated) CreateFast handshake. //! use crate::crypto::ll::kdf::{Kdf, LegacyKdf}; use crate::util::ct::bytes_eq; use crate::{Error, Result}; use rand::{CryptoRng, RngCore}; /// Number of bytes used ...
code_fim
hard
{ "lang": "rust", "repo": "bitcoinmw/rust-tor", "path": "/tor-proto/src/crypto/handshake/fast.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> rng: &mut R, _key: &[Self::KeyType], msg: T, ) -> Result<(Self::KeyGen, Vec<u8>)> { let msg = msg.as_ref(); if msg.len() != FAST_C_HANDSHAKE_LEN { return Err(Error::BadHandshake); } let mut reply = vec![0_u8; FAST_S_HANDSHAKE_LEN]; rng.fill_bytes(&mut reply[0..20]); let mut inp = Ve...
code_fim
hard
{ "lang": "rust", "repo": "bitcoinmw/rust-tor", "path": "/tor-proto/src/crypto/handshake/fast.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: robertpyke/rusty-ai path: /src/ai.rs use rand::prelude::*; use specs::prelude::*; use crate::components::*; const ENEMY_MOVEMENT_SPEED: i32 = 8; const HERO_MOVEMENT_SPEED: i32 = 3; pub struct AI; impl<'a> System<'a> for AI { type SystemData = ( ReadStorage<'a, AIControlled>, ...
code_fim
hard
{ "lang": "rust", "repo": "robertpyke/rusty-ai", "path": "/src/ai.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match nearest_enemy_pos { Some(nearest_enemy_pos) => { let enemy_x = nearest_enemy_pos.0.x; let enemy_y = nearest_enemy_pos.0.y; let x_delta = enemy_x - hero_x; let x_delta_abs = x_delta.abs(); ...
code_fim
hard
{ "lang": "rust", "repo": "robertpyke/rusty-ai", "path": "/src/ai.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pontuslaestadius/pathtracer path: /src/tests/from.rs use crate::*; #[test] fn coordinate_conversion() { let node = Node::new("", Coordinate::new(6, 1)); let c = Coordinate::from(node); assert_eq!(c, Coordinate::new(6, 1)); let group = Group::new_simple(4, 3); let c = Coordi...
code_fim
medium
{ "lang": "rust", "repo": "pontuslaestadius/pathtracer", "path": "/src/tests/from.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let node = Node::new("", Coordinate::new(4, 3)); let group = Group::from(node); assert_eq!(group.position(), Coordinate::new(4, 3)); }<|fim_prefix|>// repo: pontuslaestadius/pathtracer path: /src/tests/from.rs use crate::*; #[test] fn coordinate_conversion() { let node = Node::new("", Co...
code_fim
hard
{ "lang": "rust", "repo": "pontuslaestadius/pathtracer", "path": "/src/tests/from.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: matteodepalo/ariko path: /sam3x8e-rs/sam3x8e-hal-codegen/src/pio.rs /* * This file (src/pio.rs) is part of sam3x8e-hal-codegen. * * sam3x8e-hal-codegen is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published ...
code_fim
hard
{ "lang": "rust", "repo": "matteodepalo/ariko", "path": "/sam3x8e-rs/sam3x8e-hal-codegen/src/pio.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> copy of the GNU Lesser General Public License * along with sam3x8e-hal-codegen. If not, see <https://www.gnu.org/licenses/>. */ mod pin; mod pio; mod pio_set; pub use pin::*; pub use pio::*; pub use pio_set::*;<|fim_prefix|>// repo: matteodepalo/ariko path: /sam3x8e-rs/sam3x8e-hal-codegen/src/pi...
code_fim
hard
{ "lang": "rust", "repo": "matteodepalo/ariko", "path": "/sam3x8e-rs/sam3x8e-hal-codegen/src/pio.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let (a, b) = (v[0].0, v[1].0); println!("{}", if a < b { v[0].1 } else { v[1].1 }); }<|fim_prefix|>// repo: yuniruyuni/atcoder path: /abc188-c/src/main.rs use proconio::input; fn main() { input! { n: u32, x: [i32; 2usize.pow(n)], } <|fim_middle|> let mut v = Vec::new(...
code_fim
hard
{ "lang": "rust", "repo": "yuniruyuni/atcoder", "path": "/abc188-c/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for _ in 1..n { let mut w = Vec::new(); for k in 0..(v.len()/2) { let (i, j) = (2*k, 2*k + 1); w.push(if v[i].0 < v[j].0 { v[j] } else { v[i] }); } v = w; } let (a, b) = (v[0].0, v[1].0); println!("{}", if a < b { v[0].1 } else { v[1...
code_fim
medium
{ "lang": "rust", "repo": "yuniruyuni/atcoder", "path": "/abc188-c/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yuniruyuni/atcoder path: /abc188-c/src/main.rs use proconio::input; fn main() { input! { n: u32, x: [i32; 2usize.pow(n)], } <|fim_suffix|> let (a, b) = (v[0].0, v[1].0); println!("{}", if a < b { v[0].1 } else { v[1].1 }); }<|fim_middle|> let mut v = Vec::new(...
code_fim
hard
{ "lang": "rust", "repo": "yuniruyuni/atcoder", "path": "/abc188-c/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut qs = init.clone(); let mut result = 0; for line in input { if line.len() == 0 { result += qs.len(); qs = init.clone(); } else { qs = qs .intersection(&(line.chars().collect())) ...
code_fim
hard
{ "lang": "rust", "repo": "thopper21/AoC20-RS", "path": "/src/days/day6.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: thopper21/AoC20-RS path: /src/days/day6.rs use crate::day::Day; use std::collections::HashSet; use std::iter::once; pub struct Day6; impl Day for Day6 { type T1 = usize; fn part1<I>(input: I) -> usize where I: Iterator<Item = String>, { let mut qs = HashSet::<c...
code_fim
hard
{ "lang": "rust", "repo": "thopper21/AoC20-RS", "path": "/src/days/day6.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AllanPeres/rust_examples path: /src/objects/point.rs use std::ops::Add; pub struct Point { pub x: i32, pub y: i32 } impl Point { pub fn calculate_distance(&self) -> f64 { let sum_of_squares = self.x.pow(2) + self.y.pow(2); (sum_of_squares as f64).sqrt() } } <|f...
code_fim
medium
{ "lang": "rust", "repo": "AllanPeres/rust_examples", "path": "/src/objects/point.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Point { x: self.x + point.x, y: self.y + point.y } } }<|fim_prefix|>// repo: AllanPeres/rust_examples path: /src/objects/point.rs use std::ops::Add; pub struct Point { pub x: i32, pub y: i32 } impl Point { pub fn calculate_distance(&self) -> f64 {...
code_fim
easy
{ "lang": "rust", "repo": "AllanPeres/rust_examples", "path": "/src/objects/point.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut rwtxn = self.env.begin_rw_txn().expect("can't begin rw txn"); let wbytes = serde_json::to_string(&head).expect("failed to serialize"); rwtxn .put(self.db, &LONGEST_HEAD_KEY, &wbytes, WriteFlags::empty()) .expect("put failed"); rwtxn.commit(...
code_fim
hard
{ "lang": "rust", "repo": "discosultan/test-assignments", "path": "/blockchain-explorer/src/storage/lmdb.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let rotxn = self.env.begin_ro_txn().expect("can't begin ro txn"); match rotxn.get(self.db, &LONGEST_HEAD_KEY) { Ok(rbytes) => { let rstr = std::str::from_utf8(rbytes).expect("failed to parse read bytes"); let rval: BlockLength = serde_json::from_...
code_fim
hard
{ "lang": "rust", "repo": "discosultan/test-assignments", "path": "/blockchain-explorer/src/storage/lmdb.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: discosultan/test-assignments path: /blockchain-explorer/src/storage/lmdb.rs use lmdb::{DatabaseFlags, Environment, Transaction, WriteFlags, Database}; use tempdir::TempDir; use crate::block::BlockID; use super::{BlockLength, BlockState}; const LONGEST_HEAD_KEY: &'static str = "longest_head"; ...
code_fim
hard
{ "lang": "rust", "repo": "discosultan/test-assignments", "path": "/blockchain-explorer/src/storage/lmdb.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: naveednajam/rust-raop-player path: /src/main.rs // Docopt #[macro_use] extern crate serde_derive; use docopt::Docopt; // Standard dependencies use std::net::{IpAddr, SocketAddr}; use std::os::unix::io::FromRawFd; use std::sync::Arc; use std::time::Duration; // General dependencies use beefeate...
code_fim
hard
{ "lang": "rust", "repo": "naveednajam/rust-raop-player", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let frames = Arc::new(Beefeater::new(Frames::new(0))); { let status = status.clone(); ctrlc::set_handler(move || { info!("Recevied SIGINT, stopping playback"); status.store(Status::Stopped); })?; } let status_logger = StatusLogger::start(st...
code_fim
hard
{ "lang": "rust", "repo": "naveednajam/rust-raop-player", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Error::DecodeError(other) } } impl From<tobj::LoadError> for Error { fn from(other: tobj::LoadError) -> Self { Error::ObjLoadError(other.to_string()) } } /// Safely loads data from a resource path root. pub struct ResourceLoader { path_root: PathBuf, } impl ResourceLoade...
code_fim
hard
{ "lang": "rust", "repo": "ad2476/cuddly-broccoli", "path": "/src/resources.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ad2476/cuddly-broccoli path: /src/resources.rs //! Resource loading system. //! //! Use `ResourceLoader` for loading files from a resource root path. use std; use std::ffi::{CString, NulError}; use std::fs; use std::io::{self, Read}; use std::path::{Path, PathBuf}; use image; use tobj; /// Er...
code_fim
hard
{ "lang": "rust", "repo": "ad2476/cuddly-broccoli", "path": "/src/resources.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Load an OBJ model. Wraps `tobj::load_obj` to handle relative resource paths. pub fn load_obj( &self, resource_name: &Path, ) -> Result<(Vec<tobj::Model>, Vec<tobj::Material>), Error> { tobj::load_obj(&self.path_root.join(resource_name)).map_err(|e| e.into()) } ...
code_fim
hard
{ "lang": "rust", "repo": "ad2476/cuddly-broccoli", "path": "/src/resources.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl NumericOps<isize> for Exp<isize> { fn plus(left: Self, right: Self) -> Self { Exp::bind2(left, right, |left, right| match (left, right) { (ExpNode::Const(left), ExpNode::Const(right)) => ExpNode::Const(left + right).into(), (left, right) => to_atom(Plus { left, rig...
code_fim
hard
{ "lang": "rust", "repo": "zeta1999/lms", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn to_atom<A, D>(def: D) -> Exp<A> where D: Def<A> + 'static, { Exp::new(move |ctx| { if let Some(index) = ctx.lookup_def(&def) { ExpNode::Sym(index) } else { println!("inserting node of type {:?} : {:?}", def.type_id(), def); ExpNode::Sym(ctx.in...
code_fim
hard
{ "lang": "rust", "repo": "zeta1999/lms", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zeta1999/lms path: /src/lib.rs use std::any::Any; use std::fmt::Debug; use std::ops::{Add, Mul, Sub}; pub mod codegen; pub struct Context { symbol_table: Vec<Box<dyn Any>>, fresh: usize, } impl Default for Context { fn default() -> Self { Context { symbol_table...
code_fim
hard
{ "lang": "rust", "repo": "zeta1999/lms", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>t h2: i32 = s2.trim().parse().ok().unwrap(); println!("{}", h1 - h2); }<|fim_prefix|>// repo: pes-magic/procon path: /AtCoder/ABC001/A.rs fn main(){ let mut s1 = String::new(); std::io::stdin().read_line(&mut s1).ok(); let h1: i32 = s1.trim().parse().ok().unwrap(); let m<|fim_middle|>...
code_fim
medium
{ "lang": "rust", "repo": "pes-magic/procon", "path": "/AtCoder/ABC001/A.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pes-magic/procon path: /AtCoder/ABC001/A.rs fn main(){ let mut s1 = String::new(); std::io::stdin().read_line(<|fim_suffix|>ut s2 = String::new(); std::io::stdin().read_line(&mut s2).ok(); let h2: i32 = s2.trim().parse().ok().unwrap(); println!("{}", h1 - h2); }<|fim_middle|>...
code_fim
medium
{ "lang": "rust", "repo": "pes-magic/procon", "path": "/AtCoder/ABC001/A.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: carllerche/eventual_io path: /test/frame/test_frame_len.rs use bytes::{Bytes, ToBytes}; use eventual::Future; use eio; use eio::frame::{Frame, Len}; #[test] pub fn test_framing_exact_sized_chunk() { let s = stream(vec![b"foo", b"bar", b"baz"]) .frame(Len::new(3)); let chunks: V...
code_fim
hard
{ "lang": "rust", "repo": "carllerche/eventual_io", "path": "/test/frame/test_frame_len.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Future::lazy(move || { if chunks.is_empty() { return Ok(None); } let val = chunks.remove(0); Ok(Some((Bytes::from_slice(val), stream(chunks)))) }).to_stream() }<|fim_prefix|>// repo: carllerche/eventual_io path: /test/frame/test_frame_len.rs use bytes:...
code_fim
hard
{ "lang": "rust", "repo": "carllerche/eventual_io", "path": "/test/frame/test_frame_len.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let chunks: Vec<Bytes> = s.iter().collect(); assert_eq!(2, chunks.len()); assert_eq!(chunks[0], b"foo".to_bytes()); assert_eq!(chunks[1], b"barbaz".to_bytes()); } fn stream(mut chunks: Vec<&'static [u8]>) -> eio::Stream<Bytes> { Future::lazy(move || { if chunks.is_empty() { ...
code_fim
hard
{ "lang": "rust", "repo": "carllerche/eventual_io", "path": "/test/frame/test_frame_len.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn init_dma(sys_state: &mut SystemState) { sys_state.io_set_reg(IOReg::HDMA1, 0x00); sys_state.io_set_reg(IOReg::HDMA2, 0x00); sys_state.io_set_reg(IOReg::HDMA3, 0x80); sys_state.io_set_reg(IOReg::HDMA4, 0x00); sys_state.io_set_reg(IOReg::HDMA5, 0x80); } const IOW_HANDLERS: [fn(&m...
code_fim
hard
{ "lang": "rust", "repo": "XanClic/xgbcrew", "path": "/src/io.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: XanClic/xgbcrew path: /src/io.rs pub mod int; pub mod ir; pub mod keypad; pub mod lcd; pub mod serial; pub mod sound; pub mod timer; #[cfg(target_os = "linux")] use crate::address_space::AS_BASE; use crate::address_space::AddressSpace; use crate::system_state::{IOReg, SystemState}; pub trait ...
code_fim
hard
{ "lang": "rust", "repo": "XanClic/xgbcrew", "path": "/src/io.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn hdma_copy_16b(sys_state: &mut SystemState) -> bool { let hdma = (sys_state.io_get_reg(IOReg::HDMA1), sys_state.io_get_reg(IOReg::HDMA2), sys_state.io_get_reg(IOReg::HDMA3), sys_state.io_get_reg(IOReg::HDMA4)); let mut src = ((hdma.0 as u16) <...
code_fim
hard
{ "lang": "rust", "repo": "XanClic/xgbcrew", "path": "/src/io.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if let Some(named) = &internal.args.named { for (_, named_arg) in named.iter() { match named_arg { NamedValue::PresentSwitch(span) => { output.pus...
code_fim
hard
{ "lang": "rust", "repo": "seanwallawalla-forks/nushell", "path": "/crates/nu-parser/src/shapes.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if let Some(positionals) = &call.positional { for positional_arg in positionals { output.append(&mut expression_to_flat_shape(positional_arg)); } } ...
code_fim
hard
{ "lang": "rust", "repo": "seanwallawalla-forks/nushell", "path": "/crates/nu-parser/src/shapes.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: seanwallawalla-forks/nushell path: /crates/nu-parser/src/shapes.rs use nu_protocol::hir::*; use nu_protocol::UnspannedPathMember; use nu_source::{Spanned, SpannedItem}; /// Converts a SpannedExpression into a spanned shape(s) ready for color-highlighting pub fn expression_to_flat_shape(e: &Span...
code_fim
hard
{ "lang": "rust", "repo": "seanwallawalla-forks/nushell", "path": "/crates/nu-parser/src/shapes.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn build_pitch(pitchType: PitchType, aim_x: f32, aim_y: f32, loc_x: f32, loc_y: f32, speed: f32) -> Pitch { Pitch { pitchType, aim_x, aim_y, loc_x, loc_y, speed, } }<|fim_prefix|>// repo: lrssnn/game-test path: /src/pitch.rs #[derive(Debug, Copy...
code_fim
medium
{ "lang": "rust", "repo": "lrssnn/game-test", "path": "/src/pitch.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lrssnn/game-test path: /src/pitch.rs #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum PitchType {Fastball, Curveball, None} <|fim_suffix|>pub fn build_pitch(pitchType: PitchType, aim_x: f32, aim_y: f32, loc_x: f32, loc_y: f32, speed: f32) -> Pitch { Pitch { pitchType, ...
code_fim
medium
{ "lang": "rust", "repo": "lrssnn/game-test", "path": "/src/pitch.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: robo9k/chip8-rs path: /src/keypad.rs //! Keys and keypad use crate::errors::Chip8Error; use core::convert::TryFrom; use core::ops::{Index, IndexMut}; /// Possible state for each key #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum KeyState { /// Key not pressed NotPressed = 0, ...
code_fim
hard
{ "lang": "rust", "repo": "robo9k/chip8-rs", "path": "/src/keypad.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> _ => Err(Chip8Error::InvalidKey(value)), } } } /// 16-key hexadecimal keypad /// /// # Key layout // table without thead requires html /// <table> /// <tr> /// <td>1 /// <td>2 /// <td>3 /// <td>C /// <tr> /// <td>4 /// <td>5 ...
code_fim
hard
{ "lang": "rust", "repo": "robo9k/chip8-rs", "path": "/src/keypad.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Default for Keypad { #[must_use] fn default() -> Self { Self::new() } } #[cfg(test)] mod tests { use super::*; #[test] fn keypad_default() { use super::{Key::*, KeyState::*}; let keypad = Keypad::default(); assert_eq!(keypad[Key0], NotPresse...
code_fim
hard
{ "lang": "rust", "repo": "robo9k/chip8-rs", "path": "/src/keypad.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tomhoule/nannou-sketches path: /src/bin/nenuphars.rs ///! inspired by https://www.instagram.com/p/Ba9ApsdFlnV/ use nannou::draw::properties::color::IntoRgba; use nannou::prelude::*; const POPUP_INTERVAL: std::time::Duration = std::time::Duration::from_millis(500); /// The lifetime one px of ra...
code_fim
hard
{ "lang": "rust", "repo": "tomhoule/nannou-sketches", "path": "/src/bin/nenuphars.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let draw = app.draw(); for nenuphar in model .nenuphars .iter() .filter(|n| n.state != NenupharState::Dead) { nenuphar.draw(&draw); } draw.to_frame(app, &frame).unwrap(); frame } fn update(app: &App...
code_fim
hard
{ "lang": "rust", "repo": "tomhoule/nannou-sketches", "path": "/src/bin/nenuphars.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> (db, executor) } /// Runs the benchmark with given parameters. pub fn run_benchmark( num_accounts: usize, init_account_balance: u64, block_size: usize, num_transfer_blocks: usize, db_dir: Option<PathBuf>, ) { let (mut config, genesis_key) = diem_genesis_tool::test_config(); ...
code_fim
hard
{ "lang": "rust", "repo": "samonh/diem", "path": "/execution/executor-benchmark/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Wait for generator to finish. let mut generator = gen_thread.join().unwrap(); generator.drop_sender(); // Wait until all transactions are committed. exe_thread.join().unwrap(); commit_thread.join().unwrap(); // Do a sanity check on the sequence number to make sure all trans...
code_fim
hard
{ "lang": "rust", "repo": "samonh/diem", "path": "/execution/executor-benchmark/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: samonh/diem path: /execution/executor-benchmark/src/lib.rs // Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 pub mod transaction_committer; pub mod transaction_executor; pub mod transaction_generator; use crate::{ transaction_committer::TransactionCommitter...
code_fim
hard
{ "lang": "rust", "repo": "samonh/diem", "path": "/execution/executor-benchmark/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: defvar/toy path: /shared/toy-pack-json/src/encode/error.rs use std::backtrace::Backtrace; use std::fmt::Display; use std::io; use thiserror::Error as ThisError; /// Using Encoder and Serializer. /// It is used when an error occurs in the implementation of serialization. /// #[derive(Debug, This...
code_fim
medium
{ "lang": "rust", "repo": "defvar/toy", "path": "/shared/toy-pack-json/src/encode/error.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[error("{:?}", inner)] Error { inner: String }, } impl EncodeError { pub fn error<T>(msg: T) -> EncodeError where T: Display, { EncodeError::Error { inner: msg.to_string(), } } } impl serde::ser::Error for EncodeError { fn custom<T>(msg: T...
code_fim
hard
{ "lang": "rust", "repo": "defvar/toy", "path": "/shared/toy-pack-json/src/encode/error.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl serde::ser::Error for EncodeError { fn custom<T>(msg: T) -> Self where T: Display, { EncodeError::error(msg) } }<|fim_prefix|>// repo: defvar/toy path: /shared/toy-pack-json/src/encode/error.rs use std::backtrace::Backtrace; use std::fmt::Display; use std::io; use thi...
code_fim
hard
{ "lang": "rust", "repo": "defvar/toy", "path": "/shared/toy-pack-json/src/encode/error.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug)] pub struct ColumnDef { name: String, sql_type: SqlType, ord_num: usize, } impl ColumnDef { pub fn new(name: String, sql_type: SqlType, ord_num: usize) -> ColumnDef { ColumnDef { name, sql_type, ord_num, } } pub ...
code_fim
hard
{ "lang": "rust", "repo": "Tolledo/database", "path": "/entities/definition/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn try_from(object: &'o sql_ast::ObjectName) -> Result<Self, Self::Error> { if object.0.len() == 1 { Err(TableNamingError::Unqualified(object.to_string())) } else if object.0.len() != 2 { Err(TableNamingError::NotProcessed(object.to_string())) } else { ...
code_fim
hard
{ "lang": "rust", "repo": "Tolledo/database", "path": "/entities/definition/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Tolledo/database path: /entities/definition/src/lib.rs // Copyright 2020 - present Alex Dukhno // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www...
code_fim
hard
{ "lang": "rust", "repo": "Tolledo/database", "path": "/entities/definition/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ioncodes/gbr path: /gbr/src/cpu.rs use registers::Registers; use rom::Rom; <|fim_suffix|> pub fn cycle(&self) { // load next opcode } pub fn execute(&self) { // execute opcode } }<|fim_middle|>pub struct CPU { pub opcode: u8, pub rom: Rom, } impl CPU { ...
code_fim
hard
{ "lang": "rust", "repo": "ioncodes/gbr", "path": "/gbr/src/cpu.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn execute(&self) { // execute opcode } }<|fim_prefix|>// repo: ioncodes/gbr path: /gbr/src/cpu.rs use registers::Registers; use rom::Rom; pub struct CPU { pub opcode: u8, pub rom: Rom, } <|fim_middle|>impl CPU { pub fn new(rom_path: String) -> CPU { CPU { ...
code_fim
hard
{ "lang": "rust", "repo": "ioncodes/gbr", "path": "/gbr/src/cpu.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn cycle(&self) { // load next opcode } pub fn execute(&self) { // execute opcode } }<|fim_prefix|>// repo: ioncodes/gbr path: /gbr/src/cpu.rs use registers::Registers; use rom::Rom; pub struct CPU { pub opcode: u8, pub rom: Rom, } <|fim_middle|>impl CPU { ...
code_fim
medium
{ "lang": "rust", "repo": "ioncodes/gbr", "path": "/gbr/src/cpu.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>macro_rules! array_as_expression { ($ty:ty, $sql_type:ty) => { #[cfg(feature = "postgres_backend")] // this simplifies the macro implementation // as some macro calls use this lifetime #[allow(clippy::extra_unused_lifetimes)] impl<'a, 'b, ST: 'static, T> AsExpre...
code_fim
hard
{ "lang": "rust", "repo": "diesel-rs/diesel", "path": "/diesel/src/pg/types/array.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>use crate::expression::bound::Bound; use crate::expression::AsExpression; macro_rules! array_as_expression { ($ty:ty, $sql_type:ty) => { #[cfg(feature = "postgres_backend")] // this simplifies the macro implementation // as some macro calls use this lifetime #[allow(cl...
code_fim
hard
{ "lang": "rust", "repo": "diesel-rs/diesel", "path": "/diesel/src/pg/types/array.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: diesel-rs/diesel path: /diesel/src/pg/types/array.rs use byteorder::{NetworkEndian, ReadBytesExt, WriteBytesExt}; use std::fmt; use std::io::Write; use crate::deserialize::{self, FromSql}; use crate::pg::{Pg, PgTypeMetadata, PgValue}; use crate::query_builder::bind_collector::ByteWrapper; use c...
code_fim
hard
{ "lang": "rust", "repo": "diesel-rs/diesel", "path": "/diesel/src/pg/types/array.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: palvarez89/adventofcode2017 path: /day09/day09.rs use std::env; use std::fs::File; use std::collections::HashMap; use std::io::prelude::*; use std::io::{BufReader}; fn main() { let args: Vec<String> = env::args().collect(); if args.len() < 2 { println!("i need a filename as ar...
code_fim
medium
{ "lang": "rust", "repo": "palvarez89/adventofcode2017", "path": "/day09/day09.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut deep = 0; let mut in_trash = false; let mut ignore_next = false; let mut score = 0; let mut garbage = 0; let mut contents = String::new(); f.read_to_string(&mut contents).expect("Unable to read the file"); for ch in contents.chars() { if ignore_next { ...
code_fim
medium
{ "lang": "rust", "repo": "palvarez89/adventofcode2017", "path": "/day09/day09.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut contents = String::new(); f.read_to_string(&mut contents).expect("Unable to read the file"); for ch in contents.chars() { if ignore_next { ignore_next = false; println!("-i- {}", ch); continue; } if ch == '!' { ign...
code_fim
hard
{ "lang": "rust", "repo": "palvarez89/adventofcode2017", "path": "/day09/day09.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/fixup-deref-mut.rs // run-pass #![allow(dead_code)] // pretty-expanded FIXME #23616 use std::ops::{Deref, DerefMut}; // Generic unique/owned smaht pointer. struct Own<T> { value: *mut T } impl<T> Deref for Own<T> { type Target = T; ...
code_fim
hard
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/fixup-deref-mut.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> unsafe { &mut *self.value } } } struct Point { x: isize, y: isize } impl Point { fn get(&mut self) -> (isize, isize) { (self.x, self.y) } } fn test0(mut x: Own<Point>) { let _ = x.get(); } fn test1(mut x: Own<Own<Own<Point>>>) { let _ = x.get(); } fn test2(...
code_fim
medium
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/fixup-deref-mut.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for k_i in 0..MAX_K { f[0][k_i] = 1; f[1][k_i] = k as i32 - 1; } for n_i in 0..MAX_N { f[n_i][0] = 0; } let res = solve(&mut f, n as usize, k as usize); println!("{}", res); }<|fim_prefix|>// repo: hywei/timus-rust path: /1009.rs use std::io; const MAX_...
code_fim
hard
{ "lang": "rust", "repo": "hywei/timus-rust", "path": "/1009.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hywei/timus-rust path: /1009.rs use std::io; const MAX_N : usize = 17; const MAX_K : usize = 11; fn solve(f: &mut [[i32; MAX_K]; MAX_N], n : usize, k : usize) -> i32 { // println!("{}, {}", n, k); <|fim_suffix|> return f[n][k]; } fn main() { let mut n_str = String::new(); let ...
code_fim
medium
{ "lang": "rust", "repo": "hywei/timus-rust", "path": "/1009.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Self { body: Some(body), form: None, headers: None, method, path, path_str, } } } impl From<(Vec<u8>, Form, Route)> for Request { fn from((body, form, route): (Vec<u8>, Form, Route)) -> Self { let (met...
code_fim
hard
{ "lang": "rust", "repo": "haze/dawn", "path": "/http/src/request/mod.rs", "mode": "spm", "license": "ISC", "source": "the-stack-v2" }
<|fim_prefix|>// repo: haze/dawn path: /http/src/request/mod.rs macro_rules! poll_req { ($ty: ty, $ret: ty) => { impl std::future::Future for $ty { type Output = $crate::error::Result<$ret>; fn poll( mut self: std::pin::Pin<&mut Self>, cx: &mut std::...
code_fim
hard
{ "lang": "rust", "repo": "haze/dawn", "path": "/http/src/request/mod.rs", "mode": "psm", "license": "ISC", "source": "the-stack-v2" }