text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: JPaiv/alphabet_tools path: /src/letter_to_alphabet_index.rs use std::char; fn letter_alphabet_index(letter: str)-> i32 { l<|fim_suffix|>iter().position(|&r| r == 'a').unwrap(); return letter_index }<|fim_middle|>et english_alphabet = (10..36).map(|i| char::from_digit(i, 36).unwrap()).c...
code_fim
medium
{ "lang": "rust", "repo": "JPaiv/alphabet_tools", "path": "/src/letter_to_alphabet_index.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>iter().position(|&r| r == 'a').unwrap(); return letter_index }<|fim_prefix|>// repo: JPaiv/alphabet_tools path: /src/letter_to_alphabet_index.rs use std::char; fn letter_alphabet_index(letter: str)-> i32 { l<|fim_middle|>et english_alphabet = (10..36).map(|i| char::from_digit(i, 36).unwrap()).c...
code_fim
medium
{ "lang": "rust", "repo": "JPaiv/alphabet_tools", "path": "/src/letter_to_alphabet_index.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: VisualSource/task_watcher path: /src/status_handler.rs extern crate craftping; extern crate chrono; extern crate rand; extern crate hex; extern crate byteorder; use rand::Rng; use craftping::sync::ping; use std::net::UdpSocket; use std::time::{Duration,SystemTime, UNIX_EPOCH}; use byteorder::{W...
code_fim
hard
{ "lang": "rust", "repo": "VisualSource/task_watcher", "path": "/src/status_handler.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// @author Jviguy /// @see /// https://github.com/Jviguy/rsquery/blob/master/src/lib.rs pub fn get_bedrock_status(hostname: &str, port: u16) -> (bool, usize) { let socket = match UdpSocket::bind(("0.0.0.0",8000)) { Ok(socket) => socket, Err(_err) => { eprintln!("{}","fai...
code_fim
hard
{ "lang": "rust", "repo": "VisualSource/task_watcher", "path": "/src/status_handler.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let status = get_bedrock_status("192.168.1.5", 19132); println!("Server is {:#?}", status); } #[test] fn test_java(){ let status = get_status("play.applecraftmc.org",25565); println!("Server is {} with {} players", status.0,status.1); } }...
code_fim
hard
{ "lang": "rust", "repo": "VisualSource/task_watcher", "path": "/src/status_handler.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match direction { Direction::North => self.northings += *distance as isize, Direction::East => self.eastings += *distance as isize, Direction::South => self.northings -= *distance as isize, Direction::West => self.eastings -= *distance as isize, ...
code_fim
hard
{ "lang": "rust", "repo": "davidlang42/advent2020", "path": "/day12/part1/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> ParseError::Int(e) } } impl From<ParseCharError> for ParseError { fn from(e: ParseCharError) -> Self { ParseError::Char(e) } } impl FromStr for Instruction { type Err = ParseError; fn from_str(line: &str) -> Result<Self, Self::Err> { let c: char = line[0..1]....
code_fim
hard
{ "lang": "rust", "repo": "davidlang42/advent2020", "path": "/day12/part1/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: davidlang42/advent2020 path: /day12/part1/src/main.rs use std::env; use std::fs; use std::str::FromStr; use std::num::ParseIntError; use std::char::ParseCharError; const NEW_LINE: &str = "\r\n"; #[derive(Debug, Copy, Clone)] enum Direction { North, South, East, West } impl Direction { ...
code_fim
hard
{ "lang": "rust", "repo": "davidlang42/advent2020", "path": "/day12/part1/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rbtying/skull path: /core/src/game_states/mod.rs use serde::{Deserialize, Serialize}; <|fim_suffix|>#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq)] pub enum GameState { Initialize(initialize::Initialize), Placement(placement::Placement), Bidding(bidding::Bidding), ...
code_fim
medium
{ "lang": "rust", "repo": "rbtying/skull", "path": "/core/src/game_states/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq)] pub enum GameState { Initialize(initialize::Initialize), Placement(placement::Placement), Bidding(bidding::Bidding), Selection(selection::Selection), }<|fim_prefix|>// repo: rbtying/skull path: /core/src/game_states/mod.rs use...
code_fim
medium
{ "lang": "rust", "repo": "rbtying/skull", "path": "/core/src/game_states/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let test_file = NamedTempFile::new().unwrap(); let gendir = tempdir().unwrap(); // Build the update package. let mut builder = UpdatePackageBuilder::new(); builder.add_file(test_file.path(), "data/file.txt").unwrap(); builder .add_package_by_man...
code_fim
hard
{ "lang": "rust", "repo": "mvanotti/fuchsia-mirror", "path": "/src/lib/assembly/update_package/src/update_package.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mvanotti/fuchsia-mirror path: /src/lib/assembly/update_package/src/update_package.rs // Copyright 2021 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. use anyhow::{bail, Context, Result}; use assem...
code_fim
hard
{ "lang": "rust", "repo": "mvanotti/fuchsia-mirror", "path": "/src/lib/assembly/update_package/src/update_package.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|>/// ``` /// \__________pkt->size___________/ \_result->size_/ \__pkt->size__/ /// ``` pub fn foo() {}<|fim_prefix|>// repo: unnsa/rust path: /src/test/rustdoc-ui/invalid-syntax.rs // Copyright 2018 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribu...
code_fim
medium
{ "lang": "rust", "repo": "unnsa/rust", "path": "/src/test/rustdoc-ui/invalid-syntax.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: unnsa/rust path: /src/test/rustdoc-ui/invalid-syntax.rs // Copyright 2018 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // ht...
code_fim
medium
{ "lang": "rust", "repo": "unnsa/rust", "path": "/src/test/rustdoc-ui/invalid-syntax.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl LolInventoryRmsEntitlementPayload { pub fn new() -> LolInventoryRmsEntitlementPayload { LolInventoryRmsEntitlementPayload { entitlement_type_id: None, item_id: None, item_type_id: None, resource_operation: None, } } }<|fim_prefix...
code_fim
hard
{ "lang": "rust", "repo": "Potato-Gaming/crystal", "path": "/league-client/src/models/lol_inventory_rms_entitlement_payload.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Potato-Gaming/crystal path: /league-client/src/models/lol_inventory_rms_entitlement_payload.rs /* * * * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * * The version of the OpenAPI document: 1.0.0 * * Generated by: https://ope...
code_fim
hard
{ "lang": "rust", "repo": "Potato-Gaming/crystal", "path": "/league-client/src/models/lol_inventory_rms_entitlement_payload.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chromium/chromium path: /third_party/rust/winapi/v0_3/crate/src/um/bitscfg.rs // Licensed under the Apache License, Version 2.0 // <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. // All file...
code_fim
medium
{ "lang": "rust", "repo": "chromium/chromium", "path": "/third_party/rust/winapi/v0_3/crate/src/um/bitscfg.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> pTaskName: *mut BSTR, ) -> HRESULT, fn GetCleanupTask( riid: REFIID, ppUnk: *mut *mut IUnknown, ) -> HRESULT, }} RIDL!{#[uuid(0xd5d2d542, 0x5503, 0x4e64, 0x8b, 0x48, 0x72, 0xef, 0x91, 0xa3, 0x2e, 0xe1)] interface IBITSExtensionSetupFactory(IBITSExtensionSetupFactoryVtbl...
code_fim
medium
{ "lang": "rust", "repo": "chromium/chromium", "path": "/third_party/rust/winapi/v0_3/crate/src/um/bitscfg.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nicey0/opengl-square-thingy path: /src/shape.rs use super::conf::*; use super::util::{Point, Vertex, GLS}; use glium::{ index::IndicesSource, uniform, Display, DrawParameters, Frame, Program, Surface, VertexBuffer, }; pub struct Shape { vbuf: VertexBuffer<Vertex>, pub w: f32, pu...
code_fim
hard
{ "lang": "rust", "repo": "nicey0/opengl-square-thingy", "path": "/src/shape.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> target .draw( &self.vbuf, indices, program, &uniform! { col: col, matrix: [ [aw, 0.0, 0.0, 0.0], [0.0, ah, 0.0, 0.0], ...
code_fim
hard
{ "lang": "rust", "repo": "nicey0/opengl-square-thingy", "path": "/src/shape.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn draw<'a>( &self, target: &mut Frame, indices: impl Into<IndicesSource<'a>>, program: &Program, params: &DrawParameters, col: [f32; 3], ) { // logical coor -> opengl coor let ax = (GLS / WIDTH) * (self.x + self.w / 2.0) - GLS / ...
code_fim
hard
{ "lang": "rust", "repo": "nicey0/opengl-square-thingy", "path": "/src/shape.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(unsafe { yr_initialize() }, 0); assert_eq!(unsafe { yr_finalize() }, 0); } }<|fim_prefix|>// repo: yoavk/yara-src-rs path: /testcrate/src/lib.rs extern "C" { pub fn yr_initialize() -> ::std::os::raw::c_int; } extern "C" { pub fn yr_finalize() -> ::std::os::raw::c_in...
code_fim
medium
{ "lang": "rust", "repo": "yoavk/yara-src-rs", "path": "/testcrate/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yoavk/yara-src-rs path: /testcrate/src/lib.rs extern "C" { pub fn yr_initialize() -> ::std::os::raw::c_int; } extern "C" { pub fn yr_finalize() -> ::std::os::raw::c_int; } <|fim_suffix|> #[test] fn yr_initialize_works() { assert_eq!(unsafe { yr_initialize() }, 0); ...
code_fim
medium
{ "lang": "rust", "repo": "yoavk/yara-src-rs", "path": "/testcrate/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn alloc(size: usize) -> *mut u8 { unsafe { Allocator.alloc(Layout::from_size_align_unchecked(size, 8)) } } } unsafe impl GlobalAlloc for Allocator { unsafe fn alloc(&self, layout: Layout) -> *mut u8 { return if GC_ENABLED { GC_malloc(layout.size()) } e...
code_fim
hard
{ "lang": "rust", "repo": "mewbak/ein", "path": "/runtime/gc/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mewbak/ein path: /runtime/gc/src/lib.rs extern crate libc; mod error; use libc::{c_int, c_void, size_t}; use std::alloc::{GlobalAlloc, Layout}; const GC_SUCCESS: c_int = 0; #[repr(C)] struct GCStackBase { mem_base: *const c_void, reg_base: *const c_void, } #[link(name = "gc")] exter...
code_fim
hard
{ "lang": "rust", "repo": "mewbak/ein", "path": "/runtime/gc/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: snapview/tokio-tungstenite path: /src/compat.rs use log::*; use std::{ io::{Read, Write}, pin::Pin, task::{Context, Poll}, }; use futures_util::task; use std::sync::Arc; use tokio::io::{AsyncRead, AsyncWrite, ReadBuf}; use tungstenite::Error as WsError; pub(crate) enum ContextWaker...
code_fim
hard
{ "lang": "rust", "repo": "snapview/tokio-tungstenite", "path": "/src/compat.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> where F: FnOnce(&mut Context<'_>, Pin<&mut S>) -> Poll<std::io::Result<R>>, { trace!("{}:{} AllowStd.with_context", file!(), line!()); let waker = match kind { ContextWaker::Read => task::waker_ref(&self.read_waker_proxy), ContextWaker::Write => task...
code_fim
hard
{ "lang": "rust", "repo": "snapview/tokio-tungstenite", "path": "/src/compat.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let i: i32 = 10; match i { 1 => println!("1"), 2 => println!("2"), 3 => println!("3"), _ => println!("misc"), } enum Color { Red, Blue, Green, } let c = Color::Red; match c { Color::Red => println!("Red"), ...
code_fim
hard
{ "lang": "rust", "repo": "gakitoru/rust-learning", "path": "/sample1/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let result: Result<i32, String> = Err("error".to_string()); let result_number = match result { Ok(number) => number, Err(message) => { println!("Error: {}", message); -1 }, }; println!("{}", result_number); for number in 1..=5 { ...
code_fim
hard
{ "lang": "rust", "repo": "gakitoru/rust-learning", "path": "/sample1/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gakitoru/rust-learning path: /sample1/src/main.rs fn main() { let number = 1; if 0 < number { println!("0 < number"); } else if number < 0 { println!("number < 0"); } else { println!("0 == number"); } let number = 1; let result = if 0 <= numbe...
code_fim
hard
{ "lang": "rust", "repo": "gakitoru/rust-learning", "path": "/sample1/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>)| (h, i)) .collect::<Vec<(usize, usize)>>() }) .collect::<HashSet<(usize, usize)>>(); (0..width) .flat_map(|w| { let min = (0..height).map(|h| input[h][w]).min().unwrap(); (0..height) .filter(|h| input[*h][w].eq(&min)) ...
code_fim
hard
{ "lang": "rust", "repo": "koboriakira/exercism-rust", "path": "/rust/saddle-points/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: koboriakira/exercism-rust path: /rust/saddle-points/src/lib.rs use std::collections::HashSet; pub fn find_saddle_points(input: &[Vec<u64>]) -> Vec<(usize, usize)> { let (height, width): (usize, usize) = (input.len(), input[0].len()); if width == 0 || height == 0 { return vec![];...
code_fim
hard
{ "lang": "rust", "repo": "koboriakira/exercism-rust", "path": "/rust/saddle-points/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TWinsnes/rusty-euler path: /problem003/problem3.rs use std; ////////////////////////////////////////////////////////// // // Problem 3: // What is the largest prime factor of the number // 600851475143 ? // ////////////////////////////////////////////////////////// fn main() { std::io::printl...
code_fim
medium
{ "lang": "rust", "repo": "TWinsnes/rusty-euler", "path": "/problem003/problem3.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> while (factor < number) { while (number % factor ==0) { number /= factor; std::io::println(#fmt("Prime: %d\tRemander: %d", factor, number)) } factor+=1; } ret factor; } // test for solution #[test] fn testSolution() { let result: int = solution(13195); //std::io::println(#fmt("Res...
code_fim
hard
{ "lang": "rust", "repo": "TWinsnes/rusty-euler", "path": "/problem003/problem3.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>// test for solution #[test] fn testSolution() { let result: int = solution(13195); //std::io::println(#fmt("Result: %d", result)); assert result == 29; }<|fim_prefix|>// repo: TWinsnes/rusty-euler path: /problem003/problem3.rs use std; ////////////////////////////////////////////////////////// // /...
code_fim
hard
{ "lang": "rust", "repo": "TWinsnes/rusty-euler", "path": "/problem003/problem3.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: m00p1ng/kattis-problem path: /LV1/1.2/carrots/carrots.rs use std::io::{self, BufRead}; fn main() { let mut buff = String::new(); let stdin = io::stdin(); <|fim_suffix|> let word: Vec<&str> = buff.split_whitespace().collect(); println!("{}", word[1]); }<|fim_middle|> stdin.loc...
code_fim
easy
{ "lang": "rust", "repo": "m00p1ng/kattis-problem", "path": "/LV1/1.2/carrots/carrots.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> stdin.lock().read_line(&mut buff).unwrap(); let word: Vec<&str> = buff.split_whitespace().collect(); println!("{}", word[1]); }<|fim_prefix|>// repo: m00p1ng/kattis-problem path: /LV1/1.2/carrots/carrots.rs use std::io::{self, BufRead}; <|fim_middle|>fn main() { let mut buff = String::n...
code_fim
medium
{ "lang": "rust", "repo": "m00p1ng/kattis-problem", "path": "/LV1/1.2/carrots/carrots.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let word: Vec<&str> = buff.split_whitespace().collect(); println!("{}", word[1]); }<|fim_prefix|>// repo: m00p1ng/kattis-problem path: /LV1/1.2/carrots/carrots.rs use std::io::{self, BufRead}; fn main() { let mut buff = String::new(); let stdin = io::stdin(); <|fim_middle|> stdin.loc...
code_fim
easy
{ "lang": "rust", "repo": "m00p1ng/kattis-problem", "path": "/LV1/1.2/carrots/carrots.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Bypass size checking during import let tipset = (self.get_tipset)(); if tipset.epoch() == 0 { continue; } // Bypass size checking when lock is held { let lock = self.lock.try_lock(); ...
code_fim
hard
{ "lang": "rust", "repo": "0xb10ckdev/forest", "path": "/src/db/rolling/gc.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 0xb10ckdev/forest path: /src/db/rolling/gc.rs // Copyright 2019-2023 ChainSafe Systems // SPDX-License-Identifier: Apache-2.0, MIT //! //! The current implementation of the garbage collector is a concurrent, //! semi-space one. //! //! ## Design goals //! Implement a correct GC algorithm that i...
code_fim
hard
{ "lang": "rust", "repo": "0xb10ckdev/forest", "path": "/src/db/rolling/gc.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn display_group(group: Group) -> Result<(), KeyManagerError> { let items = group.items()?; if items.len() == 0 { println!("Group named {} does not exist or is empty", group.name); } else { println!("{} ({} key(s))", &group.name, items.len()); for item in items { ...
code_fim
hard
{ "lang": "rust", "repo": "Gravitas-GM/key-manager", "path": "/src/cli/commands/list.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for item in items { println!(" - {}", item.file_name().unwrap().to_str().unwrap()); } println!(); } Ok(()) }<|fim_prefix|>// repo: Gravitas-GM/key-manager path: /src/cli/commands/list.rs use structopt::StructOpt; use crate::cli::Command; use crate::error::Ke...
code_fim
hard
{ "lang": "rust", "repo": "Gravitas-GM/key-manager", "path": "/src/cli/commands/list.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Gravitas-GM/key-manager path: /src/cli/commands/list.rs use structopt::StructOpt; use crate::cli::Command; use crate::error::KeyManagerError; use crate::app::{Application, Group}; #[derive(Debug, StructOpt)] pub struct ListCommand { /// If provided, only keys belonging to the named group wi...
code_fim
medium
{ "lang": "rust", "repo": "Gravitas-GM/key-manager", "path": "/src/cli/commands/list.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Emilgardis/svd path: /svd-encoder/src/config.rs use std::str::FromStr; use convert_case::{Boundary, Case, Casing}; use crate::svd::BitRangeType; #[derive(Clone, Copy, Debug)] pub enum IdentifierFormat { /// `Camel` case /// /// `aCamelCaseExample` Camel, /// `Pascal` case ...
code_fim
hard
{ "lang": "rust", "repo": "Emilgardis/svd", "path": "/svd-encoder/src/config.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> /// Format of addressBlock's size element /// /// format: hex, dec pub fn address_block_size(mut self, val: NumberFormat) -> Self { self.address_block_size = val; self } /// Format of interrupt's name-kind elements pub fn interrupt_name(mut self, val: Option<Id...
code_fim
hard
{ "lang": "rust", "repo": "Emilgardis/svd", "path": "/svd-encoder/src/config.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> /// Format of peripheral's name-kind elements pub fn peripheral_name(mut self, val: Option<IdentifierFormat>) -> Self { self.peripheral_name = val; self } /// Format of peripheral's baseAddress element /// /// format: hex, dec pub fn peripheral_base_address(mut...
code_fim
hard
{ "lang": "rust", "repo": "Emilgardis/svd", "path": "/svd-encoder/src/config.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> let size = self.file.size(); self.seek = match whence { SEEK_SET => max(0, offset as i64) as u64, SEEK_CUR => max(0, self.seek as i64 + offset as i64) as u64, SEEK_END => max(0, size as i64 + offset as i64) as u64, _ => return Err(Error::new...
code_fim
hard
{ "lang": "rust", "repo": "deepaksirone/redox-fatfs", "path": "/src/mount/redox/resource.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: deepaksirone/redox-fatfs path: /src/mount/redox/resource.rs use std::cmp::{min, max}; //use std::time::{SystemTime, UNIX_EPOCH}; use std::io::{Read, Write, Seek}; use syscall::data::{Map, Stat, TimeSpec}; use syscall::error::{Error, Result, EBADF, EINVAL, EISDIR, EPERM}; use syscall::flag::{O_A...
code_fim
hard
{ "lang": "rust", "repo": "deepaksirone/redox-fatfs", "path": "/src/mount/redox/resource.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: paulotten/advent_of_code_2020 path: /day20/part2/src/main.rs mod data; fn main() { let monsters = data::get_monsters(); let data = data::get_data(); //let data = data::_sample(); let puzzle = boolify(&remove_borders(data)); let mut matches = 0; for monster in &monste...
code_fim
hard
{ "lang": "rust", "repo": "paulotten/advent_of_code_2020", "path": "/day20/part2/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> output } fn remove_borders(input: &str) -> String { let mut output = String::new(); let mut i = 0; let mut j = 0; for line in input.lines() { if !is_border(i) { for c in line.chars() { if !is_border(j) { output.push(c); ...
code_fim
hard
{ "lang": "rust", "repo": "paulotten/advent_of_code_2020", "path": "/day20/part2/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pco2699/algorithms path: /clustering2/src/union_find_list.rs use std::collections::HashMap; #[derive(Debug)] pub struct UnionFindList { nodes: Vec<Node>, cluster_size: HashMap<usize, usize> } #[derive(Debug)] struct Node { leader: usize, } <|fim_suffix|> let size_u = self....
code_fim
hard
{ "lang": "rust", "repo": "pco2699/algorithms", "path": "/clustering2/src/union_find_list.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let size_u = self.get_size(u); let size_v = self.get_size(v); let leader_u = self.find(u); let leader_v = self.find(v); if size_u > size_v { for n in self.nodes.iter_mut() { if n.leader == leader_v { n.leader = leade...
code_fim
hard
{ "lang": "rust", "repo": "pco2699/algorithms", "path": "/clustering2/src/union_find_list.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if size_u > size_v { for n in self.nodes.iter_mut() { if n.leader == leader_v { n.leader = leader_u; } } self.cluster_size.insert(leader_u, size_u + size_v); self.cluster_size.remove(&leader_v); ...
code_fim
medium
{ "lang": "rust", "repo": "pco2699/algorithms", "path": "/clustering2/src/union_find_list.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: HerringtonDarkholme/leetcode path: /src/173_BSTIterator.rs // Definition for a binary tree node. // #[derive(Debug, PartialEq, Eq)] // pub struct TreeNode { // pub val: i32, // pub left: Option<Rc<RefCell<TreeNode>>>, // pub right: Option<Rc<RefCell<TreeNode>>>, // } // // impl TreeNode {...
code_fim
medium
{ "lang": "rust", "repo": "HerringtonDarkholme/leetcode", "path": "/src/173_BSTIterator.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn next(&mut self) -> i32 { loop { let n = self.stack.last().unwrap(); let mut n = n.borrow_mut(); if let Some(left) = n.left.take() { drop(n); self.stack.push(left); continue; } let ret...
code_fim
hard
{ "lang": "rust", "repo": "HerringtonDarkholme/leetcode", "path": "/src/173_BSTIterator.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> loop { let n = self.stack.last().unwrap(); let mut n = n.borrow_mut(); if let Some(left) = n.left.take() { drop(n); self.stack.push(left); continue; } let ret = n.val; let right ...
code_fim
hard
{ "lang": "rust", "repo": "HerringtonDarkholme/leetcode", "path": "/src/173_BSTIterator.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // let mut sentinel_config: sentinel::Config = // serde_yaml::from_value((global_config.resources.get("localhost").unwrap()).clone()) // .unwrap(); // sentinel_config.notifiers.push(smtp_notifier.sender()); // let http_sentinel = // sentinel::http::HttpSentinel::cr...
code_fim
hard
{ "lang": "rust", "repo": "Flowneee/sentinel", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Flowneee/sentinel path: /src/lib.rs use tokio::prelude::*; mod app; mod notifier; mod sentinel; /// Generic boxed future. pub(crate) type BoxedFuture<R, E> = Box<dyn Future<Item = R, Error = E> + Send>; pub(crate) type BoxedStream<R, E> = Box<dyn Stream<Item = R, Error = E> + Send>; pub fn ma...
code_fim
hard
{ "lang": "rust", "repo": "Flowneee/sentinel", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let task2=tokio::spawn(async { dowork(2).await; }); join!(task1); join!(task2); println!("hey"); }<|fim_prefix|>// repo: risonakamo/eh-system-backend2 path: /tests/tokio_test.rs use tokio::time::{sleep,Duration}; use tokio::join; <|fim_middle|>async fn dowork(secs:u64) { ...
code_fim
hard
{ "lang": "rust", "repo": "risonakamo/eh-system-backend2", "path": "/tests/tokio_test.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: risonakamo/eh-system-backend2 path: /tests/tokio_test.rs use tokio::time::{sleep,Duration}; use tokio::join; <|fim_suffix|> join!(task1); join!(task2); println!("hey"); }<|fim_middle|>async fn dowork(secs:u64) { println!("working for {}",secs); sleep(Duration::from_secs(secs...
code_fim
hard
{ "lang": "rust", "repo": "risonakamo/eh-system-backend2", "path": "/tests/tokio_test.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> join!(task1); join!(task2); println!("hey"); }<|fim_prefix|>// repo: risonakamo/eh-system-backend2 path: /tests/tokio_test.rs use tokio::time::{sleep,Duration}; use tokio::join; async fn dowork(secs:u64) { println!("working for {}",secs); sleep(Duration::from_secs(secs)).await; ...
code_fim
medium
{ "lang": "rust", "repo": "risonakamo/eh-system-backend2", "path": "/tests/tokio_test.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.timer.ccer.write(|w| { if power > 0 { let speed = (power.abs() + FORWARD_DEADBAND) as u32; self.timer.ccr1.write(|w| w.ccr1().bits(speed)); self.timer.ccr2.write(|w| w.ccr2().bits(speed)); w.cc1e().clear_bit().cc2e()....
code_fim
hard
{ "lang": "rust", "repo": "rowanras/micromouse", "path": "/firmware/src/motors/left.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rowanras/micromouse path: /firmware/src/motors/left.rs use core::i32; use stm32f4xx_hal::stm32 as stm32f405; use crate::motors::{Encoder, Motor}; const FORWARD_DEADBAND: i32 = 0; const BACKWARD_DEADBAND: i32 = 0; pub struct LeftMotor { timer: stm32f405::TIM3, } impl LeftMotor { pub ...
code_fim
hard
{ "lang": "rust", "repo": "rowanras/micromouse", "path": "/firmware/src/motors/left.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>// Src: https://github.com/davidbegin/clear-terminal fn clear_screen() { let output = Command::new("clear") .output() .unwrap_or_else(|e| panic!("failed to execute process: {}", e)); println!("{}", String::from_utf8_lossy(&output.stdout)); }<|fim_prefix|>// repo: graves501/rust-cl...
code_fim
hard
{ "lang": "rust", "repo": "graves501/rust-cli-hangman", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: graves501/rust-cli-hangman path: /src/main.rs use std::io; use std::process::Command; fn main() { clear_screen(); println!("Put in a word to guess!"); let mut word_to_guess = String::new(); io::stdin() .read_line(&mut word_to_guess) .expect("Failed to read inp...
code_fim
hard
{ "lang": "rust", "repo": "graves501/rust-cli-hangman", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn scale(n: f64, start: RangeInclusive<f64>, end: RangeInclusive<f64>) -> f64 { let (in_min, in_max) = (start.start(), start.end()); let (out_min, out_max) = (end.start(), end.end()); (n - in_min) * (out_max - out_min) / (in_max - in_min) + out_min }<|fim_prefix|>// repo: tyngsboroughrobo...
code_fim
medium
{ "lang": "rust", "repo": "tyngsboroughrobotics/botball", "path": "/lib/src/helpers.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tyngsboroughrobotics/botball path: /lib/src/helpers.rs use std::ops::RangeInclusive; #[repr(i32)] #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum DriveDirection { Forward = 0, Reverse = 1, } #[repr(i32)] #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum TurnDirection { Le...
code_fim
medium
{ "lang": "rust", "repo": "tyngsboroughrobotics/botball", "path": "/lib/src/helpers.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> use std::collections::hash_map::DefaultHasher; use std::hash::{Hash, Hasher}; let mut s = DefaultHasher::new(); self.hash(&mut s); Ok(s.finish() as isize) } } impl From<raptor::ir::Dereference<raptor::ir::Constant>> for Dereference { fn from(dereference: ra...
code_fim
hard
{ "lang": "rust", "repo": "falconre/falconre", "path": "/src/raptor/ir/dereference.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn __hash__(&self) -> PyResult<isize> { use std::collections::hash_map::DefaultHasher; use std::hash::{Hash, Hasher}; let mut s = DefaultHasher::new(); self.hash(&mut s); Ok(s.finish() as isize) } } impl From<raptor::ir::Dereference<raptor::ir::Constant>> f...
code_fim
hard
{ "lang": "rust", "repo": "falconre/falconre", "path": "/src/raptor/ir/dereference.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: falconre/falconre path: /src/raptor/ir/dereference.rs use crate::map_err; use pyo3::class::PyObjectProtocol; use pyo3::prelude::*; #[pyclass] #[derive(Clone, Eq, Hash, PartialEq)] pub struct Dereference { pub(crate) dereference: raptor::ir::Dereference<raptor::ir::Constant>, } #[pymethods]...
code_fim
hard
{ "lang": "rust", "repo": "falconre/falconre", "path": "/src/raptor/ir/dereference.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: larago/rust-runas path: /examples/demo.rs extern crate runas; fn main() { println!("Running id<|fim_suffix|>("touch") .arg("/tmp/test.foo") .force_prompt(false) .status().expect("failed to execute")); }<|fim_middle|> as root:"); println!("Status: {}", runas::Com...
code_fim
easy
{ "lang": "rust", "repo": "larago/rust-runas", "path": "/examples/demo.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>("touch") .arg("/tmp/test.foo") .force_prompt(false) .status().expect("failed to execute")); }<|fim_prefix|>// repo: larago/rust-runas path: /examples/demo.rs extern crate runas; fn main() { println!("Running id<|fim_middle|> as root:"); println!("Status: {}", runas::Com...
code_fim
easy
{ "lang": "rust", "repo": "larago/rust-runas", "path": "/examples/demo.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lambdadelta34/dices path: /server/src/routes/dices.rs use crate::handlers::dices; use crate::utils; use warp::Filter; pub fn routes( db: impl utils::DBConnection, ) -> impl Filter<Extract = impl warp::Reply, Error = warp::Rejection> + Clone { roll(db.clone()).or(dice(db)) } // GET /:id...
code_fim
hard
{ "lang": "rust", "repo": "lambdadelta34/dices", "path": "/server/src/routes/dices.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn dice() -> Dice { Dice { id: "id".to_string(), dice_type: DiceType::D6, number: 4, } } fn roll_request() -> utils::Request { utils::Request { dice_type: Some(DiceType::D20), } } }<|fim_prefix|>// repo: lambd...
code_fim
hard
{ "lang": "rust", "repo": "lambdadelta34/dices", "path": "/server/src/routes/dices.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rummolprod999/WebParserRust path: /src/parsers/parser_baltika.rs extern crate chrono; extern crate select; use self::select::document::Document; use self::select::node::Node; use self::select::predicate::{Class, Name, Predicate}; use super::parsers::WebParserTenders; use crate::settings::settin...
code_fim
hard
{ "lang": "rust", "repo": "rummolprod999/WebParserRust", "path": "/src/parsers/parser_baltika.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let document = Document::from(&*page_text); for ten in document.find( Name("div") .and(Class("news-list__result-records")) .child(Name("div").and(Class("news-list__result"))), ) { match self.parser_tender(ten) { ...
code_fim
hard
{ "lang": "rust", "repo": "rummolprod999/WebParserRust", "path": "/src/parsers/parser_baltika.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Solver for Solver001 { fn solve(&self) -> i64 { // the contribution is the factor multiplied by the sum of the number of occurrences let contribution = |factor| factor * arithmetic_sum((self.n - 1) / factor); self.input.iter().map(|&factor| contribution(factor) - self.inp...
code_fim
medium
{ "lang": "rust", "repo": "barreiro/euler", "path": "/src/main/rust/euler/solver001.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: barreiro/euler path: /src/main/rust/euler/solver001.rs // COPYRIGHT (C) 2017 barreiro. All Rights Reserved. // Rust solvers for Project Euler problems use algorithm::long::arithmetic_sum; use Solver; // keep sorted const INPUT_001: &[i64] = &[3, 5]; <|fim_suffix|> Self { n: 1000, input...
code_fim
hard
{ "lang": "rust", "repo": "barreiro/euler", "path": "/src/main/rust/euler/solver001.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Epictetus/rust path: /src/test/run-pass/basic.rs // -*- rust -*- use std; import comm; import comm::send; import comm::chan; import comm::recv; import task; fn a(c: chan<int>) { if true { log "task a"; log "task a"; log "task a"; log "task a"; log "t...
code_fim
hard
{ "lang": "rust", "repo": "Epictetus/rust", "path": "/src/test/run-pass/basic.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn b(c: chan<int>) { if true { log "task b"; log "task b"; log "task b"; log "task b"; log "task b"; log "task b"; } send(c, 10); }<|fim_prefix|>// repo: Epictetus/rust path: /src/test/run-pass/basic.rs // -*- rust -*- use std; import comm; imp...
code_fim
hard
{ "lang": "rust", "repo": "Epictetus/rust", "path": "/src/test/run-pass/basic.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rodrigocfd/winsafe path: /src/oleaut/co.rs const_bitflag! { VT: u16; /// [`VARENUM`](https://learn.microsoft.com/en-us/windows/win32/api/wtypes/ne-wtypes-varenum) /// enumeration (`u16`). => => /// Nothing. EMPTY 0 /// SQL style NULL. NULL 1 /// 2 byte signed int. I2 2 /// ...
code_fim
hard
{ "lang": "rust", "repo": "rodrigocfd/winsafe", "path": "/src/oleaut/co.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/ Stream contains an object. STREAMED_OBJECT 68 /// Storage contains an object. STORED_OBJECT 69 /// Blob contains an object. BLOB_OBJECT 70 /// Clipboard format. CF 71 /// A class ID. CLSID 72 /// Stream with a GUID version. VERSIONED_STREAM 73 /// Reserved for system use. BSTR_...
code_fim
hard
{ "lang": "rust", "repo": "rodrigocfd/winsafe", "path": "/src/oleaut/co.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> &self.0 } } #[doc = "Field `RESRIE` writer - USB - Function Resume Request Interrupt Enable"] pub struct RESRIE_W<'a> { w: &'a mut W, } impl<'a> RESRIE_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } ...
code_fim
hard
{ "lang": "rust", "repo": "cr1901/msp430f5529", "path": "/src/usb_control/usbie.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cr1901/msp430f5529 path: /src/usb_control/usbie.rs #[doc = "Register `USBIE` reader"] pub struct R(crate::R<USBIE_SPEC>); impl core::ops::Deref for R { type Target = crate::R<USBIE_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Target { &self.0 } } impl From<crate::R<...
code_fim
hard
{ "lang": "rust", "repo": "cr1901/msp430f5529", "path": "/src/usb_control/usbie.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> &self.0 } } #[doc = "Field `SUSRIE` writer - USB - Function Suspend Request Interrupt Enable"] pub struct SUSRIE_W<'a> { w: &'a mut W, } impl<'a> SUSRIE_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } ...
code_fim
hard
{ "lang": "rust", "repo": "cr1901/msp430f5529", "path": "/src/usb_control/usbie.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 911-Borcani-Robert-Raul/money-manager path: /src/repo.rs use crate::domain; use std::collections::HashMap; use std::collections::hash_map; use std::fs::File; use std::io::{Write, BufReader, BufRead}; use std::num::ParseFloatError; use std::fmt; #[derive(Debug, Clone)] pub struct RepoEr...
code_fim
hard
{ "lang": "rust", "repo": "911-Borcani-Robert-Raul/money-manager", "path": "/src/repo.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match amount { Ok(amount) => { let current_currency_balance = domain::CurrencyBalance::new(current_currency, amount); self.currencies.insert(current_currency_balance.currency.id.clone(), current_currency_balance); }, ...
code_fim
hard
{ "lang": "rust", "repo": "911-Borcani-Robert-Raul/money-manager", "path": "/src/repo.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Buissonix/some-tank-game-rs path: /src/systems/health.rs use bevy::prelude::*; use crate::{ApplyDamageEvent, EffectType, Health, ThingBuilder, ThingType}; <|fim_suffix|> commands.spawn().insert(ThingBuilder { translation:transform.translation, ...
code_fim
hard
{ "lang": "rust", "repo": "Buissonix/some-tank-game-rs", "path": "/src/systems/health.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> commands.spawn().insert(ThingBuilder { translation:transform.translation, thing_type:ThingType::Effect(EffectType::Explosion), ..Default::default() }); } } } }<|fim_prefix|>// repo: Buissoni...
code_fim
hard
{ "lang": "rust", "repo": "Buissonix/some-tank-game-rs", "path": "/src/systems/health.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl PeerClient for TcpPeerClient { fn send_raw<T: AsRef<[u8]> + Send + 'static>( &self, data: T, ) -> BoxFuture<'static, Result<AlignedVec, std::io::Error>> { let pool = self.pool.clone(); self.connect() .then(move |tcp_stream| match tcp_stream { ...
code_fim
hard
{ "lang": "rust", "repo": "fleetfs/fleetfs", "path": "/src/client/peer_client.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug)] pub struct TcpPeerClient { server_ip_port: SocketAddr, pool: Arc<Mutex<Vec<TcpStream>>>, } async fn async_send_and_receive<T: AsRef<[u8]> + Send>( mut stream: TcpStream, data: T, pool: Arc<Mutex<Vec<TcpStream>>>, ) -> Result<AlignedVec, std::io::Error> { let mut r...
code_fim
hard
{ "lang": "rust", "repo": "fleetfs/fleetfs", "path": "/src/client/peer_client.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fleetfs/fleetfs path: /src/client/peer_client.rs use log::error; use std::net::SocketAddr; use crate::base::response_or_error; use crate::base::{CommitId, ErrorCode, RkyvRequest}; use byteorder::{ByteOrder, LittleEndian}; use futures::future::{ok, ready, BoxFuture, Either}; use futures::FutureE...
code_fim
hard
{ "lang": "rust", "repo": "fleetfs/fleetfs", "path": "/src/client/peer_client.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> match *self { ConnectionError::WebSocket(ref e) => e.description(), ConnectionError::Internal(ref s) => s, } } fn cause(&self) -> Option<&Error> { if let ConnectionError::WebSocket(ref e) = *self { Some(e) } else { No...
code_fim
hard
{ "lang": "rust", "repo": "qidian99/generals-rs", "path": "/src/connection.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl From<WebSocketError> for ConnectionError { fn from(err: WebSocketError) -> Self { ConnectionError::WebSocket(err) } } impl Error for ConnectionError { fn description(&self) -> &str { match *self { ConnectionError::WebSocket(ref e) => e.description(), ...
code_fim
hard
{ "lang": "rust", "repo": "qidian99/generals-rs", "path": "/src/connection.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: qidian99/generals-rs path: /src/connection.rs use std::collections::VecDeque; use std::error::Error; use std::fmt; use futures::stream::Stream; use futures::sync::mpsc::{channel, Receiver, Sender}; use futures::{Async, Sink}; use futures::{Future, Poll}; use tokio_io::{AsyncRead, AsyncWrite}; ...
code_fim
hard
{ "lang": "rust", "repo": "qidian99/generals-rs", "path": "/src/connection.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dmitryshur/notifier path: /scheduler/src/store.rs use crate::SchedulerErrors; use async_trait::async_trait; use serde::{Deserialize, Serialize}; use std::collections::HashMap; <|fim_suffix|>#[async_trait] pub trait Store { async fn load(&self) -> Result<HashMap<String, Record>, SchedulerErr...
code_fim
medium
{ "lang": "rust", "repo": "dmitryshur/notifier", "path": "/scheduler/src/store.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[async_trait] pub trait Store { async fn load(&self) -> Result<HashMap<String, Record>, SchedulerErrors>; async fn get(&self, id: &str) -> Result<Option<Record>, SchedulerErrors>; async fn add(&self, record: Record) -> Result<(), SchedulerErrors>; async fn update(&self, id: &str, chat_id:...
code_fim
medium
{ "lang": "rust", "repo": "dmitryshur/notifier", "path": "/scheduler/src/store.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: estelendur/budget-app path: /src/error.rs use chrono; use diesel; use diesel::r2d2; use serde_json; use std::error::Error as StdError; use std::fmt; #[derive(Debug)] pub enum Error { Msg(String), _Request(&'static str), NotFound, NotUnique, DatabasePool { source: r2d2::Er...
code_fim
hard
{ "lang": "rust", "repo": "estelendur/budget-app", "path": "/src/error.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match self.source() { Some(source) => write!(f, " - Source: {}", source), _ => Ok(()), } } } impl StdError for Error { fn description(&self) -> &str { "No description defined" } fn cause(&self) -> Option<&StdError> { match *self { ...
code_fim
hard
{ "lang": "rust", "repo": "estelendur/budget-app", "path": "/src/error.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Deserialize, Serialize, Debug)] pub struct SrpStep2Response { pub m2_str: String, }<|fim_prefix|>// repo: MoeAl-Ani/authentication_microservice path: /src/entities/srp/srp_entities.rs use serde::{Deserialize, Serialize}; use serde_json; #[derive(Deserialize, Serialize, Debug)] pub struct Li...
code_fim
hard
{ "lang": "rust", "repo": "MoeAl-Ani/authentication_microservice", "path": "/src/entities/srp/srp_entities.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }