text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: XuShaohua/nc path: /src/calls/setsid.rs /// Create a new session if the calling process is not a process group leader. /// /// <|fim_suffix|>fn setsid() -> Result<pid_t, Errno> { syscall0(SYS_SETSID).map(|ret| ret as pid_t) }<|fim_middle|># Example /// /// ``` /// let ret = unsafe { nc::sets...
code_fim
medium
{ "lang": "rust", "repo": "XuShaohua/nc", "path": "/src/calls/setsid.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[allow(unused)] impl<'a> #ident { const TOTAL_SUPPLY : u64 = #total_supply; const ISSUER : &'a str = #issuer; const ASSET_NAME : &'a str = #asset_name; const DESCRIPTION...
code_fim
hard
{ "lang": "rust", "repo": "morebtcg/liquid", "path": "/lang/macro/src/contract/codegen/contract/assets.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if asset.fungible { quote_spanned! {span => #[cfg_attr(test, derive(Debug))] pub struct #ident{ value: u64, stored: bool, from_self :bool, } ...
code_fim
hard
{ "lang": "rust", "repo": "morebtcg/liquid", "path": "/lang/macro/src/contract/codegen/contract/assets.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: morebtcg/liquid path: /lang/macro/src/contract/codegen/contract/assets.rs // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LIC...
code_fim
hard
{ "lang": "rust", "repo": "morebtcg/liquid", "path": "/lang/macro/src/contract/codegen/contract/assets.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn request_connection(&self, name: &str) -> Result<xous::CID, xous::Error> { let mut lookup_name = xous_ipc::String::<64>::new(); write!(lookup_name, "{}", name).expect("name problably too long"); let mut buf = Buffer::into_buf(lookup_name).or(Err(xous::Error::InternalErro...
code_fim
hard
{ "lang": "rust", "repo": "follower/xous-core", "path": "/services/xous-names/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut buf = Buffer::into_buf(lookup_name).or(Err(xous::Error::InternalError))?; buf.lend_mut(self.conn, api::Opcode::Lookup.to_u32().unwrap()) .or(Err(xous::Error::InternalError))?; match buf.to_original().unwrap() { api::Return::CID((cid, _)) => Ok(cid)...
code_fim
hard
{ "lang": "rust", "repo": "follower/xous-core", "path": "/services/xous-names/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: follower/xous-core path: /services/xous-names/src/lib.rs #![cfg_attr(target_os = "none", no_std)] //! Detailed docs are parked under Structs/XousNames down below pub mod api; use api::Disconnect; use core::fmt::Write; use num_traits::ToPrimitive; use xous_ipc::{Buffer, String}; #[doc = inclu...
code_fim
hard
{ "lang": "rust", "repo": "follower/xous-core", "path": "/services/xous-names/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ehntoo/bl702-pac path: /src/timer/tcdr.rs #[doc = "Register `TCDR` reader"] pub struct R(crate::R<TCDR_SPEC>); impl core::ops::Deref for R { type Target = crate::R<TCDR_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Target { &self.0 } } impl From<crate::R<TCDR_SPEC>> ...
code_fim
hard
{ "lang": "rust", "repo": "ehntoo/bl702-pac", "path": "/src/timer/tcdr.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> &self.0 } } #[doc = "Field `wcdr` writer - "] pub struct WCDR_W<'a> { w: &'a mut W, } impl<'a> WCDR_W<'a> { #[doc = r"Writes raw bits to the field"] #[inline(always)] pub unsafe fn bits(self, value: u8) -> &'a mut W { self.w.bits = (self.w.bits & !(0xff << 24)) | ((valu...
code_fim
hard
{ "lang": "rust", "repo": "ehntoo/bl702-pac", "path": "/src/timer/tcdr.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ukdataservice/qamd path: /src/model/variable.rs use readstat::bindings::*; use std::ffi::CStr; use std::os::raw::c_char; use std::ptr; #[derive(Serialize, Debug, Clone, Hash, PartialEq, Eq)] pub struct Variable { pub index: i32, pub name: String, pub label: String, pub type_: V...
code_fim
hard
{ "lang": "rust", "repo": "ukdataservice/qamd", "path": "/src/model/variable.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl std::fmt::Debug for VariableType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { match self { VariableType::Text => write!(f, "String"), VariableType::Numeric => write!(f, "Numeric"), } } } impl From<readstat_type_t> for VariableType...
code_fim
hard
{ "lang": "rust", "repo": "ukdataservice/qamd", "path": "/src/model/variable.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Alex-Addy/Fe2O3 path: /src/modules/id.rs use utils::{Message, make_reply}; pub fn id_module(msg: &Message) -> Vec<String> { <|fim_suffix|>ts_with("!id ") { let arg = msg.params[1].split("!id ").last().unwrap(); vec![make_reply(msg, arg).to_string()] } else { ...
code_fim
medium
{ "lang": "rust", "repo": "Alex-Addy/Fe2O3", "path": "/src/modules/id.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>ts_with("!id ") { let arg = msg.params[1].split("!id ").last().unwrap(); vec![make_reply(msg, arg).to_string()] } else { vec![] } }<|fim_prefix|>// repo: Alex-Addy/Fe2O3 path: /src/modules/id.rs use utils::{Message, make_reply}; pub fn id_module(msg: &Message) ->...
code_fim
medium
{ "lang": "rust", "repo": "Alex-Addy/Fe2O3", "path": "/src/modules/id.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> vec![make_reply(msg, arg).to_string()] } else { vec![] } }<|fim_prefix|>// repo: Alex-Addy/Fe2O3 path: /src/modules/id.rs use utils::{Message, make_reply}; pub fn id_module(msg: &Message) -> Vec<String> { if msg.command == "PRIVMSG" && msg.params.len() == 2 && ms...
code_fim
medium
{ "lang": "rust", "repo": "Alex-Addy/Fe2O3", "path": "/src/modules/id.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: LeonidErmak/nearapps path: /LogAnalytics/contract/src/lib.rs use std::str; use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize}; use near_sdk::serde::Serialize; use near_sdk::{env, near_bindgen}; <|fim_suffix|>#[near_bindgen] #[derive(BorshDeserialize, BorshSerialize, Default, Seriali...
code_fim
medium
{ "lang": "rust", "repo": "LeonidErmak/nearapps", "path": "/LogAnalytics/contract/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[near_bindgen] #[derive(BorshDeserialize, BorshSerialize, Default, Serialize)] #[serde(crate = "near_sdk::serde")] pub struct Call {} #[near_bindgen] impl Call { pub fn log_analytics(encoded: String) { let call_encoded: Vec<&str> = encoded.split('_').collect(); let mut call_decoded: V...
code_fim
medium
{ "lang": "rust", "repo": "LeonidErmak/nearapps", "path": "/LogAnalytics/contract/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> state.get_view_combo_box().connect_changed( clone!(@strong state => move |_| { handle_select_view_style(&state); }), ); } pub fn disable(state: &ui::State) { state.get_search_entry().set_sensitive(false); state.get_search_button().set_sensitive(false); stat...
code_fim
hard
{ "lang": "rust", "repo": "cdepillabout/nix-query-tree-viewer", "path": "/src/ui/toolbar.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn enable(state: &ui::State) { state.get_search_entry().set_sensitive(true); state.get_search_button().set_sensitive(true); state.get_sort_combo_box().set_sensitive(true); } pub fn setup(state: &ui::State) { connect_signals(state); }<|fim_prefix|>// repo: cdepillabout/nix-query-tree-v...
code_fim
hard
{ "lang": "rust", "repo": "cdepillabout/nix-query-tree-viewer", "path": "/src/ui/toolbar.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cdepillabout/nix-query-tree-viewer path: /src/ui/toolbar.rs use super::prelude::*; use glib::clone; use super::super::ui; fn handle_search(state: &ui::State) { let search_entry = state.get_search_entry(); let search_text = search_entry.get_buffer().get_text(); ui::search_for(state...
code_fim
medium
{ "lang": "rust", "repo": "cdepillabout/nix-query-tree-viewer", "path": "/src/ui/toolbar.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tristan-zander/advent_of_code_2020 path: /day1/src/main.rs use std::fs::File; use std::{collections::HashMap, io::Read}; fn main() { let mut buf = String::new(); let mut input = Vec::<i32>::new(); let mut file = File::open("input").unwrap(); let _lines_read = file.read_to_string...
code_fim
hard
{ "lang": "rust", "repo": "tristan-zander/advent_of_code_2020", "path": "/day1/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Key: opposite, Value: number let mut hash = HashMap::<i32, i32>::new(); for &num in input.iter() { let opposite = 2020 - num; if let Some(_) = hash.get(&num) { answer1 = num; answer2 = opposite; break; } hash.insert(opposit...
code_fim
medium
{ "lang": "rust", "repo": "tristan-zander/advent_of_code_2020", "path": "/day1/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ry3s/atcoder path: /hhkb2020/d.rs use std::io::{stdin, Read, StdinLock}; use std::str::FromStr; #[allow(dead_code)] struct Scanner<'a> { cin: StdinLock<'a>, } #[allow(dead_code)] impl<'a> Scanner<'a> { fn new(cin: StdinLock<'a>) -> Scanner<'a> { Scanner { cin: cin } } f...
code_fim
hard
{ "lang": "rust", "repo": "ry3s/atcoder", "path": "/hhkb2020/d.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn zero() -> ModInt { ModInt(0) } fn one() -> ModInt { ModInt(1) } fn pow(self, mut n: usize) -> ModInt { let mut ret = ModInt::one(); let mut x = self; while n > 0 { if n & 1 == 1 { ret *= x; } ...
code_fim
hard
{ "lang": "rust", "repo": "ry3s/atcoder", "path": "/hhkb2020/d.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn inv(self) -> ModInt { assert!(self.0 > 0); self.pow(MOD - 2) } } impl std::ops::Add for ModInt { type Output = ModInt; fn add(self, rhs: ModInt) -> Self::Output { let mut d = self.0 + rhs.0; if d >= MOD { d -= MOD; } ModInt(d)...
code_fim
hard
{ "lang": "rust", "repo": "ry3s/atcoder", "path": "/hhkb2020/d.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: davethecanuck/rust-bitfoo path: /src/tests/addr_test.rs #[cfg(test)] use crate::Addr; #[test] fn addr_to_bitno() { for bitno in vec![0, 1, 0x3f_ff, 0x3f_ff_ff, u64::MAX] { let addr = Addr::new(bitno); assert_eq!(bitno, addr.bitno()); } } #[test] fn clone() { let inp...
code_fim
hard
{ "lang": "rust", "repo": "davethecanuck/rust-bitfoo", "path": "/src/tests/addr_test.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Level 1 node for level in 1_u8..=8 { for bitno in &[first, last] { // Verify the level let addr = Addr::new(*bitno); assert_eq!(level, addr.node_level); // Verify keys at each level assert_eq!(bitno & 0x3f, addr.key(0) as u64...
code_fim
hard
{ "lang": "rust", "repo": "davethecanuck/rust-bitfoo", "path": "/src/tests/addr_test.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: webclinic017/ib_client path: /src/models/calendar_request_date.rs /* * Client Portal Web API * * Client Portal Web API * * The version of the OpenAPI document: 1.0.0 * * Generated by: https://openapi-generator.tech */ <|fim_suffix|>impl CalendarRequestDate { pub fn new() -> Calen...
code_fim
hard
{ "lang": "rust", "repo": "webclinic017/ib_client", "path": "/src/models/calendar_request_date.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl CalendarRequestDate { pub fn new() -> CalendarRequestDate { CalendarRequestDate { start: None, end: None, } } }<|fim_prefix|>// repo: webclinic017/ib_client path: /src/models/calendar_request_date.rs /* * Client Portal Web API * * Client Portal Web ...
code_fim
hard
{ "lang": "rust", "repo": "webclinic017/ib_client", "path": "/src/models/calendar_request_date.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IceSentry/godot-rust-template-test path: /rust/src/lib.rs mod hud; mod main_scene; mod mob; mod player; mod utils; use gdnative:<|fim_suffix|>_scene::Main>(); handle.add_class::<hud::Hud>(); } godot_init!(init);<|fim_middle|>:prelude::*; fn init(handle: InitHandle) { handle.add...
code_fim
medium
{ "lang": "rust", "repo": "IceSentry/godot-rust-template-test", "path": "/rust/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>Player>(); handle.add_class::<mob::Mob>(); handle.add_class::<main_scene::Main>(); handle.add_class::<hud::Hud>(); } godot_init!(init);<|fim_prefix|>// repo: IceSentry/godot-rust-template-test path: /rust/src/lib.rs mod hud; mod main_scene; mod mob; mod player; mod utils; use gdnati...
code_fim
medium
{ "lang": "rust", "repo": "IceSentry/godot-rust-template-test", "path": "/rust/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: m0riiiii/rust_practice path: /semantics/semantics_4_9/src/main.rs struct Foo<'a> { x: &'a i32, } static FOO: i32 = 5; <|fim_suffix|> println!("{}",x); let x: &'static i32 = &FOO; println!("{}",x); } // 黙示的に fn _foo(_x: &i32) { } // 明示的に fn _bar<'a>(_x: &'a i32) { }<|fim_midd...
code_fim
medium
{ "lang": "rust", "repo": "m0riiiii/rust_practice", "path": "/semantics/semantics_4_9/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let x: &'static i32 = &FOO; println!("{}",x); } // 黙示的に fn _foo(_x: &i32) { } // 明示的に fn _bar<'a>(_x: &'a i32) { }<|fim_prefix|>// repo: m0riiiii/rust_practice path: /semantics/semantics_4_9/src/main.rs struct Foo<'a> { x: &'a i32, } static FOO: i32 = 5; fn main() { <|fim_middle|> let...
code_fim
medium
{ "lang": "rust", "repo": "m0riiiii/rust_practice", "path": "/semantics/semantics_4_9/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: emmericp/advent-of-code-2019 path: /src/bin/day3.rs use std::fs::File; use std::io::{BufReader, BufRead}; fn main() { let file = File::open("./input/day3.txt").unwrap(); let mut reader = BufReader::new(file); let mut line1 = String::new(); let mut line2 = String::new(); read...
code_fim
hard
{ "lang": "rust", "repo": "emmericp/advent-of-code-2019", "path": "/src/bin/day3.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn test_draw() { assert_eq!(draw_segments(vec![("R", 8), ("U", 5), ("L", 5), ("D", 3)]), vec![ LineSegment { direction: SegmentDirection::HORIZONTAL, inverted: false, pos: 0, start: 0, end: 8, steps: 8, }, ...
code_fim
hard
{ "lang": "rust", "repo": "emmericp/advent-of-code-2019", "path": "/src/bin/day3.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// A map of information about the user running the command. pub user_info: UserInfo, /// A map of information about the command being run. pub command_info: CommandInfo, /// A map of the user's environment variables. pub user_env: OptionMap, /// A map of options provided to...
code_fim
hard
{ "lang": "rust", "repo": "LevyForchh/sudo_pair", "path": "/sudo_plugin/src/plugin/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: LevyForchh/sudo_pair path: /sudo_plugin/src/plugin/mod.rs // Copyright 2018 Square Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache....
code_fim
hard
{ "lang": "rust", "repo": "LevyForchh/sudo_pair", "path": "/sudo_plugin/src/plugin/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn flush(&mut self) -> io::Result<()> { self.0.flush() } } /// /// A facility implementing `std::io::Write` that allows printing /// output to the user invoking `sudo`. Technically, the user may /// not be present on a local tty, but this will be wired up to a /// `printf`-like function t...
code_fim
hard
{ "lang": "rust", "repo": "LevyForchh/sudo_pair", "path": "/sudo_plugin/src/plugin/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: timsaucer/RustDDS path: /src/discovery/content_filter_property.rs use serde::{Serialize, Deserialize}; use crate::structure::parameter_id::ParameterId; /// The ContentFilterProperty field provides all the required information to /// enable content filtering on the Writer side. For example, for ...
code_fim
hard
{ "lang": "rust", "repo": "timsaucer/RustDDS", "path": "/src/discovery/content_filter_property.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Serialize, Deserialize)] pub struct ContentFilterPropertyData { parameter_id: ParameterId, parameter_length: u16, content_filter_property: ContentFilterProperty, } impl ContentFilterPropertyData { pub fn new(content_filter_property: &ContentFilterProperty) -> ContentFilterPropertyData { ...
code_fim
hard
{ "lang": "rust", "repo": "timsaucer/RustDDS", "path": "/src/discovery/content_filter_property.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut parameter_length = len_cftn + len_rtn + len_fcn + len_fe; for param in content_filter_property.expressionParameters.iter() { let len_temp = param.len(); let len_temp = len_temp + (4 - len_temp % 4) + 4; parameter_length = parameter_length + len_temp; } parameter_...
code_fim
hard
{ "lang": "rust", "repo": "timsaucer/RustDDS", "path": "/src/discovery/content_filter_property.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> assert!(with_points_removed.len() > 0); } #[test] fn remove_interior_points_complex_2() { let path = BezierPathBuilder::<SimpleBezierPath>::start(Coord2(589.8298950195313, 841.699951171875)) .curve_to((Coord2(589.8298950195313, 841.699951171875), Coord2(589.8298950195313, 841.699951171875...
code_fim
hard
{ "lang": "rust", "repo": "Logicalshift/flo_curves", "path": "/tests/bezier/path/arithmetic_complicated_paths.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Logicalshift/flo_curves path: /tests/bezier/path/arithmetic_complicated_paths.rs as generated an error that indicates that no result path was generated (unfortunately it seems this version does not produce the error) let without_interior_points = path_remove_interior_points::<_, SimpleBezier...
code_fim
hard
{ "lang": "rust", "repo": "Logicalshift/flo_curves", "path": "/tests/bezier/path/arithmetic_complicated_paths.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Logicalshift/flo_curves path: /tests/bezier/path/arithmetic_complicated_paths.rs oord2(604.8263549804688, 851.1680908203125), Coord2(599.0707397460938, 843.4915161132813)), Coord2(593.83251953125, 839.4678955078125)) .curve_to((Coord2(588.12841796875, 843.3626708984375), Coord2(584.95806...
code_fim
hard
{ "lang": "rust", "repo": "Logicalshift/flo_curves", "path": "/tests/bezier/path/arithmetic_complicated_paths.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: erikjohnston/tk-postgres-pool path: /src/lib.rs #![feature(conservative_impl_trait)] #![allow(unused_imports, dead_code)] #[macro_use] extern crate futures; #[macro_use] extern crate tokio_core; extern crate postgres_protocol; extern crate tk_bufstream; extern crate linear_map; #[macro_use] ext...
code_fim
hard
{ "lang": "rust", "repo": "erikjohnston/tk-postgres-pool", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<C> Future for ConnectionPool<C> where C: ConnectionFactory + 'static, C::Item: PostgresConnection { type Item = (); type Error = (); fn poll(&mut self) -> Result<Async<()>, ()> { while { self.poll_receiver() || self.poll_new_connections() || self.poll_op...
code_fim
hard
{ "lang": "rust", "repo": "erikjohnston/tk-postgres-pool", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let s0 = s0.parse::<i32>()?; let s1 = s1.parse::<i32>()?; Ok(s0 + s1) } fn main() {}<|fim_prefix|>// repo: kdnk-sandbox/rust_introduction path: /src/05_user_defined_types/04_result.rs #[test] fn result_test() { assert_eq!("10".parse::<i32>(), Ok(10)); let res0 = "a".parse::<i32>(); ...
code_fim
medium
{ "lang": "rust", "repo": "kdnk-sandbox/rust_introduction", "path": "/src/05_user_defined_types/04_result.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn add0(s0: &str, s1: &str) -> Result<i32, std::num::ParseIntError> { let s0 = s0.parse::<i32>()?; let s1 = s1.parse::<i32>()?; Ok(s0 + s1) } fn main() {}<|fim_prefix|>// repo: kdnk-sandbox/rust_introduction path: /src/05_user_defined_types/04_result.rs #[test] fn result_test() { assert_...
code_fim
medium
{ "lang": "rust", "repo": "kdnk-sandbox/rust_introduction", "path": "/src/05_user_defined_types/04_result.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kdnk-sandbox/rust_introduction path: /src/05_user_defined_types/04_result.rs #[test] fn result_test() { assert_eq!("10".parse::<i32>(), Ok(10)); let res0 = "a".parse::<i32>(); assert!(res0.is_err()); println!("{:?}", res0); assert_eq!(add0("0", "127"), Ok(127)); assert!(...
code_fim
medium
{ "lang": "rust", "repo": "kdnk-sandbox/rust_introduction", "path": "/src/05_user_defined_types/04_result.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(::std::mem::size_of::<U>() , 1usize , concat ! ( "Size of: " , stringify ! ( U ) )); assert_eq! (::std::mem::align_of::<U>() , 1usize , concat ! ( "Alignment of " , stringify ! ( U ) )); } impl Clone for U { fn clone(&self) -> Self { *self } }<|fim_pre...
code_fim
medium
{ "lang": "rust", "repo": "tmfink/rust-bindgen", "path": "/tests/expectations/tests/issue-834.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tmfink/rust-bindgen path: /tests/expectations/tests/issue-834.rs /* automatically generated by rust-bindgen */ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] <|fim_suffix|> assert_eq!(::std::mem::size_of::<U>() , 1usize , concat ! ( "Size ...
code_fim
medium
{ "lang": "rust", "repo": "tmfink/rust-bindgen", "path": "/tests/expectations/tests/issue-834.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: karjonas/advent-of-code path: /2021/day19/src/lib.rs extern crate common; #[macro_use] extern crate scan_fmt; use std::ops::Add; use std::ops::Sub; #[derive(Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Hash)] struct Point { x: i32, y: i32, z: i32, } impl Add for Point { ...
code_fim
hard
{ "lang": "rust", "repo": "karjonas/advent-of-code", "path": "/2021/day19/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests { use super::*; #[test] fn test_samples() { let input = "--- scanner 0 --- 404,-588,-901 528,-643,409 -838,591,734 390,-675,-793 -537,-823,-458 -485,-357,347 -345,-311,381 -661,-816,-575 -876,649,763 -618,-824,-621 553,345,-567 474,580,667 -447,-329,318 -584,868...
code_fim
hard
{ "lang": "rust", "repo": "karjonas/advent-of-code", "path": "/2021/day19/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn id(&self) -> usize { self._id } }<|fim_prefix|>// repo: andriy-kuz/coursera_bitcoin path: /consensus_from_trust/src/transaction.rs #[derive(Hash, Eq, PartialEq, Debug, Clone)] pub struct Transaction { _id: usize, } <|fim_middle|>impl Transaction { pub fn new(id: u...
code_fim
medium
{ "lang": "rust", "repo": "andriy-kuz/coursera_bitcoin", "path": "/consensus_from_trust/src/transaction.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: andriy-kuz/coursera_bitcoin path: /consensus_from_trust/src/transaction.rs #[derive(Hash, Eq, PartialEq, Debug, Clone)] pub struct Transaction { _id: usize, } <|fim_suffix|> pub fn id(&self) -> usize { self._id } }<|fim_middle|>impl Transaction { pub fn new(id: u...
code_fim
medium
{ "lang": "rust", "repo": "andriy-kuz/coursera_bitcoin", "path": "/consensus_from_trust/src/transaction.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut system = System::new(); let (out_port, out_chan) = stream(); let actor_ref = system.add_actor_from_chan(out_chan, (), |_| { MyActor }); actor_ref.chan.send(1); actor_ref.chan.send(2); assert_eq!(1 , out_port.recv()); assert_eq!(2 , out_port.recv()); } #[test] fn test_...
code_fim
hard
{ "lang": "rust", "repo": "nielsle/rust-actor-experiments", "path": "/src/actor/system.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nielsle/rust-actor-experiments path: /src/actor/system.rs use actor::{SurviveOrDie, Survive, Die, Actor}; use actorref::{ActorRefWithStream, ActorRefWithChan, ActorRefWithPort, ActorRefWithoutPortAndChan}; use std::cell::Cell; // use std::vec::{append_one}; /// A system of act...
code_fim
hard
{ "lang": "rust", "repo": "nielsle/rust-actor-experiments", "path": "/src/actor/system.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_add_actor_from_port_and_chan() { struct MyActor; impl Actor<int, int, Chan<int>> for MyActor { fn on_receive(&mut self, msg: int, chan: &Chan<int>) -> SurviveOrDie { chan.send(msg); Survive } } let mut system = System::new(); ...
code_fim
hard
{ "lang": "rust", "repo": "nielsle/rust-actor-experiments", "path": "/src/actor/system.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DanielMena399/cc1312take3 path: /cc1312/src/sram_mmr/per_ctl.rs #[doc = "Reader of register PER_CTL"] pub type R = crate::R<u32, super::PER_CTL>; #[doc = "Writer for register PER_CTL"] pub type W = crate::W<u32, super::PER_CTL>; #[doc = "Register PER_CTL `reset()`'s with value 0"] impl crate::Re...
code_fim
hard
{ "lang": "rust", "repo": "DanielMena399/cc1312take3", "path": "/cc1312/src/sram_mmr/per_ctl.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>ABLE_W<'a> { w: &'a mut W, } impl<'a> PER_DEBUG_ENABLE_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self...
code_fim
hard
{ "lang": "rust", "repo": "DanielMena399/cc1312take3", "path": "/cc1312/src/sram_mmr/per_ctl.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Graviton-Code-Editor/Graviton-App path: /extensions/git/src/lib.rs use std::sync::Arc; use git2::{Error, Repository, StatusOptions}; use gveditor_core_api::extensions::base::{Extension, ExtensionInfo}; use gveditor_core_api::extensions::client::ExtensionClient; use gveditor_core_api::extensions...
code_fim
hard
{ "lang": "rust", "repo": "Graviton-Code-Editor/Graviton-App", "path": "/extensions/git/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Answer with the file states if let Ok(files_states) = files_states { message = FromExtension::FilesState { path, files_states }; } // Send the message send_message_to_client(client, state_id, extension_...
code_fim
hard
{ "lang": "rust", "repo": "Graviton-Code-Editor/Graviton-App", "path": "/extensions/git/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: XBagon/dawrs path: /src/effect/delay.rs use super::Effect; use crate::{PolySample, SampleTiming}; use std::collections::VecDeque; #[derive(Clone, Default)] pub struct Delay { pub delay: f32, pub feedback: f32, buffer: VecDeque<PolySample>, } <|fim_suffix|>impl Effect for Delay { ...
code_fim
medium
{ "lang": "rust", "repo": "XBagon/dawrs", "path": "/src/effect/delay.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let buffer_size = sample_timing.duration_to_sample_count(self.delay); if self.buffer.len() == buffer_size { poly_sample += self.buffer.pop_front().unwrap(); } self.buffer.push_back(poly_sample.clone() * self.feedback); poly_sample } }<|fim_prefix|>//...
code_fim
hard
{ "lang": "rust", "repo": "XBagon/dawrs", "path": "/src/effect/delay.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: maxtnuk/gluesql path: /storages/memory-storage/src/lib.rs #![deny(clippy::str_to_string)] mod alter_table; mod index; mod transaction; use { async_trait::async_trait, gluesql_core::{ data::{Key, Schema}, result::Result, store::{DataRow, RowIter, Store, StoreMut}...
code_fim
hard
{ "lang": "rust", "repo": "maxtnuk/gluesql", "path": "/storages/memory-storage/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Ok(()) } async fn insert_data(&mut self, table_name: &str, rows: Vec<(Key, DataRow)>) -> Result<()> { if let Some(item) = self.items.get_mut(table_name) { for (key, row) in rows { item.rows.insert(key, row); } } Ok(()) }...
code_fim
hard
{ "lang": "rust", "repo": "maxtnuk/gluesql", "path": "/storages/memory-storage/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> async fn insert_data(&mut self, table_name: &str, rows: Vec<(Key, DataRow)>) -> Result<()> { if let Some(item) = self.items.get_mut(table_name) { for (key, row) in rows { item.rows.insert(key, row); } } Ok(()) } async fn delete_...
code_fim
hard
{ "lang": "rust", "repo": "maxtnuk/gluesql", "path": "/storages/memory-storage/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut offset = 0u64; hr!(result_get_offset(self.handle(), &mut offset))?; Ok(Duration::from_nanos(offset * 100)) } } /// Speech-to-text result. pub trait SpeechResult: RecognitionResult { /// Normalized text generated by a speech recognition engine from recognized input....
code_fim
hard
{ "lang": "rust", "repo": "garyhai/luis_sys", "path": "/src/speech/events.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: garyhai/luis_sys path: /src/speech/events.rs sult_NoMatchReason_NoMatchReason_InitialSilenceTimeout => { Matching::InitialSilenceTimeout } Result_NoMatchReason_NoMatchReason_InitialBabbleTimeout => { Matching::InitialBabbleTimeout ...
code_fim
hard
{ "lang": "rust", "repo": "garyhai/luis_sys", "path": "/src/speech/events.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Event may produce result or error. pub struct EventResult { reason: Flags, handle: SPXRESULTHANDLE, props: Properties, } impl EventResult { /// Create result with event source flag, then patch the flag with reason. pub fn new(flag: Flags, handle: SPXRESULTHANDLE) -> Result<Self> {...
code_fim
hard
{ "lang": "rust", "repo": "garyhai/luis_sys", "path": "/src/speech/events.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let payload: originsrv::AccessToken = match message::decode(&bytes) { Ok(p) => p, Err(e) => { warn!("Unable to deserialize access token, err={:?}", e); return Err(Error::TokenInvalid); } }; if payload.get_account_id() == BUILDER_ACCOUNT_ID { ...
code_fim
hard
{ "lang": "rust", "repo": "jonsmorrow/builder", "path": "/components/builder-core/src/access_token.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub fn is_access_token(token: &str) -> bool { token.starts_with(ACCESS_TOKEN_PREFIX) } pub fn validate_access_token(key_dir: &PathBuf, token: &str) -> Result<originsrv::Session> { assert!(is_access_token(token)); let bytes = decrypt(key_dir, &token[ACCESS_TOKEN_PREFIX.len()..])?; let payloa...
code_fim
hard
{ "lang": "rust", "repo": "jonsmorrow/builder", "path": "/components/builder-core/src/access_token.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jonsmorrow/builder path: /components/builder-core/src/access_token.rs // Copyright (c) 2017 Chef Software Inc. and/or applicable contributors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtai...
code_fim
hard
{ "lang": "rust", "repo": "jonsmorrow/builder", "path": "/components/builder-core/src/access_token.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug, Clone, PartialEq, Eq)] pub struct BootMessage { pub version: String, pub device_id: String, pub systick: u64, pub mode: Mode, pub value128: u8, } #[derive(Debug, Clone, PartialEq, Eq)] pub struct StoppedMessage { pub version: String, pub device_id: String, ...
code_fim
hard
{ "lang": "rust", "repo": "yannbertrand/covid-respirator", "path": "/src/software/telemetry/src/structures.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yannbertrand/covid-respirator path: /src/software/telemetry/src/structures.rs // MakAir // // Copyright: 2020, Makers For Life // License: Public Domain License #[derive(Debug, Clone, PartialEq, Eq)] pub enum Mode { Production, Qualification, IntegrationTest, } #[derive(Debug, Clon...
code_fim
hard
{ "lang": "rust", "repo": "yannbertrand/covid-respirator", "path": "/src/software/telemetry/src/structures.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: slowli/arithmetic-parser path: /eval/src/compiler/mod.rs //! Transformation of AST output by the parser into non-recursive format. use crate::{ alloc::{Box, HashMap, String, ToOwned, Vec}, exec::{ Atom, Command, CompiledExpr, Executable, ExecutableModule, FieldName, ModuleId, Re...
code_fim
hard
{ "lang": "rust", "repo": "slowli/arithmetic-parser", "path": "/eval/src/compiler/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Lvalue::Tuple(destructure) => { let span = lhs.with_no_extra(); self.destructure(executable, destructure, span, rhs_register)?; } Lvalue::Object(destructure) => { let span = lhs.with_no_extra(); self.destr...
code_fim
hard
{ "lang": "rust", "repo": "slowli/arithmetic-parser", "path": "/eval/src/compiler/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sebastian-xyz/nushell path: /crates/nu-cli/src/lib.rs mod completions; mod errors; mod nu_highlight; mod print; mod prompt; mod syntax_highlight; m<|fim_suffix|>nu_highlight::NuHighlight; pub use print::Print; pub use prompt::NushellPrompt; pub use syntax_highlight::NuHighlighter; pub use util::...
code_fim
medium
{ "lang": "rust", "repo": "sebastian-xyz/nushell", "path": "/crates/nu-cli/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>_highlight::NuHighlighter; pub use util::print_pipeline_data; pub use validation::NuValidator;<|fim_prefix|>// repo: sebastian-xyz/nushell path: /crates/nu-cli/src/lib.rs mod completions; mod errors; mod nu_highlight; mod print; mod prompt; mod syntax_highlight; m<|fim_middle|>od util; mod validation; p...
code_fim
medium
{ "lang": "rust", "repo": "sebastian-xyz/nushell", "path": "/crates/nu-cli/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pete21/tickgrinder path: /util/src/transport/tickstream/sinks/null_sink.rs //! Pipes data into the abyss. #[allow(unused_imports)] use test; use trading::tick::Tick; use transport::tickstream::TickSink; pub struct NullSink {} <|fim_suffix|> let mut ns = NullSink{}; let t = Tick::null...
code_fim
hard
{ "lang": "rust", "repo": "pete21/tickgrinder", "path": "/util/src/transport/tickstream/sinks/null_sink.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>} /// I'd like to imagine this is optimized out but you never know... #[bench] fn null_sink(b: &mut test::Bencher) { let mut ns = NullSink{}; let t = Tick::null(); b.iter(|| ns.tick(t)) }<|fim_prefix|>// repo: pete21/tickgrinder path: /util/src/transport/tickstream/sinks/null_sink.rs //! Pip...
code_fim
medium
{ "lang": "rust", "repo": "pete21/tickgrinder", "path": "/util/src/transport/tickstream/sinks/null_sink.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[doc = r"Writes raw bits to the field"] #[inline(always)] pub unsafe fn bits(self, value: u16) -> &'a mut W { self.w.bits = (self.w.bits & !(0xffff << 16)) | (((value as u32) & 0xffff) << 16); self.w } } impl R { #[doc = "Bits 0:15 - Touch Sensing Channel High Threshold va...
code_fim
hard
{ "lang": "rust", "repo": "debilausaure/MK20D7", "path": "/src/tsi0/threshold.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: debilausaure/MK20D7 path: /src/tsi0/threshold.rs #[doc = "Reader of register THRESHOLD"] pub type R = crate::R<u32, super::THRESHOLD>; #[doc = "Writer for register THRESHOLD"] pub type W = crate::W<u32, super::THRESHOLD>; #[doc = "Register THRESHOLD `reset()`'s with value 0"] impl crate::ResetVa...
code_fim
hard
{ "lang": "rust", "repo": "debilausaure/MK20D7", "path": "/src/tsi0/threshold.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Key operations are allowed"] #[inline(always)] pub fn allowsetkey(&self) -> ALLOWSETKEY_R { ALLOWSETKEY_R::new(((self.bits >> 2) & 0x01) != 0) } #[doc = "Bit 3 - Get Key operation is allowed"] #[inline(always)] pub fn allowgetkey(&self) -> ALLOWGETKEY_R { ALLOWGETK...
code_fim
hard
{ "lang": "rust", "repo": "nickray/lpc55-pac", "path": "/src/puf/allow.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nickray/lpc55-pac path: /src/puf/allow.rs #[doc = "Reader of register ALLOW"] pub type R = crate::R<u32, super::ALLOW>; #[doc = "Writer for register ALLOW"] pub type W = crate::W<u32, super::ALLOW>; #[doc = "Register ALLOW `reset()`'s with value 0"] impl crate::ResetValue for super::ALLOW { ...
code_fim
hard
{ "lang": "rust", "repo": "nickray/lpc55-pac", "path": "/src/puf/allow.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match run::run() { Ok(_) => process::exit(0), Err(e) => { eprintln!("{}", e); process::exit(1); } } }<|fim_prefix|>// repo: 0xAB41/namethingy path: /src/bin/namethingy/main.rs use std::process; mod run; mod args; <|fim_middle|>fn main() {
code_fim
easy
{ "lang": "rust", "repo": "0xAB41/namethingy", "path": "/src/bin/namethingy/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 0xAB41/namethingy path: /src/bin/namethingy/main.rs use std::process; mod run; mod args; <|fim_suffix|> match run::run() { Ok(_) => process::exit(0), Err(e) => { eprintln!("{}", e); process::exit(1); } } }<|fim_middle|>fn main() {
code_fim
easy
{ "lang": "rust", "repo": "0xAB41/namethingy", "path": "/src/bin/namethingy/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> while x >= y { points.push((self.x + x, self.y + y)); points.push((self.x + y, self.y + x)); points.push((self.x - y, self.y + x)); points.push((self.x - x, self.y + y)); points.push((self.x - x, self.y - y)); points.push((sel...
code_fim
hard
{ "lang": "rust", "repo": "ivanceras/ito-canvas", "path": "/crates/dot-canvas/src/circle.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let radius = 10.0; let mut context = Context::new(radius * 2.0, radius * 2.0); context.draw(&Circle { x: radius, y: radius, radius, }); let result = context.to_string(); println!("{}", result); let expected = [ ...
code_fim
hard
{ "lang": "rust", "repo": "ivanceras/ito-canvas", "path": "/crates/dot-canvas/src/circle.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ivanceras/ito-canvas path: /crates/dot-canvas/src/circle.rs use crate::Shape; pub struct Circle { pub x: f32, pub y: f32, pub radius: f32, } impl Circle { pub fn new(x: f32, y: f32, radius: f32) -> Self { Circle { x, y, radius } } } impl<'a> Shape<'a> for Circle { ...
code_fim
hard
{ "lang": "rust", "repo": "ivanceras/ito-canvas", "path": "/crates/dot-canvas/src/circle.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn from_request(req: &HttpRequest, _payload: &mut Payload) -> Self::Future { let ip = match req.peer_addr() { Some(peer_addr) => Some(peer_addr.ip().to_string()), _ => None, }; let agent = match req.headers().get("Agent") { Some(agent_header)...
code_fim
medium
{ "lang": "rust", "repo": "henryv11/auth-rust", "path": "/src/request_data.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: henryv11/auth-rust path: /src/request_data.rs use actix_web::{dev::Payload, error::ResponseError, FromRequest, HttpRequest}; use futures::future::{ok, Ready}; use thiserror::Error as ThisError; #[derive(ThisError, Debug)] pub enum Error {} impl ResponseError for Error {} <|fim_suffix|> ...
code_fim
hard
{ "lang": "rust", "repo": "henryv11/auth-rust", "path": "/src/request_data.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn find_root(v: &mut Vec<usize>, i: usize) -> usize { if i == v[i] { return v[i]; } v[i] = Solution::find_root(v, v[i]); v[i] } }<|fim_prefix|>// repo: xanahopper/leetcode path: /src/leetcode/biweekly/biweekly_81_2.rs use std::collections::HashMap; use ...
code_fim
hard
{ "lang": "rust", "repo": "xanahopper/leetcode", "path": "/src/leetcode/biweekly/biweekly_81_2.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xanahopper/leetcode path: /src/leetcode/biweekly/biweekly_81_2.rs use std::collections::HashMap; use crate::leetcode::Solution; #[test] fn biweekly_81_2_test() { assert_eq!(Solution::count_pairs(3, vec![vec![0,1],vec![0,2],vec![1,2]]), 0); assert_eq!(Solution::count_pairs(1, vec![]), 0)...
code_fim
hard
{ "lang": "rust", "repo": "xanahopper/leetcode", "path": "/src/leetcode/biweekly/biweekly_81_2.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lamnot/TPS-API-Reference-Implementations path: /rs_minicbor/examples/decode.rs /*************************************************************************************************** * Copyright (c) 2021 Jeremy O'Donoghue. All rights reserved. * * Permission is hereby granted, free of charge, to...
code_fim
hard
{ "lang": "rust", "repo": "lamnot/TPS-API-Reference-Implementations", "path": "/rs_minicbor/examples/decode.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Just about simplest ever: the below decodes as 1000 let b = SequenceBuffer::new(&[0x19, 0x03, 0xe8]); let mut it = b.into_iter(); let item = it.next(); if let Some(item) = item { let v1 = u16::try_from(&item); // should succeed let v2 = u32::try_from(&item); // shou...
code_fim
medium
{ "lang": "rust", "repo": "lamnot/TPS-API-Reference-Implementations", "path": "/rs_minicbor/examples/decode.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> where F: FnOnce(&Error) -> Error, { self.map_err(|old_e| old_e.cause_err(f)) } fn errno(&self) -> Option<Errno> { match self { Ok(_) => None, Err(e) => Some(e.errno()), } } fn has_errno(&self, errno: Errno) -> bool { ...
code_fim
hard
{ "lang": "rust", "repo": "tatetian/ngo2", "path": "/src/libos/crates/errno/src/result.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>} impl<T> ResultExt<T> for Result<T> { fn cause_err<F>(self, f: F) -> Result<T> where F: FnOnce(&Error) -> Error, { self.map_err(|old_e| old_e.cause_err(f)) } fn errno(&self) -> Option<Errno> { match self { Ok(_) => None, Err(e) => Some...
code_fim
medium
{ "lang": "rust", "repo": "tatetian/ngo2", "path": "/src/libos/crates/errno/src/result.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tatetian/ngo2 path: /src/libos/crates/errno/src/result.rs use super::{Errno, Error}; pub type Result<T> = core::result::Result<T, Error>; /// Extending `Result` with extra functionalities. pub trait ResultExt<T> { fn cause_err<F>(self, f: F) -> Result<T> where F: FnOnce(&Error)...
code_fim
hard
{ "lang": "rust", "repo": "tatetian/ngo2", "path": "/src/libos/crates/errno/src/result.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> Ok(clear_actual_native) } fn dims(&self) -> &[usize] { &self.status.dims } fn mines(&self) -> usize { self.status.mines } fn game_state(&self) -> GameState { if self.status.game_over { if self.status.win { GameState::Wi...
code_fim
hard
{ "lang": "rust", "repo": "tobz1000/mines-rs", "path": "/src/server/js/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let resp: ServerResponse = serde_json::from_reader(resp_buffer)?; Ok(resp) } fn turn( &mut self, clear: Vec<Coords>, flag: Vec<Coords>, unflag: Vec<Coords>, ) -> Result<(), GameError> { let req = TurnRequest { id: &self.statu...
code_fim
hard
{ "lang": "rust", "repo": "tobz1000/mines-rs", "path": "/src/server/js/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }