text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: shibh308/procon2020-comp path: /src/api/request.rs use super::parse; use crate::api::parse::{FieldData, MatchData, TeamData}; use crate::simulator::Act; use reqwest; pub fn get_match_data(cfg: &parse::Config) -> Result<Vec<MatchData>, String> { let url = cfg.url.clone() + &*format!("/teams/...
code_fim
hard
{ "lang": "rust", "repo": "shibh308/procon2020-comp", "path": "/src/api/request.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut emitters_enabled = DataMember::<bool>::new(process_handle); emitters_enabled.set_offset(vec![0x1_42_3e_44_78, 0xac]); spawn_timer.write(&1.0)?; level_warmup.write(&1.0)?; emitters_enabled.write(&false)?; println!("Spawn timer: {}", spawn_timer.read()?); println!("Leve...
code_fim
hard
{ "lang": "rust", "repo": "534119219/rs-process-memory", "path": "/examples/fastyboy.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 534119219/rs-process-memory path: /examples/fastyboy.rs //! An example program that writes a few variables in the game Mirror's Edge Catalyst. This example //! is only supported on Windows as Mirror's Edge Catalyst only runs on Windows. //! //! The program sets the spawn timer to 1 second (down ...
code_fim
hard
{ "lang": "rust", "repo": "534119219/rs-process-memory", "path": "/examples/fastyboy.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut spawn_timer = DataMember::<f32>::new(process_handle); spawn_timer.set_offset(vec![0x1_42_14_2a_d8, 0xac]); let mut level_warmup = DataMember::<f32>::new(process_handle); level_warmup.set_offset(vec![0x1_42_14_2a_d8, 0x9c]); let mut emitters_enabled = DataMember::<bool>::new(p...
code_fim
hard
{ "lang": "rust", "repo": "534119219/rs-process-memory", "path": "/examples/fastyboy.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bytebeamio/rumqtt path: /benchmarks/clients/pahoasync.rs extern crate paho_mqtt as mqtt; use std::time::Instant; use std::error::Error; use mqtt::AsyncClient; use futures::executor::block_on; #[tokio::main(core_threads=2)] async fn main() { let _o = start("paho-rust-async", 100, 100000); }...
code_fim
hard
{ "lang": "rust", "repo": "bytebeamio/rumqtt", "path": "/benchmarks/clients/pahoasync.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let client = mqtt::AsyncClient::new(create_opts)?; let payloads = generate_payloads(count, payload_size); let start = Instant::now(); requests(payloads, client); let elapsed_ms = start.elapsed().as_millis(); let throughput = count as usize / elapsed_ms as usize; let acks_thro...
code_fim
hard
{ "lang": "rust", "repo": "bytebeamio/rumqtt", "path": "/benchmarks/clients/pahoasync.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn new(team: &str, date: &str) -> Game { // call get game data and return the game w/ the data // fake response... Game { home_team: "Dodgers".to_string(), away_team: "Giants".to_string(), home_score: 22, away_score: 0, ...
code_fim
hard
{ "lang": "rust", "repo": "joelpalmer/mlb-unofficial", "path": "/src/game.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: joelpalmer/mlb-unofficial path: /src/game.rs mod mlbapi; pub enum GameState { NoGame, Delayed, Postponed, OnLater, InProgress, Final, } pub struct Game { pub home_team: String, pub away_team: String, pub home_score: i16, pub away_score: i16, } impl Game ...
code_fim
medium
{ "lang": "rust", "repo": "joelpalmer/mlb-unofficial", "path": "/src/game.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>ble::categories .filter(table::category_name.like(name)) .select(table::category_id) .load(conn) } }<|fim_prefix|>// repo: seb-odessa/zkb path: /src/lib/models/category.rs use crate::schema::categories; use super::{Integer, Connection, QueryResult}; #[derive(Query...
code_fim
hard
{ "lang": "rust", "repo": "seb-odessa/zkb", "path": "/src/lib/models/category.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: seb-odessa/zkb path: /src/lib/models/category.rs use crate::schema::categories; use super::{Integer, Connection, QueryResult}; #[derive(Queryable, Insertable)] #[table_name = "categories"<|fim_suffix|>me: &String) -> QueryResult<Vec<Integer>> { use diesel::prelude::*; use crate:...
code_fim
medium
{ "lang": "rust", "repo": "seb-odessa/zkb", "path": "/src/lib/models/category.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>me: &String) -> QueryResult<Vec<Integer>> { use diesel::prelude::*; use crate::schema::categories::dsl as table; table::categories .filter(table::category_name.like(name)) .select(table::category_id) .load(conn) } }<|fim_prefix|>// repo: seb-...
code_fim
medium
{ "lang": "rust", "repo": "seb-odessa/zkb", "path": "/src/lib/models/category.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mvanotti/fuchsia-mirror path: /src/connectivity/lowpan/drivers/lowpan-spinel-driver/tests/test-components/mock-device/lowpan_driver_provision_mock.rs // Copyright 2020 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in ...
code_fim
hard
{ "lang": "rust", "repo": "mvanotti/fuchsia-mirror", "path": "/src/connectivity/lowpan/drivers/lowpan-spinel-driver/tests/test-components/mock-device/lowpan_driver_provision_mock.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|>#[fuchsia_async::run_singlethreaded(test)] #[ignore = "TODO(https://fxbug.dev/77055): deflake and enable"] async fn lowpan_driver_provision_mock() { syslog::init_with_tags(&["lowpan_driver_provision_mock"]).expect("Can't init logger"); fx_log_info!("test start"); let driver = lowpan_driver_in...
code_fim
hard
{ "lang": "rust", "repo": "mvanotti/fuchsia-mirror", "path": "/src/connectivity/lowpan/drivers/lowpan-spinel-driver/tests/test-components/mock-device/lowpan_driver_provision_mock.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: brentongunning/rust-sv path: /src/transaction/sighash.rs //! Transaction sighash helpers use crate::messages::{OutPoint, Payload, Tx, TxOut}; use crate::script::{next_op, op_codes, Script}; use crate::util::{sha256d, var_int, Error, Hash256, Result, Serializable}; use byteorder::{LittleEndian, ...
code_fim
hard
{ "lang": "rust", "repo": "brentongunning/rust-sv", "path": "/src/transaction/sighash.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // 6. Serialize satoshis s.write_i64::<LittleEndian>(satoshis)?; // 7. Serialize sequence s.write_u32::<LittleEndian>(tx.inputs[n_input].sequence)?; // 8. Serialize hash of outputs if base_type != SIGHASH_SINGLE && base_type != SIGHASH_NONE { if cache.hash_outputs.is_none...
code_fim
hard
{ "lang": "rust", "repo": "brentongunning/rust-sv", "path": "/src/transaction/sighash.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Serialize the inputs let n_inputs = if anyone_can_pay { 1 } else { tx.inputs.len() }; var_int::write(n_inputs as u64, &mut s)?; for i in 0..tx.inputs.len() { let i = if anyone_can_pay { n_input } else { i }; let mut tx_in = tx.inputs[i].clone(); if i == n_input {...
code_fim
hard
{ "lang": "rust", "repo": "brentongunning/rust-sv", "path": "/src/transaction/sighash.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Print out our settings (as a HashMap) return settings.try_into::<Config>().unwrap(); }<|fim_prefix|>// repo: sparkymat/murd path: /src/config.rs use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Debug)] pub struct Config { pub listen_host: String, pub listen_port: ...
code_fim
hard
{ "lang": "rust", "repo": "sparkymat/murd", "path": "/src/config.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sparkymat/murd path: /src/config.rs use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Debug)] pub struct Config { pub listen_host: String, pub listen_port: u32, } <|fim_suffix|> // Print out our settings (as a HashMap) return settings.try_into::<Config>().unw...
code_fim
hard
{ "lang": "rust", "repo": "sparkymat/murd", "path": "/src/config.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if self.state == state { Err(ParseError::invalid_token(token)) } else { Ok(()) } } } #[derive(Debug, PartialEq, Copy, Clone)] pub enum CoordinateState { Start, ReadingFirstCooordinate, ReadingNextCoordinate, FinishedCoordinate, Finis...
code_fim
hard
{ "lang": "rust", "repo": "jagill/rust-wkt", "path": "/src/coordinate_reader.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jagill/rust-wkt path: /src/coordinate_reader.rs use crate::char_class::CharClass; use crate::parse_error::{ParseError, ParseResult}; use crate::tokenizer::{Token, Tokenizer}; struct CoordinateReader<'t> { coordinates: Vec<f64>, tokenizer: &'t mut Tokenizer<'t>, state: CoordinateStat...
code_fim
hard
{ "lang": "rust", "repo": "jagill/rust-wkt", "path": "/src/coordinate_reader.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // println!("{:?} : {:?}", reader.state(), reader.coordinates()); while reader.state() != CoordinateState::Finished { reader.read()?; // println!("{:?} : {:?}", reader.state(), reader.coordinates()); } Ok(()) } #[test] fn test_empty() { ...
code_fim
hard
{ "lang": "rust", "repo": "jagill/rust-wkt", "path": "/src/coordinate_reader.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bantic/project-euler path: /problem15/problem15.rs fn next_triangle_vec(vec: Vec<uint>) -> Vec<uint> { let mut next_vec = vec![1]; <|fim_suffix|> let mut vec = vec![1,1]; let mut cur_num = 1; while cur_num < num { cur_num = cur_num + 1; vec = next_triangle_vec(vec...
code_fim
medium
{ "lang": "rust", "repo": "bantic/project-euler", "path": "/problem15/problem15.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut vec = vec![1,1]; let mut cur_num = 1; while cur_num < num { cur_num = cur_num + 1; vec = next_triangle_vec(vec); } vec } fn main() { let mut max = 0; let tri = triangle_vec(20*2); println!("TRI {}",tri); for &i in tri.iter() { if i > max...
code_fim
medium
{ "lang": "rust", "repo": "bantic/project-euler", "path": "/problem15/problem15.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Self::Generic(val) } } impl From<makepad_zune_inflate::errors::InflateDecodeErrors> for PngDecodeErrors { fn from(val: makepad_zune_inflate::errors::InflateDecodeErrors) -> Self { Self::ZlibDecodeErrors(val) } }<|fim_prefix|>// repo: makepad/makepad path: /libs/zune-png/src/e...
code_fim
hard
{ "lang": "rust", "repo": "makepad/makepad", "path": "/libs/zune-png/src/error.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: makepad/makepad path: /libs/zune-png/src/error.rs /* * Copyright (c) 2023. * * This software is free software; * * You can redistribute it or modify it under terms of the MIT, Apache License or Zlib license */ //! Errors possible during png operations use alloc::string::String; use core::...
code_fim
hard
{ "lang": "rust", "repo": "makepad/makepad", "path": "/libs/zune-png/src/error.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl From<String> for PngDecodeErrors { fn from(val: String) -> Self { Self::Generic(val) } } impl From<makepad_zune_inflate::errors::InflateDecodeErrors> for PngDecodeErrors { fn from(val: makepad_zune_inflate::errors::InflateDecodeErrors) -> Self { Self::ZlibDecodeErrors(val...
code_fim
medium
{ "lang": "rust", "repo": "makepad/makepad", "path": "/libs/zune-png/src/error.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: CNife/leetcode path: /rust/finished/src/binary_search.rs use std::cmp::Ordering::*; pub fn search(nums: Vec<i32>, target: i32) -> i32 { let mut low = 0; let mut high = nums.len(); while low < high { let middle = low + (high - low) / 2; match nums[middle].cmp(&target)...
code_fim
medium
{ "lang": "rust", "repo": "CNife/leetcode", "path": "/rust/finished/src/binary_search.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let cases = vec![ (vec![-1, 0, 3, 5, 9, 12], 9, 4), (vec![-1, 0, 3, 5, 9, 12], 2, -1), (vec![5], -5, -1), (vec![], 0, -1), ]; for (nums, target, expect) in cases { assert_eq!(search(nums, target), expect); } }<|fim_prefix|>// repo: CNife/leetcode pa...
code_fim
medium
{ "lang": "rust", "repo": "CNife/leetcode", "path": "/rust/finished/src/binary_search.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>xpect(1) .create(); let moved_mocker = mocker; let client = reqwest::Client::new(); println!( "{:?}", client.get(&format!("{}/bar?stuff", mockito::server_url())).send() ); moved_mocker.assert(); }<|fim_prefix|>// repo: thomasetter/mockito_query_bug_repro path: /tes...
code_fim
medium
{ "lang": "rust", "repo": "thomasetter/mockito_query_bug_repro", "path": "/tests/repro.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: thomasetter/mockito_query_bug_repro path: /tests/repro.rs use mockito::Matcher; #[test] fn query_in_exact_test() { env_logger::init(); let mocker = mockito::mock( <|fim_suffix|>"{:?}", client.get(&format!("{}/bar?stuff", mockito::server_url())).send() ); moved_mocker...
code_fim
hard
{ "lang": "rust", "repo": "thomasetter/mockito_query_bug_repro", "path": "/tests/repro.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> (71_923_000 as Weight) .saturating_add((529_000 as Weight).saturating_mul(r as Weight)) .saturating_add((1_763_000 as Weight).saturating_mul(x as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } fn apply_certificatio...
code_fim
hard
{ "lang": "rust", "repo": "FelixMeyr/dico-chain", "path": "/pallets/kyc/src/weights.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> (11_375_000 as Weight) .saturating_add((382_000 as Weight).saturating_mul(r as Weight)) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } fn ias_provide_judgement(r: u32, x: u32) -> Weight { (71_923_000 as Weight) .satu...
code_fim
hard
{ "lang": "rust", "repo": "FelixMeyr/dico-chain", "path": "/pallets/kyc/src/weights.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: FelixMeyr/dico-chain path: /pallets/kyc/src/weights.rs #![allow(unused_parens)] #![allow(unused_imports)] use frame_support::{ traits::Get, weights::{constants::RocksDbWeight, Weight}, }; use sp_std::marker::PhantomData; /// Weight functions needed for pallet_kyc. pub trait WeightInfo { ///...
code_fim
hard
{ "lang": "rust", "repo": "FelixMeyr/dico-chain", "path": "/pallets/kyc/src/weights.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Deserialize)] struct ScaleOrderParams { scale_init_level_size: Option<i32>, scale_subs_level_size: Option<i32>, _scale_price_increment: EmptyString, // TODO Option<f64>, /* TODO: requires manual deserialize implementation if scalePriceIncrement > 0.0 && scalePriceIncrement !=...
code_fim
hard
{ "lang": "rust", "repo": "yangbin/ibapi", "path": "/src/protocol/order.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yangbin/ibapi path: /src/protocol/order.rs String, short_sale_params: ShortSaleParams, auction_strategy: Option<i32>, box_order_params: BoxOrderParams, peg_to_stk_or_vol_order_params: PegToStkOrVolOrderParams, display_size: Option<i32>, block_order: bool, sweep_to_fil...
code_fim
hard
{ "lang": "rust", "repo": "yangbin/ibapi", "path": "/src/protocol/order.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /* TODO: requires manual deserialize implementation if scalePriceIncrement > 0.0 && scalePriceIncrement != Double.MAX_VALUE { scalePriceAdjustValue: Option<f64>, scalePriceAdjustInterval: Option<i32>, scaleProfitOffset: Option<f64>, scaleAutoReset: bool, sca...
code_fim
hard
{ "lang": "rust", "repo": "yangbin/ibapi", "path": "/src/protocol/order.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.is_game || depth==0{ return (self.eval(),self.clone()); } let mut children=vec![]; let moves=self.get_possible_moves(); for m in moves{ let mut cloned=self.clone(); cloned.move_game(m); cloned.check_win(m); c...
code_fim
hard
{ "lang": "rust", "repo": "swd543/rusty-andantino", "path": "/src/minimax.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: swd543/rusty-andantino path: /src/minimax.rs use crate::hex::Hex; use std::thread; use crate::havannah::Havannah; use std::borrow::Borrow; impl Hex{ pub fn minimax(&self, depth:i8, maximising:bool)->(i32,Hex){ if self.is_game || depth==0{ return (self.eval(),self.clone()...
code_fim
hard
{ "lang": "rust", "repo": "swd543/rusty-andantino", "path": "/src/minimax.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> VariantValue::String(string) }, EvtVarTypeAnsiString => { let slice : &[u8]; unsafe { let ptr = variant.u.AnsiStringVal(); let len = (0..).take_while(|&i| *ptr.offset(i) != 0).count(); ...
code_fim
hard
{ "lang": "rust", "repo": "N4rr34n6/RsWindowsThingies", "path": "/src/winevt/variant.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: N4rr34n6/RsWindowsThingies path: /src/winevt/variant.rs use hex; use std::fmt; use serde::Serialize; use serde_json::Value; use std::ffi::OsString; use serde_json::Number; use std::os::windows::prelude::*; use winapi::shared::guiddef::GUID; use winapi::um::winevt::*; use crate::errors::WinThingE...
code_fim
hard
{ "lang": "rust", "repo": "N4rr34n6/RsWindowsThingies", "path": "/src/winevt/variant.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: prateekkumarweb/sat-verifier path: /src/dimacs.rs use regex::Regex; use std::io::BufRead; #[derive(Debug)] pub struct Dimacs { pub n_vars: usize, pub clauses: Vec<Vec<i64>>, } <|fim_suffix|> cl.push(l); } clauses.push(cl); if clauses.l...
code_fim
hard
{ "lang": "rust", "repo": "prateekkumarweb/sat-verifier", "path": "/src/dimacs.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> cl.push(l); } clauses.push(cl); if clauses.len() == n_clauses { break; } } } Dimacs { n_vars, clauses } }<|fim_prefix|>// repo: prateekkumarweb/sat-verifier path: /src/dimacs.rs use regex::Regex; use std::io:...
code_fim
hard
{ "lang": "rust", "repo": "prateekkumarweb/sat-verifier", "path": "/src/dimacs.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for line in reader.lines() { let line = line.unwrap(); let line = line.trim(); if line.is_empty() { continue; } if line.starts_with('c') { continue; } else if line.starts_with('p') { let re_cnf = Regex::new(r"p\s+cnf\s...
code_fim
hard
{ "lang": "rust", "repo": "prateekkumarweb/sat-verifier", "path": "/src/dimacs.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>d miner; /// Search manager module pub mod search_manager;<|fim_prefix|>// repo: adriangrpz/music-player-rs path: /src/music_manager/mod.rs //! Library to create a music player and/or a songs miner /// Database module pub mod music_database; /// Query man<|fim_middle|>ager module pub mod query_manager; ...
code_fim
easy
{ "lang": "rust", "repo": "adriangrpz/music-player-rs", "path": "/src/music_manager/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: adriangrpz/music-player-rs path: /src/music_manager/mod.rs //! Library to create a music player and/or a songs miner <|fim_suffix|>d miner; /// Search manager module pub mod search_manager;<|fim_middle|> /// Database module pub mod music_database; /// Query manager module pub mod query_manager; ...
code_fim
medium
{ "lang": "rust", "repo": "adriangrpz/music-player-rs", "path": "/src/music_manager/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[error("other error: {0}")] Other(String), }<|fim_prefix|>// repo: UniqueVision/db-migration-tool path: /src/error.rs use thiserror::Error; #[derive(Debug, Error)] pub enum SystemError { #[error(transparent)] PgError(#[from] tokio_postgres::error::Error), <|fim_middle|> #[error(tran...
code_fim
medium
{ "lang": "rust", "repo": "UniqueVision/db-migration-tool", "path": "/src/error.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: UniqueVision/db-migration-tool path: /src/error.rs use thiserror::Error; #[derive(Debug, Error)] pub enum SystemError { #[error(transparent)] PgError(#[from] tokio_postgres::error::Error), <|fim_suffix|> #[error("other error: {0}")] Other(String), }<|fim_middle|> #[error(tran...
code_fim
medium
{ "lang": "rust", "repo": "UniqueVision/db-migration-tool", "path": "/src/error.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: emilk/pga path: /generator/src/gen.rs use {itertools::Itertools, strum::IntoEnumIterator}; use crate::{documentation::*, *}; const CODE_SEPARATOR: &str = "// ---------------------------------------------------------------------"; pub struct Settings { pub float_type: String, } impl Default ...
code_fim
hard
{ "lang": "rust", "repo": "emilk/pga", "path": "/generator/src/gen.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // TODO: we can only implement Add, Sub if the struct has no Type::Constant let derives = "Copy, Clone, Debug, Default, PartialEq, PartialOrd, derive_more::Neg, derive_more::Add, derive_more::Sub\n"; let members = strct .iter() .map(|(member_name, member_type)| format!(" pub {}:...
code_fim
hard
{ "lang": "rust", "repo": "emilk/pga", "path": "/generator/src/gen.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fess932/todo-service path: /src/buisness.rs // interfaces #[async_trait] pub trait Store: Send + Sync { async fn store(&self, name: String); async fn get_users(&self) -> Vec<User>; } pub trait Delivery { fn create(&self); <|fim_suffix|>pub enum TaskStatus { Progress, Done, }...
code_fim
medium
{ "lang": "rust", "repo": "fess932/todo-service", "path": "/src/buisness.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub enum TaskStatus { Progress, Done, } // end models // pub struct Usecase { store: Box<dyn Store>, } impl Usecase { pub async fn create(&self, name: String) { println!("usecase impl name: {}", name); self.store.store(name).await; } pub async fn get_users(&self...
code_fim
medium
{ "lang": "rust", "repo": "fess932/todo-service", "path": "/src/buisness.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match self.first_fit(layout) { Some((idx, addr)) => { self.bitfield().set_bit(idx); addr as *mut u8 } None => ptr::null_mut(), } } /// Checks if we can still allocate more objects of a given layout within the page...
code_fim
hard
{ "lang": "rust", "repo": "theseus-os/Theseus", "path": "/kernel/slabmalloc/src/pages.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Checks if the page has currently no allocations. fn is_empty(&self, relevant_bits: usize) -> bool { self.bitfield().all_free(relevant_bits) } /// Deallocates a memory object within this page. fn deallocate(&self, ptr: NonNull<u8>, layout: Layout) -> Result<(), &'static str...
code_fim
hard
{ "lang": "rust", "repo": "theseus-os/Theseus", "path": "/kernel/slabmalloc/src/pages.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: theseus-os/Theseus path: /kernel/slabmalloc/src/pages.rs page_size - metadata_size - layout.size()); if !offset_inside_data_area { return None; } let addr: usize = base_addr + offset; let alignment_ok = addr % l...
code_fim
hard
{ "lang": "rust", "repo": "theseus-os/Theseus", "path": "/kernel/slabmalloc/src/pages.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Vertical center let container = gtk::Box::new(gtk::Orientation::Vertical, 0); container.pack_start(&entry, true, false, 0); scrolled_window.add(&container); window.add(&scrolled_window); let app = Arc::new(Mutex::new(App { app_indicator: ai, ...
code_fim
hard
{ "lang": "rust", "repo": "whizsid/typeonscreen", "path": "/src/app.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Toggle Item let toggle_item = gtk::MenuItem::new_with_label("Activate Typing (Ctrl + F6)"); m.append(&toggle_item); // About Me let about_item = gtk::MenuItem::new_with_label("About"); about_item.connect_activate(move |_|{ let about_dialog = ...
code_fim
hard
{ "lang": "rust", "repo": "whizsid/typeonscreen", "path": "/src/app.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: whizsid/typeonscreen path: /src/app.rs use gtk::prelude::*; use libappindicator::{AppIndicator, AppIndicatorStatus}; use std::sync::Arc; use std::sync::Mutex; use super::config::Config; pub struct App { app_indicator: AppIndicator, pub toggle_item: gtk::MenuItem, pub exit_item: gt...
code_fim
hard
{ "lang": "rust", "repo": "whizsid/typeonscreen", "path": "/src/app.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: digitsu/bitcrust path: /tests/compare_core.rs /// Tool to compare the block processing time of core with bitcrust /// /// Will run in two phases /// - Sync bitcrust from blk files to add_block with initial_sync=true until no more blocks are in /// - Then poll the blk files every 5 sec to see ...
code_fim
hard
{ "lang": "rust", "repo": "digitsu/bitcrust", "path": "/tests/compare_core.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> println!("No more initial sync; polling files"); loop { match read_next(pos) { None => { std::thread::sleep(std::time::Duration::new(5,0)); continue; }, Some((p, blk)) => { pos = p; bitcrus...
code_fim
hard
{ "lang": "rust", "repo": "digitsu/bitcrust", "path": "/tests/compare_core.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Set the domain corresponding to the "domain" directive. pub fn set_domain(&mut self, domain: String) { self.domain = Some(domain); self.last_search = LastSearch::Domain; } /// Set the domains corresponding the "search" directive. pub fn set_search(&mut self, search...
code_fim
hard
{ "lang": "rust", "repo": "mullvad/resolv-conf", "path": "/src/config.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mullvad/resolv-conf path: /src/config.rs use std::iter::{IntoIterator, Iterator}; use std::slice::Iter; use {grammar, Network, ParseError, ScopedIp}; use std::net::{IpAddr, Ipv4Addr, Ipv6Addr}; #[cfg(feature = "system")] use hostname::get_hostname; const NAMESERVER_LIMIT:usize = 3; const SEARC...
code_fim
hard
{ "lang": "rust", "repo": "mullvad/resolv-conf", "path": "/src/config.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<E1, E2, E3, E4, E> FromErr<Err4<E1, E2, E3, E4>> for E where E: FromErr<E1>, E: FromErr<E2>, E: FromErr<E3>, E: FromErr<E4>, { fn from(e: Err4<E1, E2, E3, E4>) -> Self { use self::Err4::*; match e { V1(e) => FromErr::from(e), ...
code_fim
hard
{ "lang": "rust", "repo": "WaDelma/mini-pl", "path": "/parsco/src/common.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: WaDelma/mini-pl path: /parsco/src/common.rs //! Technical types used by parsers. use {FromErr, Parser, Parseable, Result}; /// Never type. /// /// This is workaround while `!` is not stable. /// It's used to indicate imposibility of certain return values. #[derive(Clone, Copy, Debug, PartialE...
code_fim
hard
{ "lang": "rust", "repo": "WaDelma/mini-pl", "path": "/parsco/src/common.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> const TEST_INPUT: &str = " [D] [N] [C] [Z] [M] [P] 1 2 3 move 1 from 2 to 1 move 3 from 1 to 3 move 2 from 2 to 1 move 1 from 1 to 2 "; #[test] fn test_get_stacks_and_operations() { let (stacks, operations) = get_stacks_and_operations(TEST_INPUT); assert_eq!(stacks, ...
code_fim
hard
{ "lang": "rust", "repo": "khayyamsaleem/advent-of-code", "path": "/2022/src/day_05.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_rearrange_crates_cratemover_9001() { let (mut stacks, operations) = get_stacks_and_operations(TEST_INPUT); rearrange_crates_cratemover_9001(&mut stacks, operations); assert_eq!(stacks, vec![vec!['M'], vec!['C'], vec!['P', 'Z', 'N', 'D']]) } #[test] ...
code_fim
hard
{ "lang": "rust", "repo": "khayyamsaleem/advent-of-code", "path": "/2022/src/day_05.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: khayyamsaleem/advent-of-code path: /2022/src/day_05.rs use crate::common; use itertools::Itertools; use recap::Recap; use reqwest::Error; use serde::Deserialize; type Stack = Vec<char>; #[derive(Debug, Recap, Deserialize, PartialEq, Clone)] #[recap(regex = r#"move (?P<n_crates>\d+) from (?P<s...
code_fim
hard
{ "lang": "rust", "repo": "khayyamsaleem/advent-of-code", "path": "/2022/src/day_05.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!( md_padding(0, bit_len_be_bytes), b"\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ ...
code_fim
hard
{ "lang": "rust", "repo": "foudfou/cryptopals", "path": "/src/sha.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: foudfou/cryptopals path: /src/sha.rs /// https://en.wikipedia.org/wiki/SHA-1#SHA-1_pseudocode /// https://tools.ietf.org/html/rfc3174#section-7 /// SHA1, as well as MD5, are built on the model of Merkle–Damgård (MD). MD /// also stands for "Message Digest". use std::convert::{TryFrom, TryInto}; ...
code_fim
hard
{ "lang": "rust", "repo": "foudfou/cryptopals", "path": "/src/sha.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let claims: Claims = AuthTrait::new(1); conn.execute("INSERT INTO users (\"user\", \"password\") VALUES ($1, $2)", &[&input_login.user, &input_login.password]).unwrap(); format!("2") }<|fim_prefix|>// repo: jcamposforner/Rust-Rocket-Example path: /src/routes/user/login.rs ...
code_fim
medium
{ "lang": "rust", "repo": "jcamposforner/Rust-Rocket-Example", "path": "/src/routes/user/login.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jcamposforner/Rust-Rocket-Example path: /src/routes/user/login.rs use crate::db::Conn; use crate::services::auth::auth_trait::AuthTrait; use crate::services::auth::jwt::Claims; <|fim_suffix|> conn.execute("INSERT INTO users (\"user\", \"password\") VALUES ($1, $2)", &[&input...
code_fim
hard
{ "lang": "rust", "repo": "jcamposforner/Rust-Rocket-Example", "path": "/src/routes/user/login.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> conn.execute("INSERT INTO users (\"user\", \"password\") VALUES ($1, $2)", &[&input_login.user, &input_login.password]).unwrap(); format!("2") }<|fim_prefix|>// repo: jcamposforner/Rust-Rocket-Example path: /src/routes/user/login.rs use crate::db::Conn; use crate::services::aut...
code_fim
medium
{ "lang": "rust", "repo": "jcamposforner/Rust-Rocket-Example", "path": "/src/routes/user/login.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: comex/os-unfair-lock path: /src/lib.rs #![cfg(any(target_os = "macos", target_os = "ios"))] #![no_std] #![cfg_attr(feature = "nightly", feature(coerce_unsized, unsize))] use core::cell::UnsafeCell; use core::default::Default; use core::fmt::{self, Debug, Display, Formatter}; use core::marker::P...
code_fim
hard
{ "lang": "rust", "repo": "comex/os-unfair-lock", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl<'a, T: ?Sized + Display> Display for MutexGuard<'a, T> { #[inline] fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { (**self).fmt(f) } } #[cfg(feature = "nightly")] impl<'a, T: ?Sized, U: ?Sized> core::ops::CoerceUnsized<MutexGuard<'a, U>> for MutexGuard<'a, T> where T: c...
code_fim
hard
{ "lang": "rust", "repo": "comex/os-unfair-lock", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(feature = "nightly")] impl<T, U> core::ops::CoerceUnsized<Mutex<U>> for Mutex<T> where T: core::ops::CoerceUnsized<U> {} // extra impls: MutexGuard impl<'a, T: ?Sized + Debug> Debug for MutexGuard<'a, T> { #[inline] fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { (**self).fmt...
code_fim
hard
{ "lang": "rust", "repo": "comex/os-unfair-lock", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jackyarndley/rust-ray path: /src/util/mod.rs use crate::objects::{Hitable, Triangle}; use crate::material::Material; use rand::{Rng, thread_rng}; use std::path::Path; pub mod scenes; pub mod camera; pub mod vec3; pub mod ray; pub mod sample; pub use scenes::*; pub use camera::*; pub use vec3::...
code_fim
hard
{ "lang": "rust", "repo": "jackyarndley/rust-ray", "path": "/src/util/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let element = Triangle::new( Vec3::new(mesh.positions[position_index] as f64, mesh.positions[position_index + 1] as f64, mesh.positions[position_index + 2] as f64), Vec3::new(mesh.positions[position_index1] as f64, mesh.positions[position_index1 + 1] as f64, mes...
code_fim
hard
{ "lang": "rust", "repo": "jackyarndley/rust-ray", "path": "/src/util/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Consumes the `Rms` signal and returns its inner signal `S` and `Rms` detector. /// /// ### Required Features /// /// - When using `dasp_signal`, this item requires the **rms** feature to be enabled. /// - When using `dasp`, this item requires the **signal-rms** feature to be en...
code_fim
hard
{ "lang": "rust", "repo": "RustAudio/dasp", "path": "/dasp_signal/src/rms.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: RustAudio/dasp path: /dasp_signal/src/rms.rs //! An extension to the **Signal** trait that monitors the RMS of a signal. //! //! ### Required Features //! //! - When using `dasp_signal`, this module requires the **rms** feature to be enabled. //! - When using `dasp`, this module requires the **s...
code_fim
hard
{ "lang": "rust", "repo": "RustAudio/dasp", "path": "/dasp_signal/src/rms.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nimiq/albatross-simulator path: /src/simulation/mod.rs use std::fmt; use crate::datastructures::block::Block; use crate::datastructures::block::MacroBlock; use crate::datastructures::block::MacroHeader; use crate::datastructures::pbft::PbftProof; use crate::datastructures::pbft::ViewChange; use...
code_fim
hard
{ "lang": "rust", "repo": "nimiq/albatross-simulator", "path": "/src/simulation/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Internal events. Event::BlockProcessed(block) => write!(f, "processed block {}", block), Event::BlockProduced(block) => write!(f, "produced block {}", block), Event::ProposalProcessed(block, _signature) => write!(f, "processed proposal {}", block), ...
code_fim
hard
{ "lang": "rust", "repo": "nimiq/albatross-simulator", "path": "/src/simulation/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: najamelan/unicode-wrap path: /src/generator/unicode_standard.rs use xi_unicode::LineBreakIterator; use super::*; use self::Generate; #[ derive( PartialEq, Eq, Clone, Debug ) ] // pub struct Xi { pub priority: usize } impl Generate for Xi { fn opportunities( &self, text: &str ) -> Vec< S...
code_fim
hard
{ "lang": "rust", "repo": "najamelan/unicode-wrap", "path": "/src/generator/unicode_standard.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> { let mut split = SplitPoint::new( 3, 4, 0 ); let mut split2 = SplitPoint::new( 4, 5, 0 ); split .mandatory = true; split2.mandatory = true; assert_eq!( Xi{ priority: 0 }.opportunities( "bin\n\ndoo" ), vec![ split, split2, end( 8, 8, 0 ) ] ); } #[test] fn crlf_should_give_one_splitpoint...
code_fim
hard
{ "lang": "rust", "repo": "najamelan/unicode-wrap", "path": "/src/generator/unicode_standard.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> let mut atlas = InternalImage::new(resolution_width, resolution_height); for (tile_index, resource_tile) in layout.tiles.iter().enumerate() { //The rare mutable binding to an immutable reference shows its face again! Cool. let mut texture_to_use = match texture_source.load_image(resource_tile) { ...
code_fim
hard
{ "lang": "rust", "repo": "NotGyro/Gestalt", "path": "/gestalt-core/src/client/render/tiletextureatlas.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let idx = self.tiles.len(); if idx >= self.max_tiles { return Err(TileAtlasError::OverMax(resource_debug!(resource), self.max_tiles)); } //Insert this into the tiles. self.tiles.push(*resource); //Make sure we can look it up the other way, too. self.reverse_index.insert(*r...
code_fim
hard
{ "lang": "rust", "repo": "NotGyro/Gestalt", "path": "/gestalt-core/src/client/render/tiletextureatlas.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: NotGyro/Gestalt path: /gestalt-core/src/client/render/tiletextureatlas.rs use crate::resource::image::{ ImageProvider, InternalImage, ID_MISSING_TEXTURE, ID_PENDING_TEXTURE, }; use crate::resource::ResourceId; use glam::Vec2; use image::{GenericImage, ImageError}; use log::error; use std::colle...
code_fim
hard
{ "lang": "rust", "repo": "NotGyro/Gestalt", "path": "/gestalt-core/src/client/render/tiletextureatlas.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: iduartgomez/tf-rs path: /src/ops/init_ops.rs use TensorShape; use super::*; /// Initializer that generates tensors with constant values. /// /// The resulting tensor is populated with values of type dtype, as specified by arguments value /// following the desired shape of the new tensor (see ex...
code_fim
hard
{ "lang": "rust", "repo": "iduartgomez/tf-rs", "path": "/src/ops/init_ops.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>///// Lower level support ops ///// /// The output is a handle to the underlying mutable tensor. /// /// Needs to be initialized before it can be used. pub(crate) fn variable_<'a, I>( graph: &mut Graph, name: &str, dtype: DataType, shape: &TensorShape, control_inputs: I, ) -> Result<O...
code_fim
hard
{ "lang": "rust", "repo": "iduartgomez/tf-rs", "path": "/src/ops/init_ops.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[ignore] #[test] #[cfg(test)] fn test_random_normal_initializer() { let mut context = Scope::new(); let init = random_normal_initializer(&mut context, 0.0_f32, 1.0, None, [2, 2].as_ref()).unwrap(); let var = context .get_variable_with_initializer(init, true, "") .unwr...
code_fim
hard
{ "lang": "rust", "repo": "iduartgomez/tf-rs", "path": "/src/ops/init_ops.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: markzhang1986/rust_homework path: /HW01/hw01_zhangzipeng/src/problem1.rs pub fn sum(slice: &[i32]) -> i32 { let mut res: i32 = 0; for n in slice { res += *n; } res } <|fim_suffix|> for n in vs { if res.contains(n) { } else { res.push(*n...
code_fim
medium
{ "lang": "rust", "repo": "markzhang1986/rust_homework", "path": "/HW01/hw01_zhangzipeng/src/problem1.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> } else { res.push(*n); } } res } pub fn filter(vs: &Vec<i32>, pred: &Fn(i32) -> bool) -> Vec<i32> { let mut res = Vec::new(); for n in vs { if pred(*n) { res.push(*n); } } res }<|fim_prefix|>// repo: markzhang1986/rust_hom...
code_fim
medium
{ "lang": "rust", "repo": "markzhang1986/rust_homework", "path": "/HW01/hw01_zhangzipeng/src/problem1.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> &self, room_id: Option<&RoomId>, user_id: &UserId, kind: &EventType, ) -> Option<Result<(IVec, IVec)>> { let mut prefix = room_id .map(|r| r.to_string()) .unwrap_or_default() .as_bytes() .to_vec(); prefix.p...
code_fim
hard
{ "lang": "rust", "repo": "bbigras/conduit-1", "path": "/src/database/account_data.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bbigras/conduit-1 path: /src/database/account_data.rs use crate::{utils, Error, Result}; use ruma::{ api::client::error::ErrorKind, events::{AnyEvent as EduEvent, EventType}, serde::Raw, RoomId, UserId, }; use serde::{de::DeserializeOwned, Serialize}; use sled::IVec; use std::{co...
code_fim
hard
{ "lang": "rust", "repo": "bbigras/conduit-1", "path": "/src/database/account_data.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Ok(userdata) } fn find_event( &self, room_id: Option<&RoomId>, user_id: &UserId, kind: &EventType, ) -> Option<Result<(IVec, IVec)>> { let mut prefix = room_id .map(|r| r.to_string()) .unwrap_or_default() .as_...
code_fim
hard
{ "lang": "rust", "repo": "bbigras/conduit-1", "path": "/src/database/account_data.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vmware/differential-datalog path: /rust/ddlog_benches/src/live_journal.rs use benchmarks_ddlog::{typedefs::live_journal::Edge, Relations}; use differential_datalog::{ ddval::{DDValConvert, DDValue}, program::{RelId, Update}, }; use flate2::bufread::GzDecoder; use std::{ fs::File, ...
code_fim
hard
{ "lang": "rust", "repo": "vmware/differential-datalog", "path": "/rust/ddlog_benches/src/live_journal.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for line in reader .lines() .flat_map(|line| line.ok()) .take(samples.unwrap_or_else(usize::max_value)) { if line.starts_with('#') { continue; } let mut split = line.trim().split('\t'); let from = split.next().unwrap().trim().par...
code_fim
hard
{ "lang": "rust", "repo": "vmware/differential-datalog", "path": "/rust/ddlog_benches/src/live_journal.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Ogeon/pyrite path: /pyrite/src/world.rs use std::error::Error; use rand::Rng; use obj; use cgmath::{ EuclideanSpace, InnerSpace, Matrix3, Matrix4, Point2, SquareMatrix, Vector2, Vector3, }; use collision::Ray3; use crate::{ lamp::Lamp, materials::Material, math::DIST_EPSILON,...
code_fim
hard
{ "lang": "rust", "repo": "Ogeon/pyrite", "path": "/pyrite/src/world.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn make_triangle<'p>( obj: &obj::Obj, obj::IndexTuple(v1, t1, n1): obj::IndexTuple, obj::IndexTuple(v2, t2, n2): obj::IndexTuple, obj::IndexTuple(v3, t3, n3): obj::IndexTuple, material: Material<'p>, ) -> Shape<'p> { let v1 = obj.data.position[v1].into(); let v2 = obj.data.posi...
code_fim
hard
{ "lang": "rust", "repo": "Ogeon/pyrite", "path": "/pyrite/src/world.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let (n1, n2, n3) = match (n1, n2, n3) { (Some(n1), Some(n2), Some(n3)) => { let n1 = obj.data.normal[n1].into(); let n2 = obj.data.normal[n2].into(); let n3 = obj.data.normal[n3].into(); (n1, n2, n3) } _ => { let a: Ve...
code_fim
hard
{ "lang": "rust", "repo": "Ogeon/pyrite", "path": "/pyrite/src/world.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: forkkit/glium_shapes path: /src/errors.rs //! A module containing the error structures for this crate. extern crate core; extern crate glium; extern crate std; use std::error::Error; /// The error object that is returned when a shape fails to build. #[derive(Debug, Copy, Clone)] pub enum Shape...
code_fim
hard
{ "lang": "rust", "repo": "forkkit/glium_shapes", "path": "/src/errors.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl From<glium::vertex::BufferCreationError> for ShapeCreationError { fn from(error: glium::vertex::BufferCreationError) -> Self { ShapeCreationError::VertexBufferCreationError(error) } } impl core::fmt::Display for ShapeCreationError { fn fmt(&self, fmt: &mut core::fmt::Formatter) -...
code_fim
hard
{ "lang": "rust", "repo": "forkkit/glium_shapes", "path": "/src/errors.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }