text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: diseraluca/stm32g4 path: /src/stm32g471/flash/sec2r.rs ///Reader of register SEC2R pub type R = crate::R<u32, super::SEC2R>; ///Writer for register SEC2R pub type W = crate::W<u32, super::SEC2R>; ///Register SEC2R `reset()`'s with value 0xffff_ff00 impl crate::ResetValue for super::SEC2R { t...
code_fim
hard
{ "lang": "rust", "repo": "diseraluca/stm32g4", "path": "/src/stm32g471/flash/sec2r.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>lways)] pub unsafe fn bits(self, value: u8) -> &'a mut W { self.w.bits = (self.w.bits & !0xff) | ((value as u32) & 0xff); self.w } } impl R { ///Bits 0:7 - sets the number of pages used in the bank 2 Securable memory area #[inline(always)] pub fn sec_size2(&self) -> SEC...
code_fim
hard
{ "lang": "rust", "repo": "diseraluca/stm32g4", "path": "/src/stm32g471/flash/sec2r.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: l1h3r/plutonium path: /src/hash/source.rs use std::ops::Deref; use std::os::raw::c_char; use std::os::raw::c_uchar; #[derive(Debug)] #[repr(C)] pub struct Source(*const c_char); // // Warning: BYO Safety // unsafe impl Send for Source {} unsafe impl Sync for Source {} <|fim_suffix|> #[inline...
code_fim
medium
{ "lang": "rust", "repo": "l1h3r/plutonium", "path": "/src/hash/source.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[inline] fn deref(&self) -> &Self::Target { &self.0 } }<|fim_prefix|>// repo: l1h3r/plutonium path: /src/hash/source.rs use std::ops::Deref; use std::os::raw::c_char; use std::os::raw::c_uchar; #[derive(Debug)] #[repr(C)] pub struct Source(*const c_char); // // Warning: BYO Safety // unsafe ...
code_fim
easy
{ "lang": "rust", "repo": "l1h3r/plutonium", "path": "/src/hash/source.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>// // Warning: BYO Safety // unsafe impl Send for Source {} unsafe impl Sync for Source {} impl Source { #[inline] pub fn new(source: &'static [c_uchar]) -> Self { Self(source.as_ptr() as *const c_char) } } impl Deref for Source { type Target = *const c_char; #[inline] fn deref(&self) -...
code_fim
medium
{ "lang": "rust", "repo": "l1h3r/plutonium", "path": "/src/hash/source.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MaethorNaur/kokai path: /src/error.rs use std::fmt; #[derive(Debug, Clone)] pub struct Error { message: String, } pub trait IntoError<T> { fn into_error(self) -> Result<T, Error>; fn into_error_msg<S: std::string::ToString>(self, msg: S) -> Result<T, Error>; } impl Error { pub fn new<S...
code_fim
hard
{ "lang": "rust", "repo": "MaethorNaur/kokai", "path": "/src/error.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> write!(f, "{}", self.message) } } impl std::error::Error for Error { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { None } } impl<T> IntoError<T> for Result<T, git2::Error> { fn into_error(self) -> Result<T, Error> { self.map_err(|error| Error { message: format!...
code_fim
hard
{ "lang": "rust", "repo": "MaethorNaur/kokai", "path": "/src/error.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gbarta/jbob-folly path: /tests/main.rs #![feature(plugin, custom_attribute)] #![plugin(jbob)] #[jbob_trace_se(FooBar)] fn expand_this() { <|fim_suffix|>#[test] fn test_hello_world() { expand_this(); expand_this_as_well(); }<|fim_middle|> println!("expand this!"); } jbob_trace_macro!...
code_fim
medium
{ "lang": "rust", "repo": "gbarta/jbob-folly", "path": "/tests/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gbarta/jbob-folly path: /tests/main.rs #![feature(plugin, custom_attribute)] #![plugin(jbob)] <|fim_suffix|> expand_this(); expand_this_as_well(); }<|fim_middle|>#[jbob_trace_se(FooBar)] fn expand_this() { println!("expand this!"); } jbob_trace_macro!(fn expand_this_as_well(){ p...
code_fim
medium
{ "lang": "rust", "repo": "gbarta/jbob-folly", "path": "/tests/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn test_hello_world() { expand_this(); expand_this_as_well(); }<|fim_prefix|>// repo: gbarta/jbob-folly path: /tests/main.rs #![feature(plugin, custom_attribute)] #![plugin(jbob)] #[jbob_trace_se(FooBar)] fn expand_this() { println!("expand this!"); } <|fim_middle|>jbob_trace_macro!...
code_fim
medium
{ "lang": "rust", "repo": "gbarta/jbob-folly", "path": "/tests/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> std::env::set_var("RUST_LOG", "info"); env_logger::init(); // Listen on an address and call the closure for each connection let count = Rc::new(Cell::new(0)); listen("127.0.0.1:8000", |out| Server { out, count: count.clone(), }) .unwrap() }<|fim_prefix|>// repo...
code_fim
hard
{ "lang": "rust", "repo": "Plommonsorbet/prataut-backend", "path": "/src/bin/websocket.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Plommonsorbet/prataut-backend path: /src/bin/websocket.rs /// An example of a chat web application server extern crate ws; //use futures::executor::LocalPool; use prataut_backend::{Server}; use std::cell::Cell; use std::rc::Rc; use redis; use ws::{listen, Handler, Handshake, Message, Request, R...
code_fim
hard
{ "lang": "rust", "repo": "Plommonsorbet/prataut-backend", "path": "/src/bin/websocket.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> while left < right { let mut i_left = left; while i_left + 1 <= right && results[i_left + 1][0] < height { i_left += 1; } if i_left - left >= 1 { let tmp = results.remove(left); ...
code_fim
hard
{ "lang": "rust", "repo": "geniousli/point24", "path": "/src/algorithm/reconstruct_queue.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: geniousli/point24 path: /src/algorithm/reconstruct_queue.rs use std::cmp::Ord; use std::cmp::PartialOrd; use std::vec::Vec; pub struct Solution; impl Solution { pub fn reconstruct_queue(mut people: Vec<Vec<i32>>) -> Vec<Vec<i32>> { people.sort_by(|a, b| a[1].cmp(&b[1])); let...
code_fim
hard
{ "lang": "rust", "repo": "geniousli/point24", "path": "/src/algorithm/reconstruct_queue.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if i_left - left >= 1 { let tmp = results.remove(left); results.insert(i_left, tmp); } left = i_left + 1; } } results } }<|fim_prefix|>// repo: geniousli/point24 path: /src/algorithm/r...
code_fim
hard
{ "lang": "rust", "repo": "geniousli/point24", "path": "/src/algorithm/reconstruct_queue.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>nherit_local!(Proxy, Object, Value, Data);<|fim_prefix|>// repo: uuhan/rvb path: /src/object/proxy.rs pub use crate::v8::raw::Proxy; use crate:<|fim_middle|>:v8::{ Object, Value, Data, }; inherit!(Proxy, Object, Value, Data); i
code_fim
medium
{ "lang": "rust", "repo": "uuhan/rvb", "path": "/src/object/proxy.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: uuhan/rvb path: /src/object/proxy.rs pub use crate::v8::raw::Proxy; use crate:<|fim_suffix|> inherit!(Proxy, Object, Value, Data); inherit_local!(Proxy, Object, Value, Data);<|fim_middle|>:v8::{ Object, Value, Data, };
code_fim
easy
{ "lang": "rust", "repo": "uuhan/rvb", "path": "/src/object/proxy.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: panoptesDev/panoptis-program-library path: /governance/program/src/state/enums.rs //! State enumerations use borsh::{BorshDeserialize, BorshSchema, BorshSerialize}; /// Defines all Governance accounts types #[repr(C)] #[derive(Clone, Debug, PartialEq, BorshDeserialize, BorshSerialize, BorshSch...
code_fim
hard
{ "lang": "rust", "repo": "panoptesDev/panoptis-program-library", "path": "/governance/program/src/state/enums.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Voting ended with success Succeeded, /// Voting on Proposal succeeded and now instructions are being executed /// Proposal enter this state when first instruction is executed and leaves when the last instruction is executed Executing, /// Completed Completed, /// Can...
code_fim
hard
{ "lang": "rust", "repo": "panoptesDev/panoptis-program-library", "path": "/governance/program/src/state/enums.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// No vote No(u64), } /// What state a Proposal is in #[repr(C)] #[derive(Clone, Debug, PartialEq, BorshDeserialize, BorshSerialize, BorshSchema)] pub enum ProposalState { /// Draft - Proposal enters Draft state when it's created Draft, /// SigningOff - The Proposal is being signed ...
code_fim
hard
{ "lang": "rust", "repo": "panoptesDev/panoptis-program-library", "path": "/governance/program/src/state/enums.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> for event in gfx.display.poll_events() { match event { WindowEvent::Closed => return Exit, WindowEvent::MouseMoved(x, y) => notifier.notify(WindowEvent::MouseMoved(x, h as i32 - y)), e => notifier.notify(e), ...
code_fim
hard
{ "lang": "rust", "repo": "tioover/rier-sprite", "path": "/examples/sprite.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let weak = Rc::downgrade(&self.sprite); notifier.register(move |e| { match e { &WindowEvent::MouseMoved(x, y) => { match weak.upgrade() { None => Return::Dead, Some(sprite) => { ...
code_fim
hard
{ "lang": "rust", "repo": "tioover/rier-sprite", "path": "/examples/sprite.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tioover/rier-sprite path: /examples/sprite.rs extern crate rier; extern crate rier_sprite; use std::path::PathBuf; use std::rc::Rc; use std::cell::RefCell; use rier::texture; use rier::{Context, Gfx, WindowEvent, Camera2D, Loop}; use rier::loader::Resource; use rier::event::{Notifier, Return}; ...
code_fim
hard
{ "lang": "rust", "repo": "tioover/rier-sprite", "path": "/examples/sprite.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Noah-Kennedy/rust-chat path: /src/ws.rs use actix_web::web; use crate::handlers::AppState; use actix::{Actor, StreamHandler, ActorContext, spawn}; use actix_web_actors::ws; use actix_web_actors::ws::{ProtocolError, Message}; use crate::model::Msg; <|fim_suffix|> let r...
code_fim
hard
{ "lang": "rust", "repo": "Noah-Kennedy/rust-chat", "path": "/src/ws.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match item { Ok(Message::Ping(msg)) => { ctx.pong(&msg); } Ok(Message::Pong(_)) => { unimplemented!() } Ok(Message::Text(text)) => { match serde_json::from_str(&text) { O...
code_fim
hard
{ "lang": "rust", "repo": "Noah-Kennedy/rust-chat", "path": "/src/ws.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let fut = async move { let db = state.pool.get().await.unwrap(); let res = db.query( "INSERT INTO messages (\"to\", \"from\", \"body\", \"time\") VALUES ($1, $2, $3, $4) RETURNING *", ...
code_fim
hard
{ "lang": "rust", "repo": "Noah-Kennedy/rust-chat", "path": "/src/ws.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Shizcow/emoji-rs path: /examples/lookup/src/main.rs fn main() { println!("There's only one emoji with the name 'shrimp'. It's: {}", emoji::lookup_by_name::l<|fim_suffix|>annotations for 'prawn' and taking the top result yields: {}", emoji::search::search_annotation("prawn", "en"...
code_fim
medium
{ "lang": "rust", "repo": "Shizcow/emoji-rs", "path": "/examples/lookup/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>("prawn", "en").into_iter().map( |e| format!("{} ({})", e.glyph, e.name) ).nth(0).unwrap() ); }<|fim_prefix|>// repo: Shizcow/emoji-rs path: /examples/lookup/src/main.rs fn main() { println!("There's only one emoji with the name 'shrimp'. It's: {}", emoji::lookup_by_name::l<|fim_middle|>...
code_fim
hard
{ "lang": "rust", "repo": "Shizcow/emoji-rs", "path": "/examples/lookup/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for (s, n, t) in resolution.iter_stem() { println!( "{},{},{}", n, s, resolution.module(s).number_of_gens_in_degree(t) ); } Ok(()) }<|fim_prefix|>// repo: SpectralSequences/sseq path: /ext/examples/num_gens.rs //! This prints the...
code_fim
easy
{ "lang": "rust", "repo": "SpectralSequences/sseq", "path": "/ext/examples/num_gens.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: SpectralSequences/sseq path: /ext/examples/num_gens.rs //! This prints the number of generators in each $\Ext^{s, n + s}$ in the format `n,s,num_gens`. //! use ext::chain_complex::ChainComplex; use ext::utils::query_module; <|fim_suffix|> let resolution = query_module(None, false)?; for...
code_fim
easy
{ "lang": "rust", "repo": "SpectralSequences/sseq", "path": "/ext/examples/num_gens.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: realcr/fragmentos path: /src/state_machine.rs use std::collections::HashMap; use ::shares::{DataShare}; use ::messages::{MESSAGE_ID_LEN, ECC_LEN, unite_message, verify_frag_message}; const MESSAGE_ID_TICKS: usize = 30; struct CurMessage { ticks_to_live: usize, b: u8, share_len...
code_fim
hard
{ "lang": "rust", "repo": "realcr/fragmentos", "path": "/src/state_machine.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut fsm = FragStateMachine::new(); let orig_message = b"This is some message to be split"; let frags = split_message(orig_message, b"nonce123", 22).unwrap(); let b = (frags.len() + 1) / 2; for i in 0 .. b-1 { asse...
code_fim
hard
{ "lang": "rust", "repo": "realcr/fragmentos", "path": "/src/state_machine.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // A litle time has passed: fsm.time_tick(); // We now get all the other frags. All of them should be ignored: for i in b .. frags.len() { assert_eq!(fsm.received_frag_message(&frags[i]), None); } } #[test] fn test_received_frag_cur_message...
code_fim
hard
{ "lang": "rust", "repo": "realcr/fragmentos", "path": "/src/state_machine.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dicroce/basic_rust path: /src/structs.rs // normal struct struct Color { red: u8, green: u8, blue: u8 } // tuple struct struct Color2(u8, u8, u8); // basic type with ctor and method... struct Person { first_name: String, last_name: String } impl Person { // construct ...
code_fim
hard
{ "lang": "rust", "repo": "dicroce/basic_rust", "path": "/src/structs.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> (self.first_name.to_string(), self.last_name.to_string()) } } pub fn run() { let c = Color { red: 255, green: 0, blue: 0 }; println!("{} {} {}", c.red, c.green, c.blue); let c2 = Color2(0, 255, 0); println!("{} {} {}", c2.0, c2.1, c2.2); let mut p = Person::new("Tony", "...
code_fim
medium
{ "lang": "rust", "repo": "dicroce/basic_rust", "path": "/src/structs.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// If `result` is [`Err`], logs and aborts the node. pub(crate) fn ok_or_abort_node<T>(func_name: &str, result: Result<T>) { if let Err(report) = result { log_chronik!("{report:?}\n"); abort_node( &format!("ERROR Chronik in {func_name}"), &format!("{report:#}")...
code_fim
medium
{ "lang": "rust", "repo": "Bitcoin-ABC/bitcoin-abc", "path": "/chronik/chronik-lib/src/error.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Bitcoin-ABC/bitcoin-abc path: /chronik/chronik-lib/src/error.rs // Copyright (c) 2022 The Bitcoin developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. <|fim_suffix|>/// If `result` is [`Err`], logs ...
code_fim
medium
{ "lang": "rust", "repo": "Bitcoin-ABC/bitcoin-abc", "path": "/chronik/chronik-lib/src/error.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #include <stdio.h> #include "config.h" #include "ucp/core/ucp_request.h" void main() { fprint("%ull\n", sizeof(ucp_request)); } Run on Alpine Linux using: gcc -DHAVE_CONFIG -I. -I./src -o ./x find_size_of_ucp_request_t.c (where `find_size_of_ucp_request_t.c` is in ucx-sys/tempo...
code_fim
hard
{ "lang": "rust", "repo": "cnutshell/rust-ucx", "path": "/workspace/ucx/src/attributes/ApplicationContextAttributes.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> void main() { fprint("%ull\n", sizeof(ucp_request)); } Run on Alpine Linux using: gcc -DHAVE_CONFIG -I. -I./src -o ./x find_size_of_ucp_request_t.c (where `find_size_of_ucp_request_t.c` is in ucx-sys/temporary/root) */ pub(crate) const ReservedSpaceInNonBlockingRequestsRoundedUp: usiz...
code_fim
hard
{ "lang": "rust", "repo": "cnutshell/rust-ucx", "path": "/workspace/ucx/src/attributes/ApplicationContextAttributes.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cnutshell/rust-ucx path: /workspace/ucx/src/attributes/ApplicationContextAttributes.rs // This file is part of ucx. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/ucx/master/COPYRIG...
code_fim
hard
{ "lang": "rust", "repo": "cnutshell/rust-ucx", "path": "/workspace/ucx/src/attributes/ApplicationContextAttributes.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jonahpelfrey/node-rust path: /native/src/types/component_types.rs use ::types::base_types::Quote; #[derive(Deserialize)] pub struct Input { pub draws: Vec<Draw>, pub factors: PricingFactor, pub prices: DailyPrice, pub quote: Quote, pub coverage: f64 } #[derive(Deserialize)] pub struct Dra...
code_fim
hard
{ "lang": "rust", "repo": "jonahpelfrey/node-rust", "path": "/native/src/types/component_types.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[serde(rename = "monthOneExpectedButterPrice")] pub m1ebp: f64, #[serde(rename = "monthTwoButterSigma")] pub m2bs: f64, #[serde(rename = "monthTwoExpectedButterPrice")] pub m2ebp: f64, #[serde(rename = "monthThreeButterSigma")] pub m3bs: f64, #[serde(rename = "monthThreeExpectedButterPrice")...
code_fim
hard
{ "lang": "rust", "repo": "jonahpelfrey/node-rust", "path": "/native/src/types/component_types.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[serde(rename = "expectedButterfatPrice")] pub ebfp: f64, #[serde(rename = "expectedProteinPrice")] pub epp: f64, #[serde(rename = "expectedOtherSolidsPrice")] pub eosp: f64, #[serde(rename = "monthOneButterSigma")] pub m1bs: f64, #[serde(rename = "monthOneExpectedButterPrice")] pub m1ebp:...
code_fim
hard
{ "lang": "rust", "repo": "jonahpelfrey/node-rust", "path": "/native/src/types/component_types.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jamescarterbell/bevy_rollback path: /src/util.rs use bevy::ecs::schedule::Stage; use crate::RollbackStartupSchedule; use crate::rollback_schedule::RollbackSchedule; use bevy::app::AppBuilder; use bevy::ecs::schedule::{StageLabel, SystemDescriptor}; use bevy::reflect::TypeRegistry; use bevy::ecs:...
code_fim
hard
{ "lang": "rust", "repo": "jamescarterbell/bevy_rollback", "path": "/src/util.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> &mut self, target: impl StageLabel, label: impl StageLabel, stage: S ) -> &mut AppBuilder { self .world_mut() .get_resource_mut::<RollbackStartupSchedule>() .expect("Add RollbackStartupSchedule to app!") .add_stage...
code_fim
hard
{ "lang": "rust", "repo": "jamescarterbell/bevy_rollback", "path": "/src/util.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let component_name = r_string(); component_manager .register(crate::model::Component::new( component_name.clone(), vec![crate::model::PropertyType::new( String::from("x"), DataType::String, )], )); let relati...
code_fim
hard
{ "lang": "rust", "repo": "aschaeffer/rust-ecs-poc", "path": "/src/tests/implementation/relation_type_manager_test.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let type_name = r_string(); let outbound_type_name = r_string(); let inbound_type_name = r_string(); let mut path = env::temp_dir(); path.push(format!("{}.json", type_name)); let path = path.into_os_string().into_string().unwrap(); EntityTypeBuilder::new(outbound_type_name.cl...
code_fim
hard
{ "lang": "rust", "repo": "aschaeffer/rust-ecs-poc", "path": "/src/tests/implementation/relation_type_manager_test.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aschaeffer/rust-ecs-poc path: /src/tests/implementation/relation_type_manager_test.rs use std::env; use crate::model::{PropertyType, RelationType, DataType}; use crate::tests::utils::{init_application, r_string}; use crate::builder::EntityTypeBuilder; #[test] fn test_register_relation_type() {...
code_fim
hard
{ "lang": "rust", "repo": "aschaeffer/rust-ecs-poc", "path": "/src/tests/implementation/relation_type_manager_test.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) { let heap = __current_heap_bottom() as *mut lla::Heap; let nn_ptr = NonNull::new(ptr).unwrap(); (*heap).deallocate(nn_ptr, layout); } } #[global_allocator] pub static ALLOCATOR: Allocator = Allocator;<|fim_prefix|>// ...
code_fim
hard
{ "lang": "rust", "repo": "gavz/choupi-os", "path": "/src/allocator/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>} #[no_mangle] pub unsafe extern "C" fn initialize_heap() { let bottom = __current_heap_bottom(); let size = __current_heap_size(); initialize_heap_at(bottom, size); } pub unsafe fn initialize_heap_at(bottom: usize, size: usize) { let meta_size = size_of::<lla::Heap>(); *(bottom as *...
code_fim
hard
{ "lang": "rust", "repo": "gavz/choupi-os", "path": "/src/allocator/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gavz/choupi-os path: /src/allocator/lib.rs // The MIT License (MIT) // // Copyright (c) 2020, National Cybersecurity Agency of France (ANSSI) // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software")...
code_fim
hard
{ "lang": "rust", "repo": "gavz/choupi-os", "path": "/src/allocator/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: harpiechoise/Set-de-Mandelbrot-Rust path: /src/main.rs extern crate num; use num::Complex; extern crate crossbeam; /// Intentamos determinar si `c` es un miembro del set de Mandelbrot, /// Unsando el parametro limit como el limite de iteraciones que decidamos /// Si `c` pertenece al conjunto s...
code_fim
hard
{ "lang": "rust", "repo": "harpiechoise/Set-de-Mandelbrot-Rust", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match s.find(separator) { None => None, Some(index) => { match (T::from_str(&s[..index]), T::from_str(&s[index + 1..])) { (Ok(l), Ok(r)) => Some((l, r)), _ => None } } } } /// Esta funcion busca un par...
code_fim
hard
{ "lang": "rust", "repo": "harpiechoise/Set-de-Mandelbrot-Rust", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> -> Result<(), std::io::Error> { let output = File::create(filename)?; let encoder = PNGEncoder::new(output); encoder.encode(&pixels, bounds.0 as u32, bounds.1 as u32, ColorType::Gray(8))?; Ok(()) } use std::io::Write; /// Ejecuta todas las funciones que se describieron ...
code_fim
hard
{ "lang": "rust", "repo": "harpiechoise/Set-de-Mandelbrot-Rust", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> UpdateTaskCommandHandler { command, client: self.client.to_owned() } } fn build_for_delete(&self, command: DeleteTaskCommand) -> DeleteTaskCommandHandler { DeleteTaskCommandHandler { command, client: self.client.to_owned() } } fn build_for_assign_task_to_user(&self, comma...
code_fim
hard
{ "lang": "rust", "repo": "emreyalvac/project-management-system", "path": "/commands/src/factory/task_command_handler_factory.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: emreyalvac/project-management-system path: /commands/src/factory/task_command_handler_factory.rs use crate::commands::task_commands::insert_task_command::{InsertTaskCommand}; use crate::command_handlers::task_command_handlers::insert_task_command_handler::{InsertTaskCommandHandler}; use crate::c...
code_fim
hard
{ "lang": "rust", "repo": "emreyalvac/project-management-system", "path": "/commands/src/factory/task_command_handler_factory.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(Status::Pending.to_taskmap(), "pending"); assert_eq!(Status::Completed.to_taskmap(), "completed"); assert_eq!(Status::Deleted.to_taskmap(), "deleted"); assert_eq!(Status::Recurring.to_taskmap(), "recurring"); assert_eq!(Status::Unknown("wishful".into()).t...
code_fim
medium
{ "lang": "rust", "repo": "GothenburgBitFactory/taskwarrior", "path": "/taskchampion/taskchampion/src/task/status.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: GothenburgBitFactory/taskwarrior path: /taskchampion/taskchampion/src/task/status.rs /// The status of a task, as defined by the task data model. #[derive(Debug, PartialEq, Eq, Clone, strum_macros::Display)] #[repr(C)] pub enum Status { Pending, Completed, Deleted, Recurring, ...
code_fim
hard
{ "lang": "rust", "repo": "GothenburgBitFactory/taskwarrior", "path": "/taskchampion/taskchampion/src/task/status.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>quick_main!(|| -> Result<()> { Ok(()) });<|fim_prefix|>// repo: charmoniumQ/chunky_backup path: /src/main.rs // `error_chain!` can recurse deeply #![recursion_limit = "1024"] <|fim_middle|>// Import the macro. #[macro_use] extern crate error_chain; pub use errors::*; use std::path::Path; mod errors; m...
code_fim
hard
{ "lang": "rust", "repo": "charmoniumQ/chunky_backup", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: charmoniumQ/chunky_backup path: /src/main.rs // `error_chain!` can recurse deeply #![recursion_limit = "1024"] // Import the macro. #[macro_use] extern crate error_chain; pub use errors::*; use std::path::Path; <|fim_suffix|>struct Config { root_dir: Box<Path>, block_size: i32, } qui...
code_fim
easy
{ "lang": "rust", "repo": "charmoniumQ/chunky_backup", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: galsterGH/terminal path: /src/main.rs use std::env::args; use std::fs; use std::io::{stdin,stdout,Write}; use termion::{event::Key, input::TermRead}; use termion::raw::IntoRawMode; use termion::{color,style}; struct Doc { lines: Vec<String>, } struct Coordinate { pub x: usize, pub ...
code_fim
hard
{ "lang": "rust", "repo": "galsterGH/terminal", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let pos = &self.cur_pos; let (old_x, old_y) = (pos.x, pos.y); print!("{}{}",termion::clear::All,termion::cursor::Goto(1,1)); println!("{}{}Welcome to Super text viewer\r{}", color::Bg(color::Black), color::Fg(color::Red), ...
code_fim
hard
{ "lang": "rust", "repo": "galsterGH/terminal", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ferrouswheel/advent-of-code-2020-rs path: /src/day5.rs mod utils; use core::cmp::*; use std::char; use utils::read_lines; const INPUT_FN : &str = "input/day5.txt"; #[derive(Eq)] pub struct Seat { data_binary: Vec<bool>, row: u8, column: u8 } impl Seat { pub fn load(line: &St...
code_fim
hard
{ "lang": "rust", "repo": "ferrouswheel/advent-of-code-2020-rs", "path": "/src/day5.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn decode_seat_line_2() { let s = Seat::load(&"FFFBBBFRRR".to_string()); assert_eq!(s.row, 14); assert_eq!(s.column, 7); assert_eq!(s.seat_id(), 119); } #[test] fn decode_seat_line_3() { let s = Seat::load(&"BBFFBBFRLL".to_string()); ...
code_fim
hard
{ "lang": "rust", "repo": "ferrouswheel/advent-of-code-2020-rs", "path": "/src/day5.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn main() -> Result<(), String> { let max_id; let min_id; if let Ok(lines) = read_lines(INPUT_FN) { // Consumes the iterator, returns an (Optional) String let seats: Vec<Seat> = lines.map(Result::unwrap).map(|x| Seat::load(&x)).collect(); min_id = seats.it...
code_fim
hard
{ "lang": "rust", "repo": "ferrouswheel/advent-of-code-2020-rs", "path": "/src/day5.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/darling/tests/accrue_errors.rs # ! [ allow ( dead_code ) ] / / ! These tests verify that multiple errors will be collected up from throughout / / ! the parsing process and returned correctly to the caller . use darling : : { ast FromDeriveInput...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/darling/tests/accrue_errors.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>rr = Month : : from_derive_input ( & input ) . unwrap_err ( ) ; assert_eq ! ( 2 s_err . len ( ) ) ; let err = s_err . flatten ( ) ; / / TODO add tests to check location path is correct println ! ( " { } " err ) ; } # [ test ] fn error_in_newtype_variant ( ) { let input = parse_quote ! { # [ accrue ( sched...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/darling/tests/accrue_errors.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 0xksure/gittoken path: /backend/src/sdk.rs use rithub::api::api::{self, ReviewComment}; use rithub::app::app; use rithub::error::errors::Error; use rocket_contrib::databases::postgres; use solana_sdk::instruction::AccountMeta; use std::borrow::Borrow; use std::fs::File; use std::io::{BufRead, Bu...
code_fim
hard
{ "lang": "rust", "repo": "0xksure/gittoken", "path": "/backend/src/sdk.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if from_addr.eq(to_addr) { return Err(Error::new( 500, String::from("should avoid transfer to itself"), )); } if from_balance < amount { return Err(Error::new(500, String::from("not enough funds"))); } let token_program_id = Pubkey::new...
code_fim
hard
{ "lang": "rust", "repo": "0xksure/gittoken", "path": "/backend/src/sdk.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Clone)] #[repr(align(64))] pub(crate) struct OwnedPage { page: Vec<u8>, } // unsafe impl Send for Page {} // unsafe impl Sync for Page {} impl OwnedPage { pub(crate) fn new(size: PageSize) -> Self { Self { page: vec![0u8; size], } } pub(crate) fn fro...
code_fim
hard
{ "lang": "rust", "repo": "Reeywhaar/nut", "path": "/src/page/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Reeywhaar/nut path: /src/page/mod.rs #[cfg(test)] pub mod page_data_tests; #[cfg(test)] pub mod tests; use std::borrow::{Borrow, BorrowMut, ToOwned}; use std::fmt; use std::marker::PhantomData; use std::ops::{Deref, DerefMut}; mod branch_page_element; mod leaf_page_element; mod page_data; mod ...
code_fim
hard
{ "lang": "rust", "repo": "Reeywhaar/nut", "path": "/src/page/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut computations = Vec::<i64>::new(); for mut value in arr_1 { stack_computations(&mut computations, &mut value) } const THRESHOLD: i64 = 100; let items_gt_100 = computations.iter().filter(|x| *x > &THRESHOLD).count(); println!("Values from \n\t{:?}\ngreater than {}...
code_fim
medium
{ "lang": "rust", "repo": "ldfdev/Exercises-from-the-book-Beginning-Rust-From-Novice-To-Expert", "path": "/Chapter 5/pushing_into_vector_as_function_parameter_part1.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for mut value in arr_1 { stack_computations(&mut computations, &mut value) } const THRESHOLD: i64 = 100; let items_gt_100 = computations.iter().filter(|x| *x > &THRESHOLD).count(); println!("Values from \n\t{:?}\ngreater than {}: {}", computations, THRESHOLD, items_gt_100); ...
code_fim
medium
{ "lang": "rust", "repo": "ldfdev/Exercises-from-the-book-Beginning-Rust-From-Novice-To-Expert", "path": "/Chapter 5/pushing_into_vector_as_function_parameter_part1.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jvff/pegast path: /src/rules/optional.rs use { crate::{input::Input, ParseError, PegAstNode}, std::borrow::Cow, }; impl<R: PegAstNode> PegAstNode for Option<R> { fn parse(input: &mut impl Input) -> Result<Self, ParseError> { <|fim_suffix|> self.as_ref() .map(PegAs...
code_fim
hard
{ "lang": "rust", "repo": "jvff/pegast", "path": "/src/rules/optional.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut expecting = R::expecting(); expecting.push("or nothing".to_owned()); expecting } }<|fim_prefix|>// repo: jvff/pegast path: /src/rules/optional.rs use { crate::{input::Input, ParseError, PegAstNode}, std::borrow::Cow, }; impl<R: PegAstNode> PegAstNode for Opt...
code_fim
medium
{ "lang": "rust", "repo": "jvff/pegast", "path": "/src/rules/optional.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn neighbor(&self, dir: i32) -> Hex { self + &HEX_DIRECTIONS[(dir % 6) as usize] } } impl std::cmp::PartialEq for Hex { fn eq(&self, other: &Hex) -> bool { self.q == other.q && self.r == other.r && self.s == other.s } } impl std::ops::Add<&Hex> for &Hex { type Out...
code_fim
hard
{ "lang": "rust", "repo": "akesling/tesselated", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: akesling/tesselated path: /src/lib.rs pub struct Hex { // Prevent independent construction so invariants are enforced. _secret: (), pub q: i32, pub r: i32, pub s: i32, } static HEX_DIRECTIONS: [Hex; 6] = [ Hex { _secret: (), r: 1, q: 0, s:...
code_fim
hard
{ "lang": "rust", "repo": "akesling/tesselated", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: johnstonskj/rust-xml_dom_xpath path: /src/xpath1/parser/mod.rs /*! Parse an XPath string into it's model form. The primary API is the [`read_str`](fn.read_str.html) function. # Specification ```ebnf [1] LocationPath ::= RelativeLocationPath | Absolute...
code_fim
hard
{ "lang": "rust", "repo": "johnstonskj/rust-xml_dom_xpath", "path": "/src/xpath1/parser/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // https://www.sqlite.org/lang_UPSERT.html (Parsing Ambiguity) self.0.build_query(pass, |where_clause, mut pass| { match where_clause { BoxedWhereClause::None => pass.push_sql(" WHERE 1=1 "), w => w.walk_ast(pass.reborrow())?, } ...
code_fim
hard
{ "lang": "rust", "repo": "diesel-rs/diesel", "path": "/diesel/src/sqlite/query_builder/query_fragment_impls.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: diesel-rs/diesel path: /diesel/src/sqlite/query_builder/query_fragment_impls.rs use crate::query_builder::select_statement::boxed::BoxedQueryHelper; use crate::query_builder::upsert::into_conflict_clause::OnConflictSelectWrapper; use crate::query_builder::where_clause::BoxedWhereClause; use crat...
code_fim
hard
{ "lang": "rust", "repo": "diesel-rs/diesel", "path": "/diesel/src/sqlite/query_builder/query_fragment_impls.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Delete cache file now that keys are stored in the DB. fs::remove_file(&pk_cache_path).map_err(|e| { StoreError::SchemaMigrationError(format!( "unable to delete {}: {:?}", pk_cache_path.display(), e ...
code_fim
hard
{ "lang": "rust", "repo": "g-r-a-n-t/lighthouse", "path": "/beacon_node/beacon_chain/src/schema_change.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Ok(()) } // Migration for adding sync committee contributions to the persisted op pool. (SchemaVersion(3), SchemaVersion(4)) => { // Deserialize from what exists in the database using the `PersistedOperationPoolBase` // variant and convert it to ...
code_fim
hard
{ "lang": "rust", "repo": "g-r-a-n-t/lighthouse", "path": "/beacon_node/beacon_chain/src/schema_change.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: g-r-a-n-t/lighthouse path: /beacon_node/beacon_chain/src/schema_change.rs //! Utilities for managing database schema changes. use crate::beacon_chain::{BeaconChainTypes, OP_POOL_DB_KEY}; use crate::validator_pubkey_cache::ValidatorPubkeyCache; use operation_pool::{PersistedOperationPool, Persist...
code_fim
hard
{ "lang": "rust", "repo": "g-r-a-n-t/lighthouse", "path": "/beacon_node/beacon_chain/src/schema_change.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oconnor0/wio-rs path: /src/handle.rs // Copyright © 2015, Peter Atashian // Licensed under the MIT License <LICENSE.md> use {Result, k32, last_error, w}; use std::io::{Error}; use std::ops::{Deref}; use std::os::windows::io::{AsRawHandle, FromRawHandle, IntoRawHandle}; use std::ptr::{null_mut}; ...
code_fim
hard
{ "lang": "rust", "repo": "oconnor0/wio-rs", "path": "/src/handle.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>} impl Drop for Handle { fn drop(&mut self) { let err = unsafe { k32::CloseHandle(self.0) }; assert!(err != 0, "{:?}", Error::last_os_error()); } } impl FromRawHandle for Handle { unsafe fn from_raw_handle(handle: w::HANDLE) -> Handle { Handle(handle) } } impl IntoR...
code_fim
hard
{ "lang": "rust", "repo": "oconnor0/wio-rs", "path": "/src/handle.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Polkadex-Substrate/curv path: /src/cryptographic_primitives/hashing/hash_sha256.rs /* This file is part of Curv library Copyright 2018 by Kzen Networks (https://github.com/KZen-networks/curv) License MIT: https://github.com/KZen-networks/curv/blob/master/LICENSE */ #![allow(depr...
code_fim
hard
{ "lang": "rust", "repo": "Polkadex-Substrate/curv", "path": "/src/cryptographic_primitives/hashing/hash_sha256.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn create_sha256_from_ge_test<E: Curve>() { let generator = Point::<E>::generator(); let base_point2 = Point::<E>::base_point2(); let result1 = HSha256::create_hash_from_ge::<E>(&[base_point2, &generator]); assert!(result1.to_bigint().bit_length() > 240); let re...
code_fim
hard
{ "lang": "rust", "repo": "Polkadex-Substrate/curv", "path": "/src/cryptographic_primitives/hashing/hash_sha256.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hexcowboy/rust-by-example path: /to_do/src/to_do/structs/base.rs pub struct Base { pub title: String, pub status: String } <|fim_suffix|> Base { return Base { title: input_title.to_string(), status: input_status.to_string() } } }<|fim_middle|>...
code_fim
medium
{ "lang": "rust", "repo": "hexcowboy/rust-by-example", "path": "/to_do/src/to_do/structs/base.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> Base { return Base { title: input_title.to_string(), status: input_status.to_string() } } }<|fim_prefix|>// repo: hexcowboy/rust-by-example path: /to_do/src/to_do/structs/base.rs pub struct Base { pub title: String, pub status: String } <|fim_middle|>...
code_fim
medium
{ "lang": "rust", "repo": "hexcowboy/rust-by-example", "path": "/to_do/src/to_do/structs/base.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: NorabX/rustils path: /src/parse/ulong.rs use error::ParseError; use RoundingMode; use RoundingMode::*; pub trait ToU64 { fn to_u64_res(self) -> ParseResultU64; fn to_u64(self) -> u64; } pub trait ToU64RM { fn to_u64_rm_res(self, rm: RoundingMode) -> Parse...
code_fim
hard
{ "lang": "rust", "repo": "NorabX/rustils", "path": "/src/parse/ulong.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if x.is_nan() || x < 0.0 || x > max { Err(ParseError::InvalidNumber(a.to_string())) } else { Ok(x as u64) } } pub fn f64_to_u64_rm(a: f64, rm: RoundingMode) -> u64 { match f64_to_u64_rm_res(a, rm) { Ok(i) => i, Err(err) => panic!("{}",err) } } /// Parse [`isi...
code_fim
hard
{ "lang": "rust", "repo": "NorabX/rustils", "path": "/src/parse/ulong.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match i8_to_u64_res(a) { Ok(i) => i, Err(err) => panic!("{}",err) } } /// Parse [`i16`](https://doc.rust-lang.org/std/primitive.i16.html) to /// [`u64`](https://doc.rust-lang.org/std/primitive.u64.html) /// /// # Arguments /// /// * `a` - Any [`i16`](https://doc.rust-lang.org/std/...
code_fim
hard
{ "lang": "rust", "repo": "NorabX/rustils", "path": "/src/parse/ulong.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>(true); pie.draw(); pie.chart_prop.set_screen_size(900.0, 900.0); pie.draw(); pie.chart_prop.set_screen_size(300.0, 300.0); pie.draw(); pie.chart_prop.set_screen_size(500.0, 700.0); pie.draw(); pie.chart_prop.set_screen_size(700.0, 500.0); pie.draw(); pie.chart_prop...
code_fim
hard
{ "lang": "rust", "repo": "hdoordt/rustplot", "path": "/tests/window_size_tests.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hdoordt/rustplot path: /tests/window_size_tests.rs extern crate rustplot; use rustplot::chart_builder; use rustplot::chart_builder::Chart; use rustplot::data_parser; #[test] fn window_size_tests() { let data_1 = data_parser::get_str_col(0, 0, 5, "./resources/bar_chart_tests.csv"); let ...
code_fim
hard
{ "lang": "rust", "repo": "hdoordt/rustplot", "path": "/tests/window_size_tests.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub struct StateTrieView<'a, View: TxStateView + ?Sized> { state_view: &'a View, acc_address: Address, } impl<'a, View: TxStateView + ?Sized> StateTrieView<'a, View> { pub fn new(state_view: &'a View, acc_address: Address) -> Self { Self { state_view, acc_addre...
code_fim
hard
{ "lang": "rust", "repo": "hkbudb/slimchain", "path": "/slimchain-tx-state/src/view/trie_view.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl<'a, View: TxStateView + ?Sized> StateTrieView<'a, View> { pub fn new(state_view: &'a View, acc_address: Address) -> Self { Self { state_view, acc_address, } } } impl<'a, View: TxStateView + ?Sized> NodeLoader<StateValue> for StateTrieView<'a, View> { ...
code_fim
hard
{ "lang": "rust", "repo": "hkbudb/slimchain", "path": "/slimchain-tx-state/src/view/trie_view.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hkbudb/slimchain path: /slimchain-tx-state/src/view/trie_view.rs use super::TxStateView; use slimchain_common::{ basic::{AccountData, Address, StateValue, H256}, error::Result, }; use slimchain_merkle_trie::storage::{NodeLoader, TrieNode}; <|fim_suffix|>pub struct StateTrieView<'a, View...
code_fim
hard
{ "lang": "rust", "repo": "hkbudb/slimchain", "path": "/slimchain-tx-state/src/view/trie_view.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ostrosco/atomic_clock path: /src/time.rs /// A series of utility functions for handling time. pub struct Timestamp { pub year: u16, pub doy: u16, pub hour: u16, pub minute: u16, pub seconds: u16, } pub struct Date { pub year: u16, pub month: u16, pub day: u16, }...
code_fim
hard
{ "lang": "rust", "repo": "ostrosco/atomic_clock", "path": "/src/time.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut num_leaps = 0u32; // We only care about the number of leap years since the Unix epoch and we know the first leap // year after the epoch was in 1972. for leap in 1972..year { if (leap % 400 == 0 || leap % 100 != 0) && leap % 4 == 0 { num_leaps += 1; } ...
code_fim
hard
{ "lang": "rust", "repo": "ostrosco/atomic_clock", "path": "/src/time.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: StriderDM/tari path: /base_layer/core/src/base_node/proto/response.rs // Copyright 2019, The Tari Project // // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the // following conditions are met: // // 1. Redistributions of source cod...
code_fim
hard
{ "lang": "rust", "repo": "StriderDM/tari", "path": "/base_layer/core/src/base_node/proto/response.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }