text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: dainslef/RustPractice path: /src/leetcode/q126_word_ladder_ii.rs /* * * Given two words (beginWord and endWord), and a dictionary's word list, find all shortest transformation sequence(s) from beginWord to endWord, such that: * * Only one letter can be changed at a time * Each transformed wo...
code_fim
hard
{ "lang": "rust", "repo": "dainslef/RustPractice", "path": "/src/leetcode/q126_word_ladder_ii.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> // TODO: Find a list of points on the battlefield for party members to occupy on the left side of the screen. // And use a query to move them there. commands.insert_resource(BattleView { entity: battle_entity, enemies: vec![event.enemy_entity], ...
code_fim
hard
{ "lang": "rust", "repo": "StarArawn/bevy_roguelike_prototype", "path": "/src/game/gameplay/scenes/battle.rs", "mode": "spm", "license": "CC-BY-4.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: StarArawn/bevy_roguelike_prototype path: /src/game/gameplay/scenes/battle.rs use bevy::{prelude::*, render::camera::RenderLayers}; use crate::game::{camera::CustomOrthographicCameraBundle, gameplay::{character::Character, enemy::create_battle_enemy, stats::{StatName, StatsQuery}}, helpers::z_in...
code_fim
hard
{ "lang": "rust", "repo": "StarArawn/bevy_roguelike_prototype", "path": "/src/game/gameplay/scenes/battle.rs", "mode": "psm", "license": "CC-BY-4.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn lex_input(&mut self) { loop { if self.chr0 == None { break; } match self.chr0.unwrap() { 'a'..='z' | 'A'..='Z' | '_' => { let mut result = Vec::new(); loop { ...
code_fim
hard
{ "lang": "rust", "repo": "v4kst1z/TIP", "path": "/lexer/src/lexer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: v4kst1z/TIP path: /lexer/src/lexer.rs use crate::token::{Token, get_keywords}; use std::collections::HashMap; use std::fmt::Debug; use crate::position::Position; #[derive(Debug)] pub struct NewlineHandler<T: Iterator<Item = char>> { source: T, chr0: Option<char>, chr1: Option<char>,...
code_fim
hard
{ "lang": "rust", "repo": "v4kst1z/TIP", "path": "/lexer/src/lexer.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub struct Lexer<T: Iterator<Item = char> + Debug> { chars: T, chr0: Option<char>, chr1: Option<char>, keywords: HashMap<String, Token>, pos: Position, pub result: Vec<Token>, } impl<T> Lexer<T> where T: Iterator<Item = char> + Debug { pub fn new(input: T) -> Se...
code_fim
hard
{ "lang": "rust", "repo": "v4kst1z/TIP", "path": "/lexer/src/lexer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kosta/franzi path: /franzi-proto/src/messages/sync_group.rs kafka_message!( "SyncGroup Request (Version: 0) => group_id generation_id member_id [group_assignment] group_id => STRING generation_id => INT32 member_id => STRING group_assignment => member_id member_assignment member_...
code_fim
hard
{ "lang": "rust", "repo": "kosta/franzi", "path": "/franzi-proto/src/messages/sync_group.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>kafka_message!( "SyncGroup Response (Version: 0) => error_code member_assignment error_code => INT16 member_assignment => BYTES Field Description error_code Response error code member_assignment null" ); kafka_message!("SyncGroup Response (Version: 1) => throttle_time_ms error_code member_assig...
code_fim
hard
{ "lang": "rust", "repo": "kosta/franzi", "path": "/franzi-proto/src/messages/sync_group.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>kafka_message!("SyncGroup Response (Version: 1) => throttle_time_ms error_code member_assignment throttle_time_ms => INT32 error_code => INT16 member_assignment => BYTES Field Description throttle_time_ms Duration in milliseconds for which the request was throttled due to quota violation (Zero if ...
code_fim
hard
{ "lang": "rust", "repo": "kosta/franzi", "path": "/franzi-proto/src/messages/sync_group.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fatho/ds2d path: /examples/batch.rs use cgmath::{Rad, Vector2}; use ds2d::{ graphics::{self, Color, Quad, Texture2D}, Context, GameResult, }; use log::error; pub struct HelloGame { batch: graphics::BatchRender, face: Texture2D, faces: Vec<(Vector2<f32>, Rad<f32>)>, } impl H...
code_fim
hard
{ "lang": "rust", "repo": "fatho/ds2d", "path": "/examples/batch.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { stderrlog::new().quiet(false).verbosity(5).init().unwrap(); let (event_loop, mut context) = match ds2d::ContextBuilder::new() .debug(true) .title("Hello World!") .build() { Ok(ok) => ok, Err(err) => { error!("Could not create con...
code_fim
hard
{ "lang": "rust", "repo": "fatho/ds2d", "path": "/examples/batch.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Connicpu/pixel-arena-game path: /src/graphics/textures.rs use crate::components::Sprite; use crate::graphics::core::GraphicsCore; use crate::graphics::wrappers::texture::TextureData; use std::collections::HashMap; use failure::Fallible; use glium::texture::{MipmapsOption, RawImage2d}; use inde...
code_fim
hard
{ "lang": "rust", "repo": "Connicpu/pixel-arena-game", "path": "/src/graphics/textures.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn coord(&self, id: SubtextureId) -> (u32, u32, u32) { let stride = self.cols; let pitch = stride * self.rows; let i = id.0; (i % stride, (i % pitch) / stride, i / pitch) } pub fn uvrect(&self, row: u32, col: u32) -> math2d::Rectf { let csize = 1.0...
code_fim
hard
{ "lang": "rust", "repo": "Connicpu/pixel-arena-game", "path": "/src/graphics/textures.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Texture { pub fn new(data: TextureData, rows: u32, cols: u32, pixel_art: bool) -> Self { let layers = data.texture().array_size(); Texture { data, rows, cols, layers, pixel_art, } } pub fn index(&self, ro...
code_fim
hard
{ "lang": "rust", "repo": "Connicpu/pixel-arena-game", "path": "/src/graphics/textures.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: giordi91/rust-sandbox path: /src/engine/platform.rs //module #[cfg(target_arch = "wasm32")] mod wasm; #[cfg(target_arch = "wasm32")] pub use wasm::*; #[cfg(not(target_arch = "wasm32"))] mod native; #[cfg(not(target_arch = "wasm32"))] pub use native::*; //imports use winit::{ ...
code_fim
hard
{ "lang": "rust", "repo": "giordi91/rust-sandbox", "path": "/src/engine/platform.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[cfg(not(target_arch = "wasm32"))] { //env_logger::init(); // Temporarily avoid srgb formats for the swapchain on the web // Since main can't be async, we're going to need to block futures::executor::block_on(run::<T>( even...
code_fim
hard
{ "lang": "rust", "repo": "giordi91/rust-sandbox", "path": "/src/engine/platform.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for i in 1..a.len() { for j in (1..=i).rev() { if a[j] < a[j-1] { common::swap(a, j, j-1); } } } }<|fim_prefix|>// repo: g178253/algorithm-rust path: /src/sort/insertion.rs use crate::sort::common; <|fim_middle|>pub fn sort(a: &mut Vec<i32>...
code_fim
medium
{ "lang": "rust", "repo": "g178253/algorithm-rust", "path": "/src/sort/insertion.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: g178253/algorithm-rust path: /src/sort/insertion.rs use crate::sort::common; <|fim_suffix|> for i in 1..a.len() { for j in (1..=i).rev() { if a[j] < a[j-1] { common::swap(a, j, j-1); } } } }<|fim_middle|>pub fn sort(a: &mut Vec<i32>...
code_fim
medium
{ "lang": "rust", "repo": "g178253/algorithm-rust", "path": "/src/sort/insertion.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DrunkFlamingo/kailua path: /kailua_types/src/l10nutils.rs use std::fmt; use std::cell::RefCell; use kailua_diag::message::{Locale, Localize}; #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)] pub struct Ordinal(pub usize); impl Localize for Ordinal { fn fmt_localized(&self, f: ...
code_fim
hard
{ "lang": "rust", "repo": "DrunkFlamingo/kailua", "path": "/kailua_types/src/l10nutils.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> write!(f, "`")?; // delayed iteration to handle the last "and" let mut first = true; while let Some(next) = iter.next() { if first { first = false; } else { write!(f, "`, `")?; } // keep the f...
code_fim
hard
{ "lang": "rust", "repo": "DrunkFlamingo/kailua", "path": "/kailua_types/src/l10nutils.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<'a, I: Iterator<Item=&'a Localize>> fmt::Display for QuotedList<'a, I> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let mut iter = self.iter.borrow_mut().take().expect( "QuotedList can be formatted only once" ); let mut cur = if let Some(cur) = ite...
code_fim
hard
{ "lang": "rust", "repo": "DrunkFlamingo/kailua", "path": "/kailua_types/src/l10nutils.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: theduke/rust path: /src/test/run-pass/union/union-nodrop.rs // Copyright 2016 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 /...
code_fim
medium
{ "lang": "rust", "repo": "theduke/rust", "path": "/src/test/run-pass/union/union-nodrop.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>union ActuallyDrop<T> {inner: T} impl<T> Drop for ActuallyDrop<T> { fn drop(&mut self) {} } fn main() { unsafe { // NoDrop should not make needs_drop true assert!(!needs_drop::<Foo>()); assert!(!needs_drop::<NoDrop<u8>>()); assert!(!needs_drop::<NoDrop<Box<u8>>>()...
code_fim
hard
{ "lang": "rust", "repo": "theduke/rust", "path": "/src/test/run-pass/union/union-nodrop.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: commerceblock/coordinator path: /src/util/testing.rs //! # Testing Utils //! //! Colleciton of helper functions used in tests module use std::env; use std::str::FromStr; use std::sync::Once; use bitcoin::hashes::{hex::FromHex, sha256d, Hash}; use bitcoin::secp256k1::PublicKey; use crate::chal...
code_fim
hard
{ "lang": "rust", "repo": "commerceblock/coordinator", "path": "/src/util/testing.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Generate dummy challenge state with specific challenge pub fn gen_challenge_state_with_challenge( request_hash: &sha256d::Hash, challenge_hash: &sha256d::Hash, ) -> ChallengeState { let request = ServiceRequest { txid: sha256d::Hash::from_slice(&[0xff as u8; 32]).unwrap(), ...
code_fim
hard
{ "lang": "rust", "repo": "commerceblock/coordinator", "path": "/src/util/testing.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Generate dummy challenge state pub fn gen_challenge_state(request_hash: &sha256d::Hash) -> ChallengeState { let request = ServiceRequest { txid: *request_hash, start_blockheight: 2, end_blockheight: 5, genesis_blockhash: gen_dummy_hash(0), fee_percentage: 5,...
code_fim
hard
{ "lang": "rust", "repo": "commerceblock/coordinator", "path": "/src/util/testing.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl From<ring::error::Unspecified> for Error { fn from(error: ring::error::Unspecified) -> Error { Error::InternalServerError(error.to_string()) } } impl From<std::str::Utf8Error> for Error { fn from(error: std::str::Utf8Error) -> Error { Error::InternalServerError(error.to_s...
code_fim
hard
{ "lang": "rust", "repo": "Ruddickmg/byThePeoples", "path": "/services/auth/src/error.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Ruddickmg/byThePeoples path: /services/auth/src/error.rs use serde::export::Formatter; #[derive(Debug, Clone)] pub enum Error { DatabaseError(database::Error), InternalServerError(String), Unauthorized(argonautica::Error), PasswordError(zxcvbn::ZxcvbnError), SystemTimeError(...
code_fim
hard
{ "lang": "rust", "repo": "Ruddickmg/byThePeoples", "path": "/services/auth/src/error.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl From<zxcvbn::ZxcvbnError> for Error { fn from(error: zxcvbn::ZxcvbnError) -> Error { Error::PasswordError(error) } } impl From<database::Error> for Error { fn from(error: database::Error) -> Error { Error::DatabaseError(error) } } impl From<argonautica::Error> for Er...
code_fim
medium
{ "lang": "rust", "repo": "Ruddickmg/byThePeoples", "path": "/services/auth/src/error.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pengt/defi_projects path: /layer2/zksync/core/lib/storage/src/data_restore/records.rs // External imports use serde_json::Value; // Workspace imports use serde::{Deserialize, Serialize}; use sqlx::FromRow; use zksync_types::{AccountId, Address, BlockNumber, TokenId, ZkSyncOp}; // Workspace impor...
code_fim
hard
{ "lang": "rust", "repo": "pengt/defi_projects", "path": "/layer2/zksync/core/lib/storage/src/data_restore/records.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl NewZkSyncOp { pub fn prepare_stored_op( franklin_op: &ZkSyncOp, block: BlockNumber, fee_account: AccountId, ) -> Self { Self { block_num: i64::from(block), operation: serde_json::to_value(franklin_op.clone()).unwrap(), fee_ac...
code_fim
hard
{ "lang": "rust", "repo": "pengt/defi_projects", "path": "/layer2/zksync/core/lib/storage/src/data_restore/records.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl StoredZkSyncOp { pub fn into_franklin_op(self) -> ZkSyncOp { serde_json::from_value(self.operation).expect("Unparsable ZkSyncOp in db") } } #[derive(Debug, Clone)] pub struct NewZkSyncOp { pub block_num: i64, pub operation: Value, pub fee_account: i64, } impl NewZkSyncOp ...
code_fim
hard
{ "lang": "rust", "repo": "pengt/defi_projects", "path": "/layer2/zksync/core/lib/storage/src/data_restore/records.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: treeman/rqr path: /examples/simple.rs use rqr::{Qr, StringRenderer}; <|fim_suffix|> let qr = Qr::new("HELLO WORLD").unwrap(); let s = StringRenderer::new().render(&qr); println!("{}", s); }<|fim_middle|>fn main() {
code_fim
easy
{ "lang": "rust", "repo": "treeman/rqr", "path": "/examples/simple.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let qr = Qr::new("HELLO WORLD").unwrap(); let s = StringRenderer::new().render(&qr); println!("{}", s); }<|fim_prefix|>// repo: treeman/rqr path: /examples/simple.rs use rqr::{Qr, StringRenderer}; <|fim_middle|>fn main() {
code_fim
easy
{ "lang": "rust", "repo": "treeman/rqr", "path": "/examples/simple.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn clear_completed_button() -> impl Element { let (hovered, hovered_signal) = Mutable::new_and_signal(false); Button::new() .s(Align::new().right()) .s(Font::new().line(FontLine::new().underline_signal(hovered_signal))) .on_hovered_change(move |is_hovered| hovered.set_neq(i...
code_fim
hard
{ "lang": "rust", "repo": "dragon1061/MoonZoon", "path": "/examples/todomvc/frontend/src/app/view.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dragon1061/MoonZoon path: /examples/todomvc/frontend/src/app/view.rs use super::{Filter, Todo}; use crate::router::{router, Route}; use std::sync::Arc; use strum::IntoEnumIterator; use zoon::*; pub fn root() -> impl Element { Column::new() .s(Width::fill()) .s(Height::fill()...
code_fim
hard
{ "lang": "rust", "repo": "dragon1061/MoonZoon", "path": "/examples/todomvc/frontend/src/app/view.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn eval_prim(&mut self, prim_head: &str, args: &[Eref]) -> EvalResult<Expr> { if self.trace { println!("~p {} {:?}", prim_head, args); } // println!("evaling prim: {} {:?}", prim_head, args); match prim_head { "Prim`Print" => { fo...
code_fim
hard
{ "lang": "rust", "repo": "rjeli/maxylla", "path": "/src/eval.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rjeli/maxylla path: /src/eval.rs use permutohedron::Heap; use std::cmp::Ordering; use std::convert::TryInto; use std::default::Default; use std::fs; use std::str::FromStr; use std::sync::atomic; use std::thread; use std::time::{Duration, SystemTime}; use crate::pattern::run_unify; use crate::ut...
code_fim
hard
{ "lang": "rust", "repo": "rjeli/maxylla", "path": "/src/eval.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn set_attr(&mut self, s: &str, attr_s: &str) { if !self.attrs.contains_key(s) { self.attrs.insert(s.to_owned(), vec![]); } let attr = Attr::from_str(attr_s).unwrap(); self.attrs.get_mut(s).unwrap().push(attr); } pub fn has_attr(&self, s: &str, attr...
code_fim
hard
{ "lang": "rust", "repo": "rjeli/maxylla", "path": "/src/eval.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn unexpected_msg_status(expected: &str, actually: Option<rpc::PutCallbackReply>) -> Status { let msg = format!( "Wrong message order from client, expected {:?}, actually: {:?}", expected, actually ); log::warn!("{}", msg); Status::invalid_argument(msg.to_string()) } p...
code_fim
hard
{ "lang": "rust", "repo": "RicoGit/ope-btree", "path": "/server/grpc/src/grpc/errors.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: RicoGit/ope-btree path: /server/grpc/src/grpc/errors.rs use crate::grpc::rpc; use protocol::ProtocolError; use tokio::sync::mpsc::error::SendError; use tonic::{Response, Status}; pub fn status_to_protocol_err(status: Status) -> ProtocolError { let msg = format!("Receiving from client error:...
code_fim
hard
{ "lang": "rust", "repo": "RicoGit/ope-btree", "path": "/server/grpc/src/grpc/errors.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn send_err_to_status<T>(_msg: Result<Response<T>, Status>) -> Status { let msg = format!("Sending reply to client failed"); Status::internal(msg) } pub fn unexpected_msg_status(expected: &str, actually: Option<rpc::PutCallbackReply>) -> Status { let msg = format!( "Wrong message ...
code_fim
medium
{ "lang": "rust", "repo": "RicoGit/ope-btree", "path": "/server/grpc/src/grpc/errors.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.rpc_request::<RPCBlock>( "eth_getUncleByBlockNumberAndIndex", vec![number.to_string(), index.to_string()], ) } } pub struct NormalGethRPCClient { endpoint: String, free_id: usize, http: Client, } impl NormalGethRPCClient { pub fn new(endpo...
code_fim
hard
{ "lang": "rust", "repo": "60ke/sputnikvm", "path": "/gethrpc/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn send_raw_transaction(&mut self, data: &str) -> String { self.rpc_request::<String>("eth_sendRawTransaction", vec![data.to_string()]) } fn call(&mut self, transaction: RPCCall, number: &str) -> String { self.rpc_object_request::<(RPCCall, String), String>( "eth_c...
code_fim
hard
{ "lang": "rust", "repo": "60ke/sputnikvm", "path": "/gethrpc/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 60ke/sputnikvm path: /gethrpc/src/lib.rs extern crate serde; extern crate serde_json; extern crate hyper; extern crate hyper_native_tls; #[macro_use] extern crate serde_derive; mod record; pub use record::{RecordGethRPCClient, CachedGethRPCClient}; use std::io::Read; use hyper::header::Conte...
code_fim
hard
{ "lang": "rust", "repo": "60ke/sputnikvm", "path": "/gethrpc/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub struct CheckResult { pub package_name: String, pub support: CrateSupport, pub active_features: Vec<Feature>, } impl CheckResult { pub fn no_std_itself(&self) -> bool { match self.support { CrateSupport::ProcMacro => true, CrateSupport::OnlyWithoutFeatur...
code_fim
hard
{ "lang": "rust", "repo": "hobofan/cargo-nono", "path": "/src/check.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hobofan/cargo-nono path: /src/check.rs use proc_macro2; use proc_macro2::TokenTree; use crate::check_source::*; use crate::ext::*; #[derive(Debug, PartialEq, Eq)] pub enum CrateSupport { OnlyWithoutFeature(String), /// proc macros are not actually linked, so they don't hinder no_std su...
code_fim
hard
{ "lang": "rust", "repo": "hobofan/cargo-nono", "path": "/src/check.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jeandudey/cc13x2-rs path: /src/cpu_dwt/function1.rs field `MATCHED`"] pub type MATCHED_R = crate::R<bool, bool>; #[doc = "Write proxy for field `MATCHED`"] pub struct MATCHED_W<'a> { w: &'a mut W, } impl<'a> MATCHED_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn ...
code_fim
hard
{ "lang": "rust", "repo": "jeandudey/cc13x2-rs", "path": "/src/cpu_dwt/function1.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jeandudey/cc13x2-rs path: /src/cpu_dwt/function1.rs a> { w: &'a mut W, } impl<'a> DATAVADDR1_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 & !(0x0f << 16)) | (((value as u32...
code_fim
hard
{ "lang": "rust", "repo": "jeandudey/cc13x2-rs", "path": "/src/cpu_dwt/function1.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[doc = "Bits 6:7 - 7:6\\] Software should not rely on the value of a reserved. Writing any other value than the reset value may result in undefined behavior."] #[inline(always)] pub fn reserved6(&self) -> RESERVED6_R { RESERVED6_R::new(((self.bits >> 6) & 0x03) as u8) } #[doc = "B...
code_fim
hard
{ "lang": "rust", "repo": "jeandudey/cc13x2-rs", "path": "/src/cpu_dwt/function1.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Abogical/netutils path: /src/wget/main.rs #![deny(warnings)] extern crate hyper; extern crate hyper_rustls; use std::env; use std::fs::File; use std::io::{stderr, stdout, Read, Write}; use std::process; use std::time::Duration; use hyper::Client; use hyper::net::HttpsConnector; use hyper::head...
code_fim
hard
{ "lang": "rust", "repo": "Abogical/netutils", "path": "/src/wget/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut args = env::args().skip(1); match args.next() { Some(url) => match args.next() { Some(path) => match File::create(&path) { Ok(mut file) => { wget(&url, &mut file); if let Err(err) = file.sync_all() { ...
code_fim
hard
{ "lang": "rust", "repo": "Abogical/netutils", "path": "/src/wget/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: geoffroyvergne/crawler path: /rust/src/http.rs use isahc::prelude::*; use crate::model::HttpValues; pub fn get_http(url: &str) -> Result<HttpValues, isahc::Error> { let mut response = isahc::get(url)?; if !response.status().is_success() { panic!("failed to get a successful resp...
code_fim
hard
{ "lang": "rust", "repo": "geoffroyvergne/crawler", "path": "/rust/src/http.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut headers = std::collections::HashMap::new(); for key in response.headers().keys() { let value = response.headers().get(key); match value { Some(v) => headers.insert(key.to_string(), v.to_str().unwrap().to_string()), None => headers.insert(key...
code_fim
medium
{ "lang": "rust", "repo": "geoffroyvergne/crawler", "path": "/rust/src/http.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sharkAndshark/geoengine path: /datatypes/src/collections/feature_collection_builder.rs use crate::collections::batch_builder::RawFeatureCollectionBuilder; use crate::collections::{error, FeatureCollection, FeatureCollectionError}; use crate::primitives::{FeatureDataType, FeatureDataValue, Geomet...
code_fim
hard
{ "lang": "rust", "repo": "sharkAndshark/geoengine", "path": "/datatypes/src/collections/feature_collection_builder.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Ok(()) } /// Indicate a finished row pub fn finish_row(&mut self) { self.rows += 1; } /// Return the number of finished rows pub fn len(&self) -> usize { self.rows } /// Checks whether there was no row finished yet pub fn is_empty(&self) -> bo...
code_fim
hard
{ "lang": "rust", "repo": "sharkAndshark/geoengine", "path": "/datatypes/src/collections/feature_collection_builder.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: openethereum/pwasm-abi path: /tests/src/payable.rs #![allow(dead_code)] use pwasm_abi_derive::eth_abi; use pwasm_abi::eth::EndpointInterface; use pwasm_test::{ext_reset}; const PAYLOAD_BAZ: &[u8] = &[ 0xcd, 0xcd, 0x77, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, ...
code_fim
hard
{ "lang": "rust", "repo": "openethereum/pwasm-abi", "path": "/tests/src/payable.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn payable_method_ret() { ext_reset(|e| e.value(1.into())); PayableEndpoint::new(PayableContractInstance).dispatch(PAYLOAD_BOO); } #[test] fn payable_constructor_no_value() { PayableEndpoint::new(PayableContractInstance).dispatch_ctor(&[]); } #[test] fn payable_method_no_value() { PayableEnd...
code_fim
hard
{ "lang": "rust", "repo": "openethereum/pwasm-abi", "path": "/tests/src/payable.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Default)] pub struct RenameHandler {} #[async_trait::async_trait] impl RequestHandler for RenameHandler { async fn handle( &self, prequest: PolymorphicRequest, _: crate::shared::RequestContext, ) -> Result<Option<String>, String> { let request: Request<Ren...
code_fim
hard
{ "lang": "rust", "repo": "sensudata/flux-lsp", "path": "/src/handlers/rename.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sensudata/flux-lsp path: /src/handlers/rename.rs use crate::handlers::references::find_references; use crate::handlers::RequestHandler; use crate::protocol::properties::TextEdit; use crate::protocol::requests::{ PolymorphicRequest, RenameParams, Request, }; use crate::protocol::responses::{R...
code_fim
hard
{ "lang": "rust", "repo": "sensudata/flux-lsp", "path": "/src/handlers/rename.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> edits.push(text_edit); } } } let response = Response::new(request.id, Some(workspace_edit)); let json = response.to_json()?; Ok(Some(json)) } }<|fim_prefix|>// repo: sensudata/flux-lsp path: /src/handlers/r...
code_fim
hard
{ "lang": "rust", "repo": "sensudata/flux-lsp", "path": "/src/handlers/rename.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: suzu6/trial-code path: /rust/atcoder/arc117/src/bin/c.rs fn main() { proconio::input! { n: usize, s: String, } let mut cs: Vec<char> = s.chars().collect(); // println!("{:?}", cs); <|fim_suffix|> if a == 'B' { if b == 'W' { return 'R'; ...
code_fim
hard
{ "lang": "rust", "repo": "suzu6/trial-code", "path": "/rust/atcoder/arc117/src/bin/c.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn se(a: char, b: char)->char{ if a == 'B' { if b == 'W' { return 'R'; }else { return 'W'; } } else if a == 'W' { if b == 'B' { return 'R'; }else { return 'B'; } } else { if b == 'B' { ...
code_fim
hard
{ "lang": "rust", "repo": "suzu6/trial-code", "path": "/rust/atcoder/arc117/src/bin/c.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sorajate/tsclientlib path: /tsclientlib/examples/audio.rs //! This example connects to a teamspeak instance and joins a channel. //! The connected bot-identity will listen on your microphone and send everything to the current //! channel. In parallel, the program will play back all other clients...
code_fim
hard
{ "lang": "rust", "repo": "sorajate/tsclientlib", "path": "/tsclientlib/examples/audio.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let r = con .events() .try_filter(|e| future::ready(matches!(e, StreamItem::BookEvents(_)))) .next() .await; if let Some(r) = r { r?; } let (send, mut recv) = mpsc::channel(5); { let mut a2t = audiodata.a2ts.lock().unwrap(); a2t.set_listener(send); a2t.set_volume(args.volume); a2t....
code_fim
hard
{ "lang": "rust", "repo": "sorajate/tsclientlib", "path": "/tsclientlib/examples/audio.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn fib(fib_num:i32) -> u64 { if fib_num==1 { 1 } else if fib_num==2 { 1 } else { fib(fib_num-1) + fib(fib_num-2) } }<|fim_prefix|>// repo: Rand01ph/learning-rust path: /fib/src/main.rs use std::io; fn main() { println!("输入要求的N阶fib数列"); let mut num = String::new(); io::stdin().r...
code_fim
medium
{ "lang": "rust", "repo": "Rand01ph/learning-rust", "path": "/fib/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let total = fib(num); println!("结果为:{}", total); } fn fib(fib_num:i32) -> u64 { if fib_num==1 { 1 } else if fib_num==2 { 1 } else { fib(fib_num-1) + fib(fib_num-2) } }<|fim_prefix|>// repo: Rand01ph/learning-rust path: /fib/src/main.rs use std::io; fn main() { println!("输入要求的...
code_fim
easy
{ "lang": "rust", "repo": "Rand01ph/learning-rust", "path": "/fib/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Rand01ph/learning-rust path: /fib/src/main.rs use std::io; fn main() { println!("输入要求的N阶fib数列"); let mut num = String::new(); io::stdin().read_line(&mut num) .expect("Failed to read line"); let num: i32 = num.trim().parse() .expect("需要输入一个数字"); println!("输...
code_fim
medium
{ "lang": "rust", "repo": "Rand01ph/learning-rust", "path": "/fib/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sgrowe/compiler-in-rust path: /compiler-core/src/code_gen.rs use super::ast::*; use super::operators::*; use super::tokens::*; use super::wasm::*; use std::collections::BTreeSet; pub fn ast_to_wasm<'a>(ast: &Ast<'a>) -> Result<WasmModule<'a>, CodeGenError> { use self::Declaration::*; us...
code_fim
hard
{ "lang": "rust", "repo": "sgrowe/compiler-in-rust", "path": "/compiler-core/src/code_gen.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> compile_expression(left, &mut instr)?; compile_expression(right, &mut instr)?; instr.push(binary_op_to_wasm_instruction(*operator)); } FunctionCall { name, args } => { instr.reserve(args.len() + 1); for expr in args { ...
code_fim
hard
{ "lang": "rust", "repo": "sgrowe/compiler-in-rust", "path": "/compiler-core/src/code_gen.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mbrukman/ErlangRT path: /lib-erlangrt/src/term/boxed/export.rs use crate::{ defs::{ByteSize, WordSize}, emulator::{export, heap::Heap, mfa::MFArity}, fail::{Error, RtResult}, term::{ boxed::{BoxHeader, BOXTYPETAG_EXPORT}, lterm::*, }, }; use core::{mem::size_of, ptr}; #[allow(...
code_fim
hard
{ "lang": "rust", "repo": "mbrukman/ErlangRT", "path": "/lib-erlangrt/src/term/boxed/export.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[allow(dead_code)] pub unsafe fn const_from_term(t: LTerm) -> RtResult<*const Export> { helper_get_const_from_boxed_term::<Export>( t, BOXTYPETAG_EXPORT, Error::BoxedIsNotAnExport, ) } #[allow(dead_code)] pub unsafe fn mut_from_term(t: LTerm) -> RtResult<*mut Export> ...
code_fim
hard
{ "lang": "rust", "repo": "mbrukman/ErlangRT", "path": "/lib-erlangrt/src/term/boxed/export.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if pre_r2c { kernels.push(new_real_to_complex_kernel(options.len)); } if use_realfft && options.inverse { kernels.push(new_real_fft_pre_post_process_kernel(options.len, true)); } match kernel_type { KernelType::Dif => { ...
code_fim
hard
{ "lang": "rust", "repo": "yvt/yfft-rs", "path": "/src/setup.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yvt/yfft-rs path: /src/setup.rs use super::kernel::{ new_bit_reversal_kernel, new_half_complex_to_complex_kernel, new_real_fft_pre_post_process_kernel, new_real_to_complex_kernel, Kernel, KernelCreationParams, KernelType, }; use super::Num; use std::error; use std::fmt; use std::resu...
code_fim
hard
{ "lang": "rust", "repo": "yvt/yfft-rs", "path": "/src/setup.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> match kernel_type { KernelType::Dif => { let mut unit = fft_len; for radix_ref in &radixes { let radix = *radix_ref; unit /= radix; kernels.push(Kernel::new(&KernelCreationParams { ...
code_fim
hard
{ "lang": "rust", "repo": "yvt/yfft-rs", "path": "/src/setup.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xoyo24/nushell path: /crates/nu-command/src/core_commands/overlay/add.rs use nu_engine::{eval_block, CallExt}; use nu_protocol::ast::Call; use nu_protocol::engine::{Command, EngineState, Stack}; use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, Spanned, SyntaxShape}; use...
code_fim
hard
{ "lang": "rust", "repo": "xoyo24/nushell", "path": "/crates/nu-command/src/core_commands/overlay/add.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Jascha-N/commcomm-rs path: /src/platform/windows/com.rs use super::cvt; use ole32; use winapi as w; use std::io; use std::mem; use std::ops::{Deref, DerefMut}; use std::ptr; pub unsafe trait Interface { fn iid() -> &'static w::IID; } pub struct Pointer<T>(*mut T); impl<T> Pointer<T> { ...
code_fim
hard
{ "lang": "rust", "repo": "Jascha-N/commcomm-rs", "path": "/src/platform/windows/com.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl<T: Interface> Pointer<T> { pub fn create(clsid: &w::CLSID) -> io::Result<Pointer<T>> { unsafe { let mut instance = mem::uninitialized(); cvt(ole32::CoCreateInstance(clsid, ptr::null_mut(), w::CLSCTX_ALL, T::iid(), &mut instan...
code_fim
hard
{ "lang": "rust", "repo": "Jascha-N/commcomm-rs", "path": "/src/platform/windows/com.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn downcast<U: Interface>(&self) -> Option<Pointer<U>> { unsafe { let mut instance = mem::uninitialized(); cvt(self.as_unknown().QueryInterface(U::iid(), &mut instance as *mut _ as *mut _)).map(|_| { Some(Pointer(instance)) }).unwrap_or(N...
code_fim
hard
{ "lang": "rust", "repo": "Jascha-N/commcomm-rs", "path": "/src/platform/windows/com.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jz4o/codingames path: /rust/practice/classic_puzzle/easy/frame-the-picture.rs use std::io; macro_rules! parse_input { ($x:expr, $t:ident) => ($x.trim().parse::<$t>().unwrap()) } /** * Auto-generated code below aims at helping you parse * the standard input according to the problem statem...
code_fim
medium
{ "lang": "rust", "repo": "jz4o/codingames", "path": "/rust/practice/classic_puzzle/easy/frame-the-picture.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for i in 0..grid.len() { grid[i].insert(0, frame_char.to_string()); grid[i].push(frame_char.to_string()); } grid.insert(0, vec![frame_char.to_string();grid.first().unwrap().len()]); grid.push(vec![frame_char.to_string();grid.first().unwrap().len()]); return grid; }<|fi...
code_fim
hard
{ "lang": "rust", "repo": "jz4o/codingames", "path": "/rust/practice/classic_puzzle/easy/frame-the-picture.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Kuift/bevy_mod_picking path: /examples/events.rs use bevy::prelude::*; use bevy_mod_picking::{ HighlightablePickingPlugin, InteractablePickingPlugin, PickableBundle, PickingCameraBundle, PickingEvent, PickingPlugin, }; fn main() { App::new() .add_plugins(DefaultPlugins) ...
code_fim
medium
{ "lang": "rust", "repo": "Kuift/bevy_mod_picking", "path": "/examples/events.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: brunoczim/thedes path: /src/matter/ground.rs use crate::{ graphics::CMYColor, math::plane::{Camera, Coord2, Nat}, terminal, }; use std::fmt; /// A ground block (background color). #[derive( Debug, Clone, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, ...
code_fim
hard
{ "lang": "rust", "repo": "brunoczim/thedes", "path": "/src/matter/ground.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fmt.pad(match self { Ground::Grass => "grass", Ground::Sand => "sand", Ground::Rock => "rock", Ground::Path => "path", }) } } impl Ground { /// Renders this ground type on the screen. pub fn render( &self, pos: Co...
code_fim
medium
{ "lang": "rust", "repo": "brunoczim/thedes", "path": "/src/matter/ground.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: neqcold/rust-stuff path: /concurrency/channel.rs use std::sync::mpsc; use std::thread; use std::time::Duration; use std::io; use std::io::prelude::*; <|fim_suffix|> println!("smokin' weed in the main thread"); println!("yeee bo"); for _ in 0..50 { print!("i"); io::std...
code_fim
hard
{ "lang": "rust", "repo": "neqcold/rust-stuff", "path": "/concurrency/channel.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let (tx, rx) = mpsc::channel(); println!("doing some complex calculations in the other thread while"); thread::spawn(move || { thread::sleep(Duration::from_secs(2)); tx.send(1337).unwrap(); }); println!("smokin' weed in the main thread"); println!("yeee bo"); ...
code_fim
medium
{ "lang": "rust", "repo": "neqcold/rust-stuff", "path": "/concurrency/channel.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn mass_intersect_multi_test() { let mut test_vec = vec![]; let test1 = BitVec::from_elem(8, true); let test2 = BitVec::from_bytes(&[0b11110000]); let test3 = BitVec::from_bytes(&[0b11110011]); test_vec.push(test1); test_vec.push(test2); test_vec.push(test3); let ou...
code_fim
hard
{ "lang": "rust", "repo": "deepinthebuild/rust-wfc", "path": "/src/utils.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: deepinthebuild/rust-wfc path: /src/utils.rs use ndarray::prelude::*; use rand::distributions::{Range, IndependentSample}; use rand; use bit_vec::BitVec; pub fn generate_rotations_and_reflections<T: Copy>(image_data: &Array2<T>) -> Vec<Array2<T>> { let mut output = Vec::with_capacity(8); ...
code_fim
hard
{ "lang": "rust", "repo": "deepinthebuild/rust-wfc", "path": "/src/utils.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn mass_intersect_single_test() { let test_vec = vec![BitVec::from_elem(10, true)]; let output = mass_intersect(test_vec); let result = Some(BitVec::from_elem(10, true)); assert_eq!(output, result); } #[test] fn mass_intersect_multi_test() { let mut test_vec = vec![]; let ...
code_fim
hard
{ "lang": "rust", "repo": "deepinthebuild/rust-wfc", "path": "/src/utils.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: szqh97/rust-projects path: /rustprimer/vec.rs #[warn(unused_variables)] fn main() { let v0: Vec<i32> = Vec::new(); let v1: Vec<i32> = vec![]; let v2 = vec![1,2,3,4,4]; let v3 = vec![0;10]; println!("{:?}", v2); <|fim_suffix|> println!("{:?}, {:?}", hello, h2); let v: ...
code_fim
medium
{ "lang": "rust", "repo": "szqh97/rust-projects", "path": "/rustprimer/vec.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: szqh97/rust-projects path: /rustprimer/vec.rs #[warn(unused_variables)] fn main() { <|fim_suffix|> println!("{:?}, {:?}", hello, h2); let v: Vec<_> = (1..5).collect(); println!("{:?}", v.get(10)); }<|fim_middle|> let v0: Vec<i32> = Vec::new(); let v1: Vec<i32> = vec![]; let...
code_fim
hard
{ "lang": "rust", "repo": "szqh97/rust-projects", "path": "/rustprimer/vec.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let hello = "hello world"; let h2: &'static str = "Hello again"; println!("{:?}, {:?}", hello, h2); let v: Vec<_> = (1..5).collect(); println!("{:?}", v.get(10)); }<|fim_prefix|>// repo: szqh97/rust-projects path: /rustprimer/vec.rs #[warn(unused_variables)] fn main() { <|fim_middle|...
code_fim
medium
{ "lang": "rust", "repo": "szqh97/rust-projects", "path": "/rustprimer/vec.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn should_compute_test_input() { let input = vec![ NoOp(0), Acc(1), Jmp(4), Acc(3), Jmp(-3), Acc(-99), Acc(1), Jmp(-4), Acc(6) ]; let (i, nominal) = Assembly:...
code_fim
hard
{ "lang": "rust", "repo": "FlorianRohm/aoc2020-rs", "path": "/day8/src/assembly.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: FlorianRohm/aoc2020-rs path: /day8/src/assembly.rs use crate::op::Op; type EndedNominally = bool; type AlreadyVisited = bool; pub struct Assembly { instructions: Vec<(Op, AlreadyVisited)>, pointer: usize, accumulator: i32, } <|fim_suffix|> pub fn run(&mut self) -> (i32, EndedNo...
code_fim
hard
{ "lang": "rust", "repo": "FlorianRohm/aoc2020-rs", "path": "/day8/src/assembly.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests { use super::*; use super::Op::*; #[test] fn should_compute_test_input() { let input = vec![ NoOp(0), Acc(1), Jmp(4), Acc(3), Jmp(-3), Acc(-99), Acc(1), Jmp(-4), ...
code_fim
hard
{ "lang": "rust", "repo": "FlorianRohm/aoc2020-rs", "path": "/day8/src/assembly.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Yoshanuikabundi/mbar-rs path: /examples/pmf.rs use anyhow::Result; use itertools::Itertools; use mbar_rs::mbar::*; use mbar_rs::testsystems::*; use ndarray::{array, s, Array1, Axis}; /// Produce a sorted copy of an array fn sorted(s: &Array1<f64>) -> Array1<f64> { let mut new = s.clone(); ...
code_fim
hard
{ "lang": "rust", "repo": "Yoshanuikabundi/mbar-rs", "path": "/examples/pmf.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Correct for unequally spaced bins to get a PMF on uniform measure let f_i_corrected: Vec<_> = pmf .f_i .iter() .zip(bin_widths.iter()) .map(|(f, w)| f - w.ln()) .collect(); println!("{:?}", &f_i_corrected); println!("{:?}", bin_edges); Ok((...
code_fim
hard
{ "lang": "rust", "repo": "Yoshanuikabundi/mbar-rs", "path": "/examples/pmf.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Divide x_n into equally populated bins let n_bins = 10; let n_tot = x_n.len(); let x_n_sorted = sorted(&x_n); let bin_size = n_tot / n_bins; let mut bin_edges = x_n_sorted.slice(s![..;bin_size]).to_vec(); bin_edges.push(x_n_sorted[n_tot - 1] + 0.001); let bin_n = digiti...
code_fim
hard
{ "lang": "rust", "repo": "Yoshanuikabundi/mbar-rs", "path": "/examples/pmf.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Atul9/faunadb-rust path: /src/prelude.rs pub use crate::{ client::*, expr::*, query:<|fim_suffix|>::*, datetime::*, logical::*, math::*, misc::*, read::*, set::*, string::*, write::*, Query, }, };<|fim_middle|>:{ auth::*, basic::*, collection::*, conversion
code_fim
easy
{ "lang": "rust", "repo": "Atul9/faunadb-rust", "path": "/src/prelude.rs", "mode": "psm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|>::*, datetime::*, logical::*, math::*, misc::*, read::*, set::*, string::*, write::*, Query, }, };<|fim_prefix|>// repo: Atul9/faunadb-rust path: /src/prelude.rs pub use crate::{ client::*, expr::*, query:<|fim_middle|>:{ auth::*, basic::*, collection::*, conversion
code_fim
easy
{ "lang": "rust", "repo": "Atul9/faunadb-rust", "path": "/src/prelude.rs", "mode": "spm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }