text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|>impl Prototype for DontCraftManuallyAchievement { const TYPE: Option<&'static str> = Some("dont-craft-manually-achievement"); }<|fim_prefix|>// repo: jgraef/rustorio path: /rustorio-core/src/prototypes/prototypes/dont_craft_manually_achievement.rs use serde::{Deserialize, Serialize}; use crate::prot...
code_fim
medium
{ "lang": "rust", "repo": "jgraef/rustorio", "path": "/rustorio-core/src/prototypes/prototypes/dont_craft_manually_achievement.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl ElseCond { pub fn dump_for_testing(&self) -> serde_json::Value { return match self { ElseCond::None => serde_json::Value::Null, ElseCond::Else(stmts) => serde_json::Value::Array( stmts .iter() .map(|s| s.dump_...
code_fim
hard
{ "lang": "rust", "repo": "google/vimscript-language-server", "path": "/vimscript-core/src/ast.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: google/vimscript-language-server path: /vimscript-core/src/ast.rs // Copyright 2019 Google LLC // // 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://ww...
code_fim
hard
{ "lang": "rust", "repo": "google/vimscript-language-server", "path": "/vimscript-core/src/ast.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl StringLiteralExpression { pub fn dump_for_testing(&self) -> serde_json::Value { return json!(self); } } impl Serialize for StringLiteralExpression { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: Serializer, { serializer.serializ...
code_fim
hard
{ "lang": "rust", "repo": "google/vimscript-language-server", "path": "/vimscript-core/src/ast.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: krircc/kayrx path: /tests/web/config.rs use kayrx::service::Service; use bytes::Bytes; use kayrx::web::*; use kayrx::web::dev::*; use kayrx::http::{Method, StatusCode}; use kayrx::web::test::{call_service, init_service, read_body, TestRequest}; use kayrx::web::{self, App, HttpRequest}; use kayr...
code_fim
hard
{ "lang": "rust", "repo": "krircc/kayrx", "path": "/tests/web/config.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let req = TestRequest::with_uri("/test") .method(Method::GET) .to_request(); let resp = call_service(&mut srv, req).await; assert_eq!(resp.status(), StatusCode::CREATED); let req = TestRequest::with_uri("/index.html") .method(Method::GET) .to_request(); ...
code_fim
hard
{ "lang": "rust", "repo": "krircc/kayrx", "path": "/tests/web/config.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>// let cfg2 = |cfg: &mut ServiceConfig| { // cfg.data_factory(|| Ok::<_, ()>(10u32)); // }; // let mut srv = init_service( // App::new() // .service(web::resource("/").to(|_: web::Data<usize>| HttpResponse::Ok())) // .configure(cfg2), // ); // le...
code_fim
hard
{ "lang": "rust", "repo": "krircc/kayrx", "path": "/tests/web/config.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { input! { n: usize, m: usize, q: usize, } let mut score = vec![n; m]; let mut solved = vec![vec![]; n]; for _ in 0..q { input! { t: usize, } if t == 1 { input! { a: Usize1, } ...
code_fim
medium
{ "lang": "rust", "repo": "likr/atcoder", "path": "/past202005-2/src/bin/b.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: likr/atcoder path: /past202005-2/src/bin/b.rs use proconio::input; #[allow(unused_imports)] use proconio::marker::*; #[allow(unused_imports)] use std::cmp::*; #[allow(unused_imports)] use std::collections::*; #[allow(unused_imports)] use std::f64::consts::*; #[allow(unused)] const INF: usize = ...
code_fim
medium
{ "lang": "rust", "repo": "likr/atcoder", "path": "/past202005-2/src/bin/b.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> info!("Executed issue ID {:?}", issue_id); Ok(()) } /// Set issue period pub async fn set_issue_period(issue_prov: &PolkaBtcProvider, period: u32) -> Result<(), Error> { issue_prov.set_issue_period(period).await?; info!("Set the issue period to {:?}", period,); Ok(()) }<|fim_prefix|...
code_fim
hard
{ "lang": "rust", "repo": "w3f-grants-archive/polkabtc-clients", "path": "/testdata-gen/src/issue.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> issue_prov .execute_issue(issue_id, tx_metadata.proof, tx_metadata.raw_tx) .await?; info!("Executed issue ID {:?}", issue_id); Ok(()) } /// Set issue period pub async fn set_issue_period(issue_prov: &PolkaBtcProvider, period: u32) -> Result<(), Error> { issue_prov.set_iss...
code_fim
hard
{ "lang": "rust", "repo": "w3f-grants-archive/polkabtc-clients", "path": "/testdata-gen/src/issue.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: w3f-grants-archive/polkabtc-clients path: /testdata-gen/src/issue.rs #![allow(dead_code)] use crate::Error; use bitcoin::{BitcoinCore, BitcoinCoreApi}; use log::info; use runtime::{ AccountId, BtcAddress, BtcRelayPallet, H256Le, IssuePallet, PolkaBtcIssueRequest, PolkaBtcProvider, Polka...
code_fim
hard
{ "lang": "rust", "repo": "w3f-grants-archive/polkabtc-clients", "path": "/testdata-gen/src/issue.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub fn user_show(payload: web::Query<RequestUserShow>) -> HttpResponse { let repository_user = RepositoryUser::new(); let domain_user = &service_user_show( repository_user, payload.user_id, ); response_user_show(domain_user) }<|fim_prefix|>// repo: duzhanyuan/rust-api-sampl...
code_fim
hard
{ "lang": "rust", "repo": "duzhanyuan/rust-api-sample", "path": "/src/controller/user.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: duzhanyuan/rust-api-sample path: /src/controller/user.rs use actix_web::{ HttpResponse, web, }; use super::super::service::user::{service_user_index, service_user_show}; use super::super::repository::user::RepositoryUser; use super::super::response::{ user_index::response_user_index,...
code_fim
hard
{ "lang": "rust", "repo": "duzhanyuan/rust-api-sample", "path": "/src/controller/user.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for c in chars { assert!(min < max); let sz = (max - min) + 1; if c == 'F' || c == 'L' { max -= sz / 2; } else { min += sz / 2; } } assert!(min == max); min } #[test] fn test_row() { assert_eq!(row("FBFBBFFRLR"), 44); } fn col(pass: &str) -> u32 { bsp(0, MAX_COL, pass.chars().ski...
code_fim
medium
{ "lang": "rust", "repo": "sgravrock/adventofcode", "path": "/2020/rust/day5p1/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sgravrock/adventofcode path: /2020/rust/day5p1/src/main.rs mod input; fn main() { let highest = input::puzzle_input() .lines() .map(seat_id) .max().unwrap(); println!("{}", highest); // 930 } static MAX_ROW: u32 = 127; static MAX_COL: u32 = 7; fn seat_id(pass: &str) -> u32 { row(pas...
code_fim
hard
{ "lang": "rust", "repo": "sgravrock/adventofcode", "path": "/2020/rust/day5p1/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if c == 'F' || c == 'L' { max -= sz / 2; } else { min += sz / 2; } } assert!(min == max); min } #[test] fn test_row() { assert_eq!(row("FBFBBFFRLR"), 44); } fn col(pass: &str) -> u32 { bsp(0, MAX_COL, pass.chars().skip(7)) } #[test] fn test_col() { assert_eq!(col("FBFBBFFRLR"), 5); }...
code_fim
medium
{ "lang": "rust", "repo": "sgravrock/adventofcode", "path": "/2020/rust/day5p1/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tristan/adventofcode2019 path: /day_09.rs use common::intcode::{self, Signal}; #[derive(Debug)] enum Error { IntCodeError(intcode::Error), } impl From<intcode::Error> for Error { fn from(err: intcode::Error) -> Error { Error::IntCodeError(err) } } fn main() -> Result<(), E...
code_fim
medium
{ "lang": "rust", "repo": "tristan/adventofcode2019", "path": "/day_09.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let input = [104,1125899906842624,99]; let mut comp = intcode::IntcodeComputer::new(&input); comp.run()?; assert_eq!(comp.recv()?.value(), 1125899906842624); Ok(()) } }<|fim_prefix|>// repo: tristan/adventofcode2019 path: /day_09.rs use common::intcode::{self,...
code_fim
hard
{ "lang": "rust", "repo": "tristan/adventofcode2019", "path": "/day_09.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Ok(()) } #[test] fn test_three() -> Result<(), Error> { let input = [104,1125899906842624,99]; let mut comp = intcode::IntcodeComputer::new(&input); comp.run()?; assert_eq!(comp.recv()?.value(), 1125899906842624); Ok(()) } }<|fim_prefix|>//...
code_fim
hard
{ "lang": "rust", "repo": "tristan/adventofcode2019", "path": "/day_09.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Cargill/splinter path: /libsplinter/src/oauth/store/memory.rs // Copyright 2018-2022 Cargill Incorporated // // 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": "Cargill/splinter", "path": "/libsplinter/src/oauth/store/memory.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests { use super::*; use crate::oauth::store::tests::{ test_duplicate_id_insert, test_request_store_insert_and_remove, }; #[test] fn memory_insert_request_and_remove() { let inflight_request_store = MemoryInflightOAuthRequestStore::new(); tes...
code_fim
hard
{ "lang": "rust", "repo": "Cargill/splinter", "path": "/libsplinter/src/oauth/store/memory.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if match get_at(&grid, (right_pos.0, right_pos.1 + 1)) { Some(tile) => *tile, None => break, } == Tile::Sand { flow_water(grid, can_reach, (right_pos.0, right_pos.1 + 1)); } ...
code_fim
hard
{ "lang": "rust", "repo": "commieprincess/aoc2018", "path": "/day_17/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for &pos in visited.iter().rev() { let mut possible_water = HashSet::new(); possible_water.insert(pos); if *get_at(grid, (pos.0, pos.1 + 1)).unwrap() != Tile::Sand { let mut wall_check_left = false; let mut wall_check_right = false; let mut...
code_fim
hard
{ "lang": "rust", "repo": "commieprincess/aoc2018", "path": "/day_17/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: commieprincess/aoc2018 path: /day_17/src/main.rs use std::collections::*; use regex::Regex; fn main() { let input = include_str!("input.txt").trim(); let mut can_reach: HashSet<(usize, usize)> = HashSet::new(); let (mut grid, smallest_y) = parse_input(&input); flow_water(&mu...
code_fim
hard
{ "lang": "rust", "repo": "commieprincess/aoc2018", "path": "/day_17/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let opts: Opts = Opts::parse(); match core::load_env(&opts.config) { Ok(()) => { core::exec(&mut core::env()); } Err(e) => { eprint!("{:?}", e); panic!("初始化配置失败!!!"); } } }<|fim_prefix|>// repo: JavaHello/erm-tools-rs path: /...
code_fim
medium
{ "lang": "rust", "repo": "JavaHello/erm-tools-rs", "path": "/src/bin/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: JavaHello/erm-tools-rs path: /src/bin/main.rs use erm_tools::core; use clap::Clap; #[derive(Debug, Clap)] #[clap(version = "1.0", author = "luokai")] struct Opts { #[clap(short, long, default_value = "erm-tools.json")] config: String, // #[clap(subcommand)] // subcmd: SubComman...
code_fim
medium
{ "lang": "rust", "repo": "JavaHello/erm-tools-rs", "path": "/src/bin/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Set the size of the window self.set_default_size(width, height); // If the window was maximized when it was closed, maximize it again if is_maximized { self.maximize(); } } } // ANCHOR_END: mod<|fim_prefix|>// repo: zecakeh/gtk4-rs path: /book/l...
code_fim
hard
{ "lang": "rust", "repo": "zecakeh/gtk4-rs", "path": "/book/listings/saving_window_state/1/custom_window/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn settings(&self) -> &Settings { self.imp() .settings .get() .expect("`settings` should be set in `setup_settings`.") } pub fn save_window_size(&self) -> Result<(), glib::BoolError> { // Get the size of the window let size = self.de...
code_fim
hard
{ "lang": "rust", "repo": "zecakeh/gtk4-rs", "path": "/book/listings/saving_window_state/1/custom_window/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zecakeh/gtk4-rs path: /book/listings/saving_window_state/1/custom_window/mod.rs mod imp; use gio::Settings; use glib::Object; use gtk::prelude::*; use gtk::subclass::prelude::*; use gtk::{gio, glib, Application}; use crate::APP_ID; // ANCHOR: mod glib::wrapper! { pub struct Window(ObjectS...
code_fim
hard
{ "lang": "rust", "repo": "zecakeh/gtk4-rs", "path": "/book/listings/saving_window_state/1/custom_window/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[cfg(test)] mod tests { use super::*; use super::fakeworld::tests::FakeWorld; #[test] fn no_arg_fails() { let mut fake = FakeWorld::new(b"", &[]); assert_eq!(run(fake.world()), 2); assert_eq!(fake.stdout, b""); assert_eq!(fake.stderr, b"Shell mode not im...
code_fim
hard
{ "lang": "rust", "repo": "andybalaam/pepper", "path": "/src/cmdline/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests { use super::*; use super::fakeworld::tests::FakeWorld; #[test] fn no_arg_fails() { let mut fake = FakeWorld::new(b"", &[]); assert_eq!(run(fake.world()), 2); assert_eq!(fake.stdout, b""); assert_eq!(fake.stderr, b"Shell mode not imp...
code_fim
hard
{ "lang": "rust", "repo": "andybalaam/pepper", "path": "/src/cmdline/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: andybalaam/pepper path: /src/cmdline/mod.rs pub mod fakereadfile; pub mod fakeworld; pub mod world; mod cmdlex; mod command; use self::command::Command::*; use self::world::World; use self::cmdlex::lex; use std::io; pub fn run(world: World) -> i32 { let (cmd, args) = command::identify(&w...
code_fim
hard
{ "lang": "rust", "repo": "andybalaam/pepper", "path": "/src/cmdline/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: robamu/svd2rust-workspace path: /sample-crate/src/timer0/int.rs #[doc = "Register `INT` reader"] pub struct R(crate::R<INT_SPEC>); impl core::ops::Deref for R { type Target = crate::R<INT_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Target { &self.0 } } impl From<cr...
code_fim
hard
{ "lang": "rust", "repo": "robamu/svd2rust-workspace", "path": "/sample-crate/src/timer0/int.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> &self.0 } } #[doc = "Field `MODE` writer - Interrupt Mode, selects on which condition the Timer should generate an Interrupt"] pub struct MODE_W<'a> { w: &'a mut W, } impl<'a> MODE_W<'a> { #[doc = r"Writes `variant` to the field"] #[inline(always)] pub fn variant(self, variant:...
code_fim
hard
{ "lang": "rust", "repo": "robamu/svd2rust-workspace", "path": "/sample-crate/src/timer0/int.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> variant as _ } } #[doc = "Field `MODE` reader - Interrupt Mode, selects on which condition the Timer should generate an Interrupt"] pub struct MODE_R(crate::FieldReader<u8, MODE_A>); impl MODE_R { #[inline(always)] pub(crate) fn new(bits: u8) -> Self { MODE_R(crate::FieldReader...
code_fim
hard
{ "lang": "rust", "repo": "robamu/svd2rust-workspace", "path": "/sample-crate/src/timer0/int.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ReeceStevens/heapless path: /src/__core.rs /// Temporary fork of some stuff in `core` that's doesn't have a `const fn` API pub mod mem { pub use core::mem::{replace, zeroed}; use core::ops::{Deref, DerefMut}; <|fim_suffix|> impl<T> Deref for ManuallyDrop<T> { type Target = ...
code_fim
hard
{ "lang": "rust", "repo": "ReeceStevens/heapless", "path": "/src/__core.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub const unsafe fn uninitialized<T>() -> T { #[allow(unions_with_drop_fields)] union U<T> { none: (), some: T, } U { none: () }.some } }<|fim_prefix|>// repo: ReeceStevens/heapless path: /src/__core.rs /// Temporary fork of some stuff in `...
code_fim
medium
{ "lang": "rust", "repo": "ReeceStevens/heapless", "path": "/src/__core.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.y += 1; if self.y > self.bounds.y.1 { self.y = self.bounds.y.0; self.x += 1; if self.x > self.bounds.x.1 { self.x = self.bounds.x.0; self.w += 1; if self.w > self.bounds.w.1 { return None; } } } } return Some(value); } } impl Field { fn new...
code_fim
hard
{ "lang": "rust", "repo": "Klades/Advent2020", "path": "/src/day17.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Klades/Advent2020 path: /src/day17.rs use std::collections::HashMap; // Tried to have a solution that would run both parts easily, but something about my approach didn't work out for part2 // I was trying to make the w part of the space an Option<i32> so it could be ignored and it just didn't w...
code_fim
hard
{ "lang": "rust", "repo": "Klades/Advent2020", "path": "/src/day17.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn process_field(&mut self) { let mut new_space: CubeSpace = HashMap::new(); for (x, y, z, w) in self.borders.iter() { new_space.insert((x, y, z, w), self.process_cube(x, y, z, w)); } self.cubes = new_space; self.borders.grow(); } fn count(&self) -> usize { return self.cubes.values()....
code_fim
hard
{ "lang": "rust", "repo": "Klades/Advent2020", "path": "/src/day17.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>component!( MatFormfield, FormfieldProps, |props: &FormfieldProps| { html! { <mwc-formfield label=props.label.clone() alignEnd=bool_to_option(props.align_end) spaceBetween=bool_to_option(props.space_between) no...
code_fim
hard
{ "lang": "rust", "repo": "realotz/material-yew", "path": "/material-yew/src/form_field.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// Props for [`MatFormfield`] /// /// [MWC Documentation for properties](https://github.com/material-components/material-components-web-components/tree/master/packages/formfield#propertiesattributes) #[derive(Properties, Clone)] pub struct FormfieldProps { pub children: Children, #[prop_or_defaul...
code_fim
medium
{ "lang": "rust", "repo": "realotz/material-yew", "path": "/material-yew/src/form_field.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: realotz/material-yew path: /material-yew/src/form_field.rs use crate::bool_to_option; use std::borrow::Cow; use wasm_bindgen::prelude::*; use yew::prelude::*; #[wasm_bindgen(module = "/build/mwc-formfield.js")] extern "C" { #[derive(Debug)] type Formfield; #[wasm_bindgen(getter, st...
code_fim
medium
{ "lang": "rust", "repo": "realotz/material-yew", "path": "/material-yew/src/form_field.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: threnody96/rgengine path: /src/resource/mod.rs mod file_storage; mod packed_storage; mod texture; mod font; mod se; mod resource_key; mod resource_type; pub use self::texture::*; pub use self::font::*; pub use self::se::*; pub use self::resource_key::*; pub use self::resource_type::*; pub use s...
code_fim
medium
{ "lang": "rust", "repo": "threnody96/rgengine", "path": "/src/resource/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(debug_assertions)] pub type Storage = FileStorage;<|fim_prefix|>// repo: threnody96/rgengine path: /src/resource/mod.rs mod file_storage; mod packed_storage; mod texture; mod font; mod se; mod resource_key; mod resource_type; pub use self::texture::*; pub use self::font::*; pub use self::se::*; pu...
code_fim
medium
{ "lang": "rust", "repo": "threnody96/rgengine", "path": "/src/resource/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // let y1 = y as f64 * t.cos() + x as f64 * t.sin() + b; // println!("{} {}", x1, y1); // 複素数 <https://youtu.be/mk8mGugZREg?t=1815> let s = Complex::new(x0 as f64, y0 as f64); let t = Complex::new(x2 as f64, y2 as f64); let o = (s + t) / Complex::new(2 as f64, 0 as f64); let t ...
code_fim
hard
{ "lang": "rust", "repo": "bouzuya/rust-atcoder", "path": "/cargo-atcoder/contests/abc197/src/bin/d.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bouzuya/rust-atcoder path: /cargo-atcoder/contests/abc197/src/bin/d.rs use num::Complex; use proconio::input; fn main() { input! { n: usize, x0: i64, y0: i64, x2: i64, y2: i64, }; // let a = (x2 - x0) as f64 / 2_f64 + x0 as f64; // let b =...
code_fim
hard
{ "lang": "rust", "repo": "bouzuya/rust-atcoder", "path": "/cargo-atcoder/contests/abc197/src/bin/d.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>let n = 50000000; let mut bodies = BODIES; offset_momentum(&mut bodies); println!("{:.9}", energy(&bodies)); advance(&mut bodies, 0.01, n); println!("{:.9}", energy(&bodies));} #[no_mangle] pub extern "C" fn uniform() -> sgx_status_t { for _ in 0..10 { loop_inside(); } ...
code_fim
hard
{ "lang": "rust", "repo": "mesalock-linux/rust-sgx-benchmark", "path": "/mesalock-sgx-bench/nbody/enclave/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mesalock-linux/rust-sgx-benchmark path: /mesalock-sgx-bench/nbody/enclave/src/lib.rs // Copyright (C) 2017-2018 Baidu, Inc. All Rights Reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are m...
code_fim
hard
{ "lang": "rust", "repo": "mesalock-linux/rust-sgx-benchmark", "path": "/mesalock-sgx-bench/nbody/enclave/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[get("/")] async fn ss_status() -> impl Responder { match get_ip_address() { None => HttpResponse::Ok().body( "OFF []" ), Some(ip) => HttpResponse::Ok().body( format!("ON [{}]", ip) ), } } #[actix_web::main] async fn main() -> std::io::Result<()> { let args: Vec<String> = env...
code_fim
hard
{ "lang": "rust", "repo": "italomaia/surfshark-client", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: italomaia/surfshark-client path: /src/main.rs use actix_web::{get, App, HttpResponse, HttpServer, Responder}; use lazy_static::lazy_static; use regex::Regex; use std::env; use std::process::Command; fn extract_ip_addr (txt: &str) -> Option<String> { <|fim_suffix|>#[get("/")] async fn ss_status(...
code_fim
hard
{ "lang": "rust", "repo": "italomaia/surfshark-client", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Shoord/shipcat path: /shipcat_cli/src/main.rs .setting(AppSettings::TrailingVarArg) .arg(Arg::with_name("cmd").multiple(true))) .subcommand(SubCommand::with_name("port-forward") .about("Port forwards a service to localhost") .arg(Arg::with_name("s...
code_fim
hard
{ "lang": "rust", "repo": "Shoord/shipcat", "path": "/shipcat_cli/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Shoord/shipcat path: /shipcat_cli/src/main.rs 1) .module_path(true) // may need cargo clean's if it fails.. .line_numbers(args.is_present("debug")) .output(&log::Level::Info, loggerv::Output::Stderr) .output(&log::Level::Debug, loggerv::Output::Stderr) .o...
code_fim
hard
{ "lang": "rust", "repo": "Shoord/shipcat", "path": "/shipcat_cli/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> else if let Some(a) = args.subcommand_matches("kong") { return if let Some(_b) = a.subcommand_matches("config-url") { let (_conf, region) = resolve_config(a, ConfigType::Base)?; shipcat::kong::config_url(&region) } else { let (conf, region) = resolv...
code_fim
hard
{ "lang": "rust", "repo": "Shoord/shipcat", "path": "/shipcat_cli/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_valid_client_builder() { let indexer = IndexerBuilder::new().bind("http://example.com").build_v2(); assert!(indexer.ok().is_some()); } #[test] #[should_panic(expected = "")] fn test_client_builder_with_no_url() { let _ = IndexerBuilder::new...
code_fim
medium
{ "lang": "rust", "repo": "Sheng-Long/algonaut", "path": "/src/indexer/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Sheng-Long/algonaut path: /src/indexer/mod.rs use crate::error::AlgonautError; use algonaut_client::indexer::v2::Client; pub mod v2; /// Indexer is the entry point to the creation of a client for the Algorand's indexer pub struct IndexerBuilder<'a> { url: Option<&'a str>, } <|fim_suffix|>...
code_fim
hard
{ "lang": "rust", "repo": "Sheng-Long/algonaut", "path": "/src/indexer/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/bootstrap/test.rs ; let test_args = builder.config.cmd.test_args().join(" "); cmd.arg("--test-args").arg(test_args); if builder.config.verbose_tests { try_run(builder, &mut cmd) } else { try_run_quiet(builder, &mut cmd)...
code_fim
hard
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/bootstrap/test.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/bootstrap/test.rs should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.path("src/tools/miri") } fn make_run(run: RunConfig<'_>) { run.builder.ensure(Miri { stage: run.builder.top_stage, host: run.target,...
code_fim
hard
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/bootstrap/test.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // The llvm/bin directory contains many useful cross-platform // tools. Pass the path to run-make tests so they can use them. let llvm_bin_path = llvm_config.parent() .expect("Expected llvm-config to be contained in directory"); ...
code_fim
hard
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/bootstrap/test.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let i1: u32 = 1; let i2: u32 = 65532; let i3: u32 = 4200123456; let i4: i64 = i3 as i64 * 1000; let i5: i32 = -32456; assert!(buf.write_varint(i1).is_ok()); assert!(buf.write_varint(i2).is_ok()); assert!(buf.write_varint(i3).is_ok()); ...
code_fim
hard
{ "lang": "rust", "repo": "mesalock-linux/crates-sgx", "path": "/vendor/integer-encoding/src/varint_tests.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mesalock-linux/crates-sgx path: /vendor/integer-encoding/src/varint_tests.rs #[cfg(test)] mod tests { use reader::VarIntReader; use varint::VarInt; use writer::VarIntWriter; #[test] fn test_required_space() { assert_eq!((0 as u32).required_space(), 1); assert...
code_fim
hard
{ "lang": "rust", "repo": "mesalock-linux/crates-sgx", "path": "/vendor/integer-encoding/src/varint_tests.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_decode_min_i64() { let min_vec_encoded = vec![0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01]; assert_eq!(i64::decode_var_vec(&min_vec_encoded).0, i64::min_value()); } #[test] fn test_decode_max_i64() { let max_vec_encoded = vec![0xF...
code_fim
hard
{ "lang": "rust", "repo": "mesalock-linux/crates-sgx", "path": "/vendor/integer-encoding/src/varint_tests.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kobeHub/Learning-notes path: /RustInfo/projects/rust_base/src/structs/rectangle.rs /*define the rectangle struct and define methods*/ #[derive(Debug)] pub struct Rectangle { width: u64, length: u64, } <|fim_suffix|> // associated function of the struct pub fn square(size: u64) ->...
code_fim
hard
{ "lang": "rust", "repo": "kobeHub/Learning-notes", "path": "/RustInfo/projects/rust_base/src/structs/rectangle.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn increase(&mut self, wid: u64, len: u64) { self.width += wid; self.length += len; } }<|fim_prefix|>// repo: kobeHub/Learning-notes path: /RustInfo/projects/rust_base/src/structs/rectangle.rs /*define the rectangle struct and define methods*/ #[derive(Debug)] pub struct Recta...
code_fim
hard
{ "lang": "rust", "repo": "kobeHub/Learning-notes", "path": "/RustInfo/projects/rust_base/src/structs/rectangle.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let opt: StapleCommand = StapleCommand::from_args(); let result = opt.run(); if let Err(e) = result { error!("Error: {}", e); exit(1); } Ok(()) } #[cfg(test)] mod test { use std::path::PathBuf; pub fn setup() -> PathBuf { let _ = env_logger::builder()....
code_fim
hard
{ "lang": "rust", "repo": "Kilerd/staple", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Kilerd/staple path: /src/main.rs #![warn(clippy::dbg_macro)] #[macro_use] extern crate pest_derive; #[macro_use] extern crate log; use crate::command::StapleCommand; use env_logger::Env; use std::{io::Write, process::exit}; use structopt::StructOpt; mod app; mod command; mod config; mod const...
code_fim
hard
{ "lang": "rust", "repo": "Kilerd/staple", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> builder .loader("js", loaders::javascript()) .loader("json", loaders::json()); ctx.data_mut()?.insert::<CommonJS>(builder.build()); ctx.push_global_object() .push(commonjs::build_require(ctx, "")?)? .put_prop_string(-2, "require") .pop(1); Ok(true...
code_fim
hard
{ "lang": "rust", "repo": "kildevaeld/duktape-rs", "path": "/duktape_modules/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kildevaeld/duktape-rs path: /duktape_modules/src/lib.rs #[macro_use] extern crate error_chain; extern crate duktape; #[macro_use] extern crate lazy_static; extern crate regex; mod commonjs; pub mod error; mod eval; mod file_resolver; mod internal; pub mod loaders; mod types; pub mod utils; pub...
code_fim
hard
{ "lang": "rust", "repo": "kildevaeld/duktape-rs", "path": "/duktape_modules/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> ctx.data_mut()?.insert::<CommonJS>(builder.build()); ctx.push_global_object() .push(commonjs::build_require(ctx, "")?)? .put_prop_string(-2, "require") .pop(1); Ok(true) } #[cfg(test)] mod tests { #[test] fn it_works() { assert_eq!(2 + 2, 4); } }<...
code_fim
hard
{ "lang": "rust", "repo": "kildevaeld/duktape-rs", "path": "/duktape_modules/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: boybird/codewarust path: /src/reducing_by_steps.rs fn som(x: i64, y: i64) -> i64 { x + y } fn maxi(x: i64, y: i64) -> i64 { if x > y { x } else { y } } fn mini(x: i64, y: i64) -> i64 { if x < y { x } else { y } } fn gcdi(m: i64, n: i64)...
code_fim
hard
{ "lang": "rust", "repo": "boybird/codewarust", "path": "/src/reducing_by_steps.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> testing_lcmu( &[18, 69, -90, -78, 65, 40], &vec![18, 414, 2070, 26910, 26910, 107640], ); } #[test] fn basics_maxi() { testing_maxi(&[18, 69, -90, -78, 65, 40], &vec![18, 69, 69, 69, 69, 69]); } #[test] fn basics_gcdi() { testing_gcdi(&[18, 69, -90, -78, 65, 40], &vec![18, ...
code_fim
hard
{ "lang": "rust", "repo": "boybird/codewarust", "path": "/src/reducing_by_steps.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>'{}' for file '{}'", _0, _1)] UnsupportedFileFormat(String, String), }<|fim_prefix|>// repo: ghtyrant/sinfonia-server path: /src/audio_engine/loader/error.rs use failure::Fail; #[derive(Fail, Debug)] pub enum AudioFileLoaderErro<|fim_middle|>r { #[fail(display = "Failed to load file '{}': {}", _0, _...
code_fim
medium
{ "lang": "rust", "repo": "ghtyrant/sinfonia-server", "path": "/src/audio_engine/loader/error.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ghtyrant/sinfonia-server path: /src/audio_engine/loader/error.rs use failure::Fail; #[derive(Fail, Debug)] pub enum AudioFileLoaderErro<|fim_suffix|>oadError(String, String), #[fail(display = "Unsupported file format '{}' for file '{}'", _0, _1)] UnsupportedFileFormat(String, String), }<|f...
code_fim
medium
{ "lang": "rust", "repo": "ghtyrant/sinfonia-server", "path": "/src/audio_engine/loader/error.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let w_caption = U16CString::from_str("Note").unwrap(); let w_msg = U16CString::from_str("Goodbye, cruel world!").unwrap(); unsafe { MessageBoxW(null_mut(), w_msg.as_ptr(), w_caption.as_ptr(), MB_OK) }; }<|fim_prefix|>// repo: evgeni-nabokov/winapi-samples path: /src/bin/goodbye.rs...
code_fim
easy
{ "lang": "rust", "repo": "evgeni-nabokov/winapi-samples", "path": "/src/bin/goodbye.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: evgeni-nabokov/winapi-samples path: /src/bin/goodbye.rs #![windows_subsystem = "windows"] use std::ptr::null_mut; use winapi::um::winuser::{MB_OK, MessageBoxW}; use widestring::U16CString; <|fim_suffix|> let w_caption = U16CString::from_str("Note").unwrap(); let w_msg = U16CString::from...
code_fim
easy
{ "lang": "rust", "repo": "evgeni-nabokov/winapi-samples", "path": "/src/bin/goodbye.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> "Hello, world!" } #[get("/guest")] fn guest(_policy: Policy<User>) -> &'static str { "Guest area" }<|fim_prefix|>// repo: apognu/rocket_oso path: /examples/simple.rs #[macro_use] extern crate rocket; #[macro_use] extern crate oso; use std::error::Error; use oso::Oso; use rocket::request::Request; ...
code_fim
hard
{ "lang": "rust", "repo": "apognu/rocket_oso", "path": "/examples/simple.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: apognu/rocket_oso path: /examples/simple.rs #[macro_use] extern crate rocket; #[macro_use] extern crate oso; use std::error::Error; use oso::Oso; use rocket::request::Request; <|fim_suffix|>#[async_trait] impl Resolver for CustomActorResolver { type Actor = User; async fn resolve_actor(&...
code_fim
medium
{ "lang": "rust", "repo": "apognu/rocket_oso", "path": "/examples/simple.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> imgbuf.put_pixel(x, y, rgba); }, // The division was invalid None => {} } } } texture.update(&mut window.encoder, &imgbuf)....
code_fim
hard
{ "lang": "rust", "repo": "KamiAithein/Rust_Graphics", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: KamiAithein/Rust_Graphics path: /src/main.rs extern crate image as im; use im::{DynamicImage, RgbImage, Rgba, Pixel, GenericImage, ImageBuffer}; extern crate piston_window; use piston_window::*; use piston_window::types::Color as p_color; use std::path::Path; mod scene; use crate::scene::*;...
code_fim
hard
{ "lang": "rust", "repo": "KamiAithein/Rust_Graphics", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cambricorp/webdav-handler-rs path: /examples/actix-web.rs use actix_web::{server, App, AsyncResponder, Error, HttpMessage, HttpRequest, HttpResponse}; use failure::Fail; use futures01::{future, Future, Stream}; use http; use webdav_handler::{fakels::FakeLs, localfs::LocalFs, DavHandler}; use th...
code_fim
hard
{ "lang": "rust", "repo": "cambricorp/webdav-handler-rs", "path": "/examples/actix-web.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // G_SENDER holds a global tokio_threadpool handle. lazy_static! { static ref G_SENDER: Mutex<Option<tokio_threadpool::Sender>> = Mutex::new(None); } // T_SENDER holds a thread-local tokio_threadpool handle, // cloned from the global one. thread_local! { static T_S...
code_fim
hard
{ "lang": "rust", "repo": "cambricorp/webdav-handler-rs", "path": "/examples/actix-web.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: iliayar/esp8266-hello path: /esp8266-sys/src/bindings.rs he type of memory"] #[doc = ""] #[doc = " @return Amount of free bytes in the regions"] pub fn heap_caps_get_minimum_free_size(caps: u32) -> size_t; } extern "C" { #[doc = " @brief Initialize regions of memory to the collec...
code_fim
hard
{ "lang": "rust", "repo": "iliayar/esp8266-hello", "path": "/esp8266-sys/src/bindings.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: iliayar/esp8266-hello path: /esp8266-sys/src/bindings.rs ::raw::c_char, __format: *const ::std::os::raw::c_char, __arg: __builtin_va_list, ) -> ::std::os::raw::c_int; } extern "C" { pub fn snprintf( __s: *mut ::std::os::raw::c_char, __maxlen: ::std::os::ra...
code_fim
hard
{ "lang": "rust", "repo": "iliayar/esp8266-hello", "path": "/esp8266-sys/src/bindings.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>e to the task for which the priority is being set."] #[doc = " Passing a NULL handle results in the priority of the calling task being set."] #[doc = ""] #[doc = " @param uxNewPriority The priority to which the task will be set."] #[doc = ""] #[doc = " Example usage:"] #[doc = "<pr...
code_fim
hard
{ "lang": "rust", "repo": "iliayar/esp8266-hello", "path": "/esp8266-sys/src/bindings.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lightningdevkit/rust-lightning path: /lightning/src/routing/router.rs t (our_privkey, our_id, privkeys, nodes) = get_nodes(&secp_ctx); let scorer = ln_test_utils::TestScorer::new(); let keys_manager = ln_test_utils::TestKeysInterface::new(&[0u8; 32], Network::Testnet); let random_seed_byte...
code_fim
hard
{ "lang": "rust", "repo": "lightningdevkit/rust-lightning", "path": "/lightning/src/routing/router.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Route to 1 via 2 and 3 because our channel to 1 is disabled let payment_params = PaymentParameters::from_node_id(nodes[0], 42); let route = get_route(&our_id, &payment_params, &network_graph.read_only(), None, 100, Arc::clone(&logger), &scorer, &(), &random_seed_bytes).unwrap(); assert_eq!(rout...
code_fim
hard
{ "lang": "rust", "repo": "lightningdevkit/rust-lightning", "path": "/lightning/src/routing/router.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lightningdevkit/rust-lightning path: /lightning/src/routing/router.rs , 290_000, Arc::clone(&logger), &scorer, &(), &random_seed_bytes).unwrap(); assert_eq!(route.paths.len(), 3); let mut total_amount_paid_msat = 0; for path in &route.paths { if payment_params.payee.blinded_rout...
code_fim
hard
{ "lang": "rust", "repo": "lightningdevkit/rust-lightning", "path": "/lightning/src/routing/router.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub fn some_observed_translation( language: Language, observed: u128, ) -> Text<'static, Renderer<StyleType>> { Text::new(match language { Language::EN => format!("Total intercepted packets: {observed}\n\n\ Filtered packets: 0\n\n\ ...
code_fim
hard
{ "lang": "rust", "repo": "GyulyVGC/sniffnet", "path": "/src/translations/translations.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn specify_multiples_translation(language: Language) -> &'static str { match language { Language::EN => "; you can also specify 'K', 'M' and 'G'", Language::IT => "; puoi anche specificare 'K', 'M' e 'G'", Language::FR => "; vous pouvez également spécifier 'K', 'M' et 'G'",...
code_fim
hard
{ "lang": "rust", "repo": "GyulyVGC/sniffnet", "path": "/src/translations/translations.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: GyulyVGC/sniffnet path: /src/translations/translations.rs Language::FI => "Verkkosovitin", Language::JA => "ネットワーク アダプター", } } pub fn no_addresses_translation( language: Language, adapter: &str, ) -> Text<'static, Renderer<StyleType>> { Text::new(match language { ...
code_fim
hard
{ "lang": "rust", "repo": "GyulyVGC/sniffnet", "path": "/src/translations/translations.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let result = epoll_ctl(efd, EpollOp::EpollCtlAdd, 1, None); result.expect_err("assertion failed"); assert_eq!(result.unwrap_err(), Errno::EINVAL); } #[test] pub fn test_epoll_ctl() { let efd = epoll_create1(EpollCreateFlags::empty()).unwrap(); let mut event = EpollEvent::new(E...
code_fim
hard
{ "lang": "rust", "repo": "nix-rust/nix", "path": "/test/sys/test_epoll.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[test] pub fn test_epoll_ctl() { let efd = epoll_create1(EpollCreateFlags::empty()).unwrap(); let mut event = EpollEvent::new(EpollFlags::EPOLLIN | EpollFlags::EPOLLERR, 1); epoll_ctl(efd, EpollOp::EpollCtlAdd, 1, &mut event).unwrap(); epoll_ctl(efd, EpollOp::EpollCtlDel, 1, None)...
code_fim
hard
{ "lang": "rust", "repo": "nix-rust/nix", "path": "/test/sys/test_epoll.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nix-rust/nix path: /test/sys/test_epoll.rs #![allow(deprecated)] use nix::errno::Errno; use nix::sys::epoll::{epoll_create1, epoll_ctl}; use nix::sys::epoll::{EpollCreateFlags, EpollEvent, EpollFlags, EpollOp}; <|fim_suffix|> let result = epoll_ctl(efd, EpollOp::EpollCtlAdd, 1, None); r...
code_fim
hard
{ "lang": "rust", "repo": "nix-rust/nix", "path": "/test/sys/test_epoll.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: abhijat/django-tools path: /src/bin/declarations.rs use structopt::StructOpt; use project_checker::{collect_source_files, get_declarations, to_refs, Opts}; <|fim_suffix|> let opts: Opts = Opts::from_args(); let sources = collect_source_files(&to_refs(&opts.source_roots), ".py"); let...
code_fim
easy
{ "lang": "rust", "repo": "abhijat/django-tools", "path": "/src/bin/declarations.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let opts: Opts = Opts::from_args(); let sources = collect_source_files(&to_refs(&opts.source_roots), ".py"); let declarations = get_declarations(&sources); eprintln!("declarations = {:?}", declarations); }<|fim_prefix|>// repo: abhijat/django-tools path: /src/bin/declarations.rs use struc...
code_fim
easy
{ "lang": "rust", "repo": "abhijat/django-tools", "path": "/src/bin/declarations.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/miri path: /tests/fail/panic/panic_abort1.rs //@error-in-other-file: the program aborted execution //@normalize-stderr-test: "\| +\^+" -> "| ^" //@normalize-stderr-test: "libc::abort\(\);|core::intrinsics::abort\(\);" -> "ABORT();" //@compile-flags: -C panic=abort <|fim_suffix|> st...
code_fim
easy
{ "lang": "rust", "repo": "rust-lang/miri", "path": "/tests/fail/panic/panic_abort1.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> std::panic!("panicking from libstd"); }<|fim_prefix|>// repo: rust-lang/miri path: /tests/fail/panic/panic_abort1.rs //@error-in-other-file: the program aborted execution //@normalize-stderr-test: "\| +\^+" -> "| ^" //@normalize-stderr-test: "libc::abort\(\);|core::intrinsics::abort\(\);" -> "ABORT()...
code_fim
easy
{ "lang": "rust", "repo": "rust-lang/miri", "path": "/tests/fail/panic/panic_abort1.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ruma/homeserver path: /src/db.rs //! Database-related functionality. use diesel::pg::PgConnection; use diesel::r2d2::{Builder, ConnectionManager, Pool, PoolError as R2d2Error, PooledConnection}; use iron::typemap::Key; use iron::{Plugin, Request}; use persistent::Write; use crate::error::ApiEr...
code_fim
hard
{ "lang": "rust", "repo": "ruma/homeserver", "path": "/src/db.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> r2d2_pool_builder.build(connection_manager) } /// Extract a database conection from the pool stored in the request. pub fn from_request( request: &mut Request<'_, '_>, ) -> Result<PooledConnection<ConnectionManager<PgConnection>>, ApiError> { let mutex = request.ge...
code_fim
hard
{ "lang": "rust", "repo": "ruma/homeserver", "path": "/src/db.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }