text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: avhz/QuantMath path: /src/models/mod.rs pub mod blackdiffusion; use crate::core::factories::{Qrc, Registry, TypeId}; use crate::core::qm; use crate::dates::datetime::DateDayFraction; use crate::dates::Date; use crate::instruments::MonteCarloContext; use crate::instruments::MonteCarloDependencie...
code_fim
hard
{ "lang": "rust", "repo": "avhz/QuantMath", "path": "/src/models/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl PrimeBag { pub fn new() -> PrimeBag { PrimeBag { prev: Vec::new(), pit: Primes::all(), } } pub fn minprime(&mut self, idx: &mut usize, x: &mut BigUint, y: &mut BigUint) -> usize { loop { let len = self.prev.len(); if *idx == len { self.prev.push(BigUint::from(self.pit.next()...
code_fim
medium
{ "lang": "rust", "repo": "serprex/NULL", "path": "/src/primes.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: serprex/NULL path: /src/primes.rs use num_bigint::BigUint; use num_integer::Integer; use num_traits::Zero; use primal_sieve::Primes; <|fim_suffix|>impl PrimeBag { pub fn new() -> PrimeBag { PrimeBag { prev: Vec::new(), pit: Primes::all(), } } pub fn minprime(&mut self, idx: &mut u...
code_fim
medium
{ "lang": "rust", "repo": "serprex/NULL", "path": "/src/primes.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn get_user_id(&self) -> Option<i32> { self.user.as_ref().map(|user| user.id) } }<|fim_prefix|>// repo: m-basov/rust-realworld-example-app path: /gql/src/context.rs use crate::error::Result; use conduit::{PgPool, User}; use server::{auth, warp, with_state, ServerError, ServerState}; u...
code_fim
hard
{ "lang": "rust", "repo": "m-basov/rust-realworld-example-app", "path": "/gql/src/context.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: m-basov/rust-realworld-example-app path: /gql/src/context.rs use crate::error::Result; use conduit::{PgPool, User}; use server::{auth, warp, with_state, ServerError, ServerState}; use std::convert::Infallible; use std::sync::Arc; use warp::Filter; #[derive(Clone)] pub struct Context { pub s...
code_fim
medium
{ "lang": "rust", "repo": "m-basov/rust-realworld-example-app", "path": "/gql/src/context.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> target.clear_color_and_depth((0.6, 0.9, 0.9, 1.0), 1.0); // Sky color target .draw( &vertex_buffer, &index_buffer, &program, &uniform! {model: model, view: view, projection: projection, ...
code_fim
hard
{ "lang": "rust", "repo": "rokonio/glium_learning", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rokonio/glium_learning path: /src/main.rs #[macro_use] extern crate glium; extern crate image; extern crate nalgebra_glm as glm; use glium::glutin::{self, event_loop::EventLoop, window::WindowBuilder, ContextBuilder}; use glium::Surface; mod camera; mod keyboard_handler; mod setup; #[path = "....
code_fim
hard
{ "lang": "rust", "repo": "rokonio/glium_learning", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut add_block_indice = 0; world.camera.turn((0., 0.)); event_loop.run(move |event, _, control_flow| { if let glutin::event::Event::WindowEvent { event, .. } = event { if let glutin::event::WindowEvent::CloseRequested = event { *control_flow = glutin::...
code_fim
hard
{ "lang": "rust", "repo": "rokonio/glium_learning", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> println!("SHA-256 digest is {}", HEXUPPER.encode(digest.as_ref())); Ok(()) }<|fim_prefix|>// repo: sandkoan/wretch path: /src/main.rs use data_encoding::HEXUPPER; use ring::digest::{Context, Digest, SHA256}; use std::io::{Read, BufReader}; use std::fs::File; fn sha256_digest<R: Read>(mut reade...
code_fim
hard
{ "lang": "rust", "repo": "sandkoan/wretch", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sandkoan/wretch path: /src/main.rs use data_encoding::HEXUPPER; use ring::digest::{Context, Digest, SHA256}; use std::io::{Read, BufReader}; use std::fs::File; fn sha256_digest<R: Read>(mut reader: R) -> Result<Digest, E> { let mut context = Context::new(&SHA256); let mut buffer = [0; ...
code_fim
medium
{ "lang": "rust", "repo": "sandkoan/wretch", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> where Self::Arguments: ArgumentsCompatible<A> { // TODO: allow to change connection type // TODO: meta_object::Connection should have operator bool() unsafe { ::object::Object::connect_static((self.object() as *const ::object::Object, Self::r...
code_fim
hard
{ "lang": "rust", "repo": "aristotle9/qt_generator-output", "path": "/qt_core/src/connection.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Returns a null-terminated Latin-1 string that identifies /// this signal or slot within the owning `QObject` in Qt system. fn receiver_id() -> &'static [u8]; } /// A Qt signal. pub trait Signal: Receiver { /// Connects this signal to another signal or slot with compatible arguments. fn conn...
code_fim
hard
{ "lang": "rust", "repo": "aristotle9/qt_generator-output", "path": "/qt_core/src/connection.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aristotle9/qt_generator-output path: /qt_core/src/connection.rs //! Types and functions for connecting Qt signals and slots. use libc::c_char; /// Argument types compatible for signal connection. /// /// Qt allows to connect senders to receivers if their argument types are the same. /// Additi...
code_fim
medium
{ "lang": "rust", "repo": "aristotle9/qt_generator-output", "path": "/qt_core/src/connection.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let actual_database = client .query("SELECT currentDatabase()") .fetch_one::<String>() .await .expect("currentDatabase selected"); assert!(actual_database.starts_with(db_prefix)); }<|fim_prefix|>// repo: injecto/rusty-tub path: /tests/clickhouse_test.rs #![cfg(feat...
code_fim
hard
{ "lang": "rust", "repo": "injecto/rusty-tub", "path": "/tests/clickhouse_test.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: injecto/rusty-tub path: /tests/clickhouse_test.rs #![cfg(feature = "clickhouse")] use rusty_tub::clickhouse::ClickHouse; #[tokio::test] async fn clickhouse_integration() { let _ = tracing_subscriber::fmt() .with_env_filter("rusty-tub=trace") .try_init(); <|fim_suffix|> ...
code_fim
medium
{ "lang": "rust", "repo": "injecto/rusty-tub", "path": "/tests/clickhouse_test.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>b fn ovl0int(&self) -> OVL0INTR { let bits = { const MASK: bool = true; const OFFSET: u8 = 17; ((self.bits >> OFFSET) & MASK as u32) != 0 }; OVL0INTR { bits } } #[doc = "Bit 16 - Timebase Interrupt Flag, W12C"] #[inline] pub fn tb...
code_fim
hard
{ "lang": "rust", "repo": "gregokent/tms570", "path": "/src/rti/rtiintflag/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gregokent/tms570 path: /src/rti/rtiintflag/mod.rs #[doc = r" Value read from the register"] pub struct R { bits: u32, } #[doc = r" Value to write to the register"] pub struct W { bits: u32, } impl super::RTIINTFLAG { #[doc = r" Modifies the contents of the register"] #[inline] ...
code_fim
hard
{ "lang": "rust", "repo": "gregokent/tms570", "path": "/src/rti/rtiintflag/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let convex = Convex::new(points); // Convex does not compute explicitely the convex hull (which has 4 vertices)! assert!(convex.points().len() == 5); }<|fim_prefix|>// repo: futile/ncollide path: /examples/convex2d.rs extern crate nalgebra as na; extern crate ncollide; use na::Pnt2; use nco...
code_fim
medium
{ "lang": "rust", "repo": "futile/ncollide", "path": "/examples/convex2d.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> // Convex does not compute explicitely the convex hull (which has 4 vertices)! assert!(convex.points().len() == 5); }<|fim_prefix|>// repo: futile/ncollide path: /examples/convex2d.rs extern crate nalgebra as na; extern crate ncollide; <|fim_middle|>use na::Pnt2; use ncollide::shape::Convex; fn...
code_fim
hard
{ "lang": "rust", "repo": "futile/ncollide", "path": "/examples/convex2d.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: futile/ncollide path: /examples/convex2d.rs extern crate nalgebra as na; extern crate ncollide; use na::Pnt2; use ncollide::shape::Convex; fn main() { <|fim_suffix|> // Convex does not compute explicitely the convex hull (which has 4 vertices)! assert!(convex.points().len() == 5); }<|fi...
code_fim
hard
{ "lang": "rust", "repo": "futile/ncollide", "path": "/examples/convex2d.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|>pub trait Voice { fn signal(&self) -> u8; }<|fim_prefix|>// repo: ltriant/nes path: /src/apu/channel.rs mod square; mod triangle; mod noise; mod dmc; <|fim_middle|>pub use crate::apu::channel::square::SquareWave; pub use crate::apu::channel::triangle::TriangleWave; pub use crate::apu::channel::noise...
code_fim
medium
{ "lang": "rust", "repo": "ltriant/nes", "path": "/src/apu/channel.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ltriant/nes path: /src/apu/channel.rs mod square; mod triangle; mod noise; mod dmc; <|fim_suffix|>pub trait Voice { fn signal(&self) -> u8; }<|fim_middle|>pub use crate::apu::channel::square::SquareWave; pub use crate::apu::channel::triangle::TriangleWave; pub use crate::apu::channel::noise...
code_fim
medium
{ "lang": "rust", "repo": "ltriant/nes", "path": "/src/apu/channel.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 3akur6/braille-rs path: /src/cluster.rs use std::fmt; use std::ops; pub trait FrameLike { fn to_frame(&self) -> Frame; fn from_frame(frame: Frame) -> Self; fn from_vec(vec: Vec<u8>) -> Self where Self: std::marker::Sized, { Self::from_frame(Frame::from_vec(v...
code_fim
hard
{ "lang": "rust", "repo": "3akur6/braille-rs", "path": "/src/cluster.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn bitand(self, rhs: u64) -> Self::Output { Frame::from_u64(self.to_u64() & rhs) } } impl ops::Index<usize> for Frame { type Output = Byte; fn index(&self, index: usize) -> &Self::Output { &self.0[index] } } impl ops::IndexMut<usize> for Frame { fn index_mut(&mut...
code_fim
hard
{ "lang": "rust", "repo": "3akur6/braille-rs", "path": "/src/cluster.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl<I: Iterator<Item=Instruction<u16>>> Iterator for InstructionToU16<I> { type Item = u16; fn next(&mut self) -> Option<u16> { if self.len_buffer == 0 { if let Some(i) = self.it.next() { self.len_buffer = i.encode(&mut self.buffer) as usize; } els...
code_fim
hard
{ "lang": "rust", "repo": "Yamakaky/dcpu", "path": "/src/iterators.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Yamakaky/dcpu path: /src/iterators.rs use std::iter::Iterator; use types::*; pub struct U16ToInstruction<I> { it: U16ToInstructionOffset<I>, } impl<I: Iterator<Item=u16>> U16ToInstruction<I> { pub fn chain(it: I) -> U16ToInstruction<I> { U16ToInstruction { it: U16T...
code_fim
hard
{ "lang": "rust", "repo": "Yamakaky/dcpu", "path": "/src/iterators.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let (used, i) = match Instruction::decode(&self.buffer) { Ok(x) => x, Err(_) => return None }; let used = used as usize; if used > self.len_buffer { return None; } for n in used..3 { self.buffer[n - used] = se...
code_fim
hard
{ "lang": "rust", "repo": "Yamakaky/dcpu", "path": "/src/iterators.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mesalock-linux/crates-io path: /vendor/rayon/build.rs fn main() { let ac = autocfg::new(); if ac.probe_expres<|fim_suffix|>() {} }") { autocfg::emit("min_const_generics"); } }<|fim_middle|>sion("(0..10).step_by(2).rev()") { autocfg::emit("step_by"); } if ac.pr...
code_fim
medium
{ "lang": "rust", "repo": "mesalock-linux/crates-io", "path": "/vendor/rayon/build.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>() {} }") { autocfg::emit("min_const_generics"); } }<|fim_prefix|>// repo: mesalock-linux/crates-io path: /vendor/rayon/build.rs fn main() { let ac = autocfg::new(); if ac.probe_expres<|fim_middle|>sion("(0..10).step_by(2).rev()") { autocfg::emit("step_by"); } if ac.pr...
code_fim
medium
{ "lang": "rust", "repo": "mesalock-linux/crates-io", "path": "/vendor/rayon/build.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kgtkr/procon path: /atcoder/rust/arc078_a/src/main.rs extern crate core; use std::io::{self, Read}; fn main() { let mut input = String::new(); io::stdin().read_to_string(&mut input).unwrap(); let output = run(input.trim().to_string()); println!("{}", output); } fn run(input: S...
code_fim
hard
{ "lang": "rust", "repo": "kgtkr/procon", "path": "/atcoder/rust/arc078_a/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: perdumonocle/gnu-ln path: /src/lib.rs use anyhow::Result; use std::path::Path; use std::process::Command; pub enum BackupControl { None, Off, Numbered, T, Existing, Nil, Simple, Never, } #[derive(Default)] pub struct LnOptions<'a> { backup: Option<BackupCont...
code_fim
hard
{ "lang": "rust", "repo": "perdumonocle/gnu-ln", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match cmd.status() { Ok(status) => Ok(status.code().unwrap_or(-1)), Err(err) => Err(err.into()), } } /// Simple make symlink for file pub fn force_symlink(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> Result<i32> { let opts = LnOptions { force: true, symboli...
code_fim
hard
{ "lang": "rust", "repo": "perdumonocle/gnu-ln", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let result = db.execute( "UPDATE player SET name = ? WHERE id = ?", params![form.name, player_id] ); let base = BaseTemplate::new(&db, &identity)?; if base.player.is_some() { Ok(SettingsTemplate { base, message: match result { ...
code_fim
hard
{ "lang": "rust", "repo": "MDShields7/kachiclash", "path": "/src/handlers/settings.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub async fn settings_post(form: web::Form<FormData>, state: web::Data<AppState>, identity: Identity) -> Result<AskamaResponder<SettingsTemplate>> { let player_id = identity.require_player_id()?; let db = state.db.lock().unwrap(); if !player::name_is_valid(&form.name) { return Ok(Set...
code_fim
hard
{ "lang": "rust", "repo": "MDShields7/kachiclash", "path": "/src/handlers/settings.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MDShields7/kachiclash path: /src/handlers/settings.rs use actix_web::web; use actix_identity::Identity; use askama::Template; use crate::AppState; use super::askama_responder::AskamaResponder; use super::{BaseTemplate, Result, HandlerError}; use crate::data::player; use crate::handlers::Identit...
code_fim
hard
{ "lang": "rust", "repo": "MDShields7/kachiclash", "path": "/src/handlers/settings.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let address = self.get_register_pair(|state| state.registers.hl); let op1 = self.ram.read_u8(address); let op2 = operation.maybe_negate(operand); let result = alu::add_octets(op1, op2); self.ram.write_u8(address, result.value); Flag::set_values( ...
code_fim
hard
{ "lang": "rust", "repo": "TChatzigiannakis/rusty_sms", "path": "/src/vm/instructions/arithmetic_8bit.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub(crate) fn decrement_memory(&mut self) { self.op_memory_by_1(Operation::Subtract) } fn op_memory_by_1(&mut self, operation: Operation) { self.operate_on_memory( operation, 1, &[ Flag::Sign, Flag::Zero, ...
code_fim
hard
{ "lang": "rust", "repo": "TChatzigiannakis/rusty_sms", "path": "/src/vm/instructions/arithmetic_8bit.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TChatzigiannakis/rusty_sms path: /src/vm/instructions/arithmetic_8bit.rs use crate::vm::cpu::alu; use crate::vm::cpu::flags::Flag; use crate::vm::cpu::operation::Operation; use crate::vm::cpu::registers::Registers; use crate::vm::cpu::state::State; use crate::vm::machine::Machine; impl Machine ...
code_fim
hard
{ "lang": "rust", "repo": "TChatzigiannakis/rusty_sms", "path": "/src/vm/instructions/arithmetic_8bit.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> return Ok(()); } } let args = kin_core::parse_cmdline(); match args { SubCommand::Init(args) => init::run(&args), SubCommand::Compile(args) => compile::run(&args), SubCommand::Decrypt(args) => kin_core::decrypt::run(&args), }?; Ok(()) }<|f...
code_fim
medium
{ "lang": "rust", "repo": "pcrockett/kin-backup", "path": "/kin/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let args = kin_core::parse_cmdline(); match args { SubCommand::Init(args) => init::run(&args), SubCommand::Compile(args) => compile::run(&args), SubCommand::Decrypt(args) => kin_core::decrypt::run(&args), }?; Ok(()) }<|fim_prefix|>// repo: pcrockett/kin-backup pa...
code_fim
hard
{ "lang": "rust", "repo": "pcrockett/kin-backup", "path": "/kin/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pcrockett/kin-backup path: /kin/src/main.rs use kin_core; use kin_core::{CliResult, SubCommand}; mod compile; mod init; fn main() -> CliResult { kin_core::libsodium_init()?; // TODO: Kill this and replace with new stand-alone decrypt executable if std::env::args().len() <= 1 { ...
code_fim
medium
{ "lang": "rust", "repo": "pcrockett/kin-backup", "path": "/kin/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> amethyst::start_logger(Default::default()); let pipe = Pipeline::build().with_stage( Stage::with_backbuffer() .clear_target([0.0, 0.0, 0.0, 1.0], 1.0) .with_pass(DrawFlat2D::new()) ); let config = DisplayConfig::load("./examples/10_mouse_getdown/config.ron"...
code_fim
hard
{ "lang": "rust", "repo": "glaceef/amethyst-example", "path": "/examples/10_mouse_getdown/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let game_data = GameDataBuilder::new() .with_bundle(render_bundle.with_sprite_sheet_processor())? .with_bundle(input_bundle)? .with(MouseSystem, "mouse-system", &[]) .with(ClickSystem, "click-system", &[]); let mut game = Application::new( "./examples/10_mo...
code_fim
hard
{ "lang": "rust", "repo": "glaceef/amethyst-example", "path": "/examples/10_mouse_getdown/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: glaceef/amethyst-example path: /examples/10_mouse_getdown/main.rs use amethyst::{ prelude::*, ecs::prelude::{ System, Read }, renderer::{ DisplayConfig, DrawFlat2D, Pipeline, RenderBundle, Stage, }, input::{ is_key_down, Bindings, InputBund...
code_fim
hard
{ "lang": "rust", "repo": "glaceef/amethyst-example", "path": "/examples/10_mouse_getdown/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hdelva/preprocess_routable_tiles path: /src/entities/tile.rs use std::collections::BTreeMap; use crate::entities::node::Node; use crate::entities::profile::Profile; use crate::entities::segment::{Segment, WeightedSegment}; use crate::entities::tile_coord::TileCoordinate; use crate::entities::way...
code_fim
hard
{ "lang": "rust", "repo": "hdelva/preprocess_routable_tiles", "path": "/src/entities/tile.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for edge in way.get_segments() { let Segment { from, to } = edge; let from_node = self.get_nodes().get(from).expect("Corrupted tile"); let to_node = self.get_nodes().get(to).expect("Corrupted tile"); if profile.is_obstacle(from_n...
code_fim
hard
{ "lang": "rust", "repo": "hdelva/preprocess_routable_tiles", "path": "/src/entities/tile.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[inline] fn size_hint(&self) -> (usize, Option<usize>) { self.inner.size_hint() } } impl ExactSizeIterator for IntoChunks {} impl FusedIterator for IntoChunks {}<|fim_prefix|>// repo: mzabaluev/chunked-bytes path: /src/iter.rs use bytes::Bytes; use std::collections::vec_deque; use ...
code_fim
medium
{ "lang": "rust", "repo": "mzabaluev/chunked-bytes", "path": "/src/iter.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mzabaluev/chunked-bytes path: /src/iter.rs use bytes::Bytes; use std::collections::vec_deque; use std::iter::FusedIterator; /// The iterator produced by the `drain_chunks` method of `ChunkedBytes`. pub struct DrainChunks<'a> { inner: vec_deque::Drain<'a, Bytes>, } impl<'a> DrainChunks<'a>...
code_fim
hard
{ "lang": "rust", "repo": "mzabaluev/chunked-bytes", "path": "/src/iter.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Iterator for IntoChunks { type Item = Bytes; #[inline] fn next(&mut self) -> Option<Bytes> { self.inner.next() } #[inline] fn size_hint(&self) -> (usize, Option<usize>) { self.inner.size_hint() } } impl ExactSizeIterator for IntoChunks {} impl FusedItera...
code_fim
hard
{ "lang": "rust", "repo": "mzabaluev/chunked-bytes", "path": "/src/iter.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: atNightly/puroro path: /puroro/src/internal/de/from_iter.rs // Copyright 2021 Google LLC // // 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.apac...
code_fim
hard
{ "lang": "rust", "repo": "atNightly/puroro", "path": "/puroro/src/internal/de/from_iter.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub fn deser_from_iter<Msg, I>(message: &mut Msg, input_iter: I) -> Result<()> where Msg: DeserFieldsFromBytesIter, I: Iterator<Item = IoResult<u8>>, { let mut scoped_iter = ScopedIter::new(input_iter); deser_from_scoped_iter(message, &mut scoped_iter) } pub fn deser_from_scoped_iter<Msg,...
code_fim
hard
{ "lang": "rust", "repo": "atNightly/puroro", "path": "/puroro/src/internal/de/from_iter.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let out_dir = getenv("OUT_DIR").unwrap(); let d: String = ["lib", out_stem, "-objs"].concat(); let lib_file: String = ["lib", out_stem, ".a"].concat(); Archive { cc: cc, cxx: cxx, ar: ar, ranlib: ranlib, ...
code_fim
hard
{ "lang": "rust", "repo": "rschulman/cargo-pnacl-helper", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rschulman/cargo-pnacl-helper path: /src/lib.rs one, } } fn getenv(v: &str) -> Option<String> { use std::os::getenv; let r = getenv(v); println!("{} = {:?}", v, r); r } mod non_nacl { use super::getenv; fn get_var(var_base: &str) -> Result<String, String> { l...
code_fim
hard
{ "lang": "rust", "repo": "rschulman/cargo-pnacl-helper", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rschulman/cargo-pnacl-helper path: /src/lib.rs {} = {:?}", v, r); r } mod non_nacl { use super::getenv; fn get_var(var_base: &str) -> Result<String, String> { let target = getenv("TARGET") .expect("Environment variable 'TARGET' is unset"); let host = matc...
code_fim
hard
{ "lang": "rust", "repo": "rschulman/cargo-pnacl-helper", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // when update runs without preserve, AXIS_PTS be removed from the module // AXIS_PTS are only referenced through CHARACTERISTIC > AXIS_DESCR > AXIS_PTS_REF pub(crate) fn cleanup_removed_axis_pts(module: &mut Module, removed_items: &HashSet<String>) { if removed_items.len() == 0 { return; ...
code_fim
hard
{ "lang": "rust", "repo": "SATOSHI66/a2ltool", "path": "/src/update/axis_pts.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: SATOSHI66/a2ltool path: /src/update/axis_pts.rs use std::collections::HashMap; use std::collections::HashSet; use a2lfile::*; use crate::dwarf::*; use super::enums::*; use super::ifdata_update::*; use super::*; pub(crate) fn update_module_axis_pts( module: &mut Module, debug_data: &De...
code_fim
hard
{ "lang": "rust", "repo": "SATOSHI66/a2ltool", "path": "/src/update/axis_pts.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if click_pos.x() + 15.0 >= fish_transform.translation.x() && click_pos.x() - 15.0 <= fish_transform.translation.x() && click_pos.y() + 15.0 >= fish_transform.translation.y() && click_pos.y() - 15.0 <= fish_trans...
code_fim
hard
{ "lang": "rust", "repo": "rmaugusto/mtxia", "path": "/src/interaction/entity_selection_system.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> for (_, cam_transform, _) in q_camera.iter() { let click_pos = cam_transform.compute_matrix() * pos.extend(0.0).extend(1.0); for (fish_transform, mut fish) in q_fish.iter_mut() { fish.selected = false; if click_pos...
code_fim
hard
{ "lang": "rust", "repo": "rmaugusto/mtxia", "path": "/src/interaction/entity_selection_system.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rmaugusto/mtxia path: /src/interaction/entity_selection_system.rs use bevy::{ input::{ mouse::{MouseButtonInput, MouseMotion}, ElementState, }, prelude::*, render::camera::{Camera, OrthographicProjection}, }; use crate::{fish::Fish, shared::components::M...
code_fim
hard
{ "lang": "rust", "repo": "rmaugusto/mtxia", "path": "/src/interaction/entity_selection_system.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if self.test_spot(x, y + 1) { count += 1; } if self.test_spot(x, y - 1) { count += 1; } if self.test_spot(x + 1, y + 1) { count += 1; } if self.test_spot(x - 1, y - 1) { count += 1; } ...
code_fim
hard
{ "lang": "rust", "repo": "robmikh/minesweeper-rs", "path": "/src/minesweeper.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for mine_state in self.mine_states.iter_mut() { *mine_state = MineState::Empty } self.game_over = false; self.mine_generation_state = MineGenerationState::Deferred; self.num_mines = mines; self.last_tile = None; Ok(()) } fn swe...
code_fim
hard
{ "lang": "rust", "repo": "robmikh/minesweeper-rs", "path": "/src/minesweeper.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: robmikh/minesweeper-rs path: /src/minesweeper.rs ndation::Numerics::Vector2, Graphics::SizeInt32, UI::Composition::ContainerVisual, }; #[derive(Copy, Clone, PartialEq, Eq, Hash)] pub enum MineState { Empty, Flag, Question, Revealed, } impl MineState { fn cycle(self) -> S...
code_fim
hard
{ "lang": "rust", "repo": "robmikh/minesweeper-rs", "path": "/src/minesweeper.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jaredmcdonald/toy-browser path: /layout.rs //! a layout tree module //! px sizes for now use style; #[deriving(Show)] struct Dimensions { content: Rect, padding: EdgeSizes, border: EdgeSizes, margin: EdgeSizes, } #[deriving(Show)] struct Rect { x: f32, y: f32, width: f32, heig...
code_fim
hard
{ "lang": "rust", "repo": "jaredmcdonald/toy-browser", "path": "/layout.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl<'a> LayoutBox<'a> { fn new(box_type: BoxType) -> LayoutBox { LayoutBox { box_type: box_type, dimensions: Dimensions { // 0.0: temporary default content: Rect { x: 0.0, y: 0.0, width: 0.0, height: 0.0, }, padding: EdgeSi...
code_fim
hard
{ "lang": "rust", "repo": "jaredmcdonald/toy-browser", "path": "/layout.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>} impl<S,I,E> SinkExt<I> for S where S: Sink<I,Error=E> + Send + Unpin + 'static, I: Send + 'static, E: std::fmt::Debug + Send + 'static { fn channeled(mut self,buffer: usize) -> Sender<I>{ let (tx,mut rx) = channel(buffer); tokio::spawn(async move{ ...
code_fim
hard
{ "lang": "rust", "repo": "Eroc33/discord_next-rs", "path": "/gateway_client/src/extensions.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Eroc33/discord_next-rs path: /gateway_client/src/extensions.rs use futures::{ channel::mpsc::{Sender,UnboundedSender, channel, unbounded}, sink::{Sink,SinkExt as _}, stream::StreamExt, }; use tracing::*; pub trait SinkExt<I>: Sink<I>{ fn channeled(self,buffer: usize) -> Sender<...
code_fim
hard
{ "lang": "rust", "repo": "Eroc33/discord_next-rs", "path": "/gateway_client/src/extensions.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub trait SinkExt<I>: Sink<I>{ fn channeled(self,buffer: usize) -> Sender<I>; fn unbounded_channeled(self) -> UnboundedSender<I>; } impl<S,I,E> SinkExt<I> for S where S: Sink<I,Error=E> + Send + Unpin + 'static, I: Send + 'static, E: std::fmt::Debug + Send + 'static { ...
code_fim
hard
{ "lang": "rust", "repo": "Eroc33/discord_next-rs", "path": "/gateway_client/src/extensions.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>// EMIT_MIR separate_const_switch.identity.SeparateConstSwitch.diff fn identity(x: Result<i32, i32>) -> Result<i32, i32> { Ok(x?) } fn main() { too_complex(Ok(0)); identity(Ok(0)); }<|fim_prefix|>// repo: rust-lang/rust path: /tests/mir-opt/separate_const_switch.rs #![feature(control_flow_en...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/rust", "path": "/tests/mir-opt/separate_const_switch.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // The pass should break the outer match into // two blocks that only have one parent each. // Parents are one of the two branches of the first // match, so a later pass can propagate constants. match { match x { Ok(v) => ControlFlow::Continue(v), Err(r)...
code_fim
medium
{ "lang": "rust", "repo": "rust-lang/rust", "path": "/tests/mir-opt/separate_const_switch.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/rust path: /tests/mir-opt/separate_const_switch.rs #![feature(control_flow_enum)] #![feature(try_trait_v2)] // compile-flags: -Zunsound-mir-opts use std::ops::ControlFlow; <|fim_suffix|>// EMIT_MIR separate_const_switch.identity.SeparateConstSwitch.diff fn identity(x: Result<i32, i3...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/rust", "path": "/tests/mir-opt/separate_const_switch.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> match &self.internal { Decode(error) => Some(error), InvalidInputType(error) => Some(error), InvalidProposedInput(error) => Some(error), VersionsDontMatch { proposed: _, original: _, } => None, LockTimesDontMatch { proposed: _, original: ...
code_fim
hard
{ "lang": "rust", "repo": "rajarshimaitra/payjoin", "path": "/bip78/src/sender/error.rs", "mode": "spm", "license": "MITNFA", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug)] pub(crate) enum InternalCreateRequestError { InvalidOriginalInput(crate::psbt::PsbtInputsError), NoInputs, PayeeValueNotEqual, NoOutputs, MultiplePayeeOutputs, MissingPayeeOutput, FeeOutputValueLowerThanFeeContribution, AmbiguousChangeOutput, ChangeInde...
code_fim
hard
{ "lang": "rust", "repo": "rajarshimaitra/payjoin", "path": "/bip78/src/sender/error.rs", "mode": "spm", "license": "MITNFA", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rajarshimaitra/payjoin path: /bip78/src/sender/error.rs use crate::input_type::{InputType, InputTypeError}; use std::fmt; /// Error that may occur when the response from receiver is malformed. /// /// This is currently opaque type because we aren't sure which variants will stay. /// You can onl...
code_fim
hard
{ "lang": "rust", "repo": "rajarshimaitra/payjoin", "path": "/bip78/src/sender/error.rs", "mode": "psm", "license": "MITNFA", "source": "the-stack-v2" }
<|fim_prefix|>// repo: saadsoans/photo-studio-1 path: /photo-core/src/lib.rs #[cfg(target_os = "linux")] extern crate openssl; #[macro_use] extern crate diesel; #[macro_use] extern crate diesel_migrations; <|fim_suffix|>#[macro_use] extern crate lazy_static; #[macro_use] extern crate log; pub mod connection; pub ...
code_fim
easy
{ "lang": "rust", "repo": "saadsoans/photo-studio-1", "path": "/photo-core/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[macro_use] extern crate lazy_static; #[macro_use] extern crate log; pub mod connection; pub mod custom_migrations; pub mod helpers; pub mod models; pub mod schema;<|fim_prefix|>// repo: saadsoans/photo-studio-1 path: /photo-core/src/lib.rs #[cfg(target_os = "linux")] extern crate openssl; #[macro_us...
code_fim
medium
{ "lang": "rust", "repo": "saadsoans/photo-studio-1", "path": "/photo-core/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rudihorn/rust-stm32f103-examples path: /stm32-mem/src/main.rs #![no_std] #![no_main] #![feature(asm, lang_items, start, naked_functions, used)] extern crate stm32; mod std_repl; mod interrupts; mod mem; mod print; mod system; use print::{print, println, print_int, enable_uart}; use system::{e...
code_fim
hard
{ "lang": "rust", "repo": "rudihorn/rust-stm32f103-examples", "path": "/stm32-mem/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> INT_DATA = 9; INT_BSS = 99; print("int_data: "); print_int(INT_DATA); println(""); print("int_bss: "); print_int(INT_BSS); println(""); } loop { } }<|fim_prefix|>// repo: rudihorn/rust-stm32f103-examples path: /stm32-mem/src/main.rs #![no_std] #![no_main] #![featur...
code_fim
hard
{ "lang": "rust", "repo": "rudihorn/rust-stm32f103-examples", "path": "/stm32-mem/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: puppetlabs-toy-chest/rust-kitchensink path: /src/log.rs use rust_log::{self, LogRecord, LogMetadata, LogLevelFilter, SetLoggerError}; use std::io::Write; struct SimpleLogger; <|fim_suffix|> metadata.level() <= rust_log::LogLevel::Trace } fn log(&self, record: &LogRecord) { ...
code_fim
medium
{ "lang": "rust", "repo": "puppetlabs-toy-chest/rust-kitchensink", "path": "/src/log.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub fn init_logging(level: LogLevel) { let filter = match level { LogLevel::None => LogLevelFilter::Off, LogLevel::Trace => LogLevelFilter::Trace, LogLevel::Debug => LogLevelFilter::Debug, LogLevel::Info => LogLevelFilter::Info, LogLevel::Warn => LogLevelFilter:...
code_fim
medium
{ "lang": "rust", "repo": "puppetlabs-toy-chest/rust-kitchensink", "path": "/src/log.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: frizensami/plagiarism-basic path: /plagiarismbasic_lib/src/result_output_html.rs use crate::plagiarism_database::{PlagiarismResult, TextOwnerID}; use crate::text_utils::get_boldtext_segments_from_intervals; use fs_extra; use gcollections::ops::*; use handlebars::Handlebars; use interval::interva...
code_fim
hard
{ "lang": "rust", "repo": "frizensami/plagiarism-basic", "path": "/plagiarismbasic_lib/src/result_output_html.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Add the result to an overall vector to be sent to Handlebars plag_results.push(HBPlagiarismResult { owner_id1: result.owner_id1.clone(), owner_id2: result.owner_id2.clone(), trusted_owner1: result.trusted_owner1, equal_fragments: result.eq...
code_fim
hard
{ "lang": "rust", "repo": "frizensami/plagiarism-basic", "path": "/plagiarismbasic_lib/src/result_output_html.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dylanmckay/debugger path: /tools/debug.rs extern crate debugger; fn main() { let pid = std::env::args().skip(1).next().expect("expected a PID"); let process = match debugger::machine::attach_to(&pid) { Ok(p) => p, Err(e) => {<|fim_suffix|>process.threads().unwrap().colle...
code_fim
medium
{ "lang": "rust", "repo": "dylanmckay/debugger", "path": "/tools/debug.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("error: {}", e); return; }, }; let threads: Vec<_> = process.threads().unwrap().collect(); println!("threads: {:#?}", threads); println!("hello"); }<|fim_prefix|>// repo: dylanmckay/debugger path: /tools/debug.rs extern crate debugger; fn main...
code_fim
medium
{ "lang": "rust", "repo": "dylanmckay/debugger", "path": "/tools/debug.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>process.threads().unwrap().collect(); println!("threads: {:#?}", threads); println!("hello"); }<|fim_prefix|>// repo: dylanmckay/debugger path: /tools/debug.rs extern crate debugger; fn main() { let pid = std::env::args().skip(1).next().expect("expected a PID"); let process = match deb...
code_fim
medium
{ "lang": "rust", "repo": "dylanmckay/debugger", "path": "/tools/debug.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: znuznu/nunki path: /src/project/regex.rs use lazy_static::lazy_static; use regex::Regex; use std::borrow::Cow; pub fn extract_untracked_todo_content(line: &str) -> Option<&str> { lazy_static! { static ref RE: Regex = Regex::new(r"^(.*)TODO[: ]? (.*)(\n)?$").unwrap(); } matc...
code_fim
hard
{ "lang": "rust", "repo": "znuznu/nunki", "path": "/src/project/regex.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!( extract_untracked_todo_content("// TODO: rewrite everything\n").unwrap(), "rewrite everything" ); } #[test] fn case_sensitive() { assert_eq!( extract_untracked_todo_content("// todo: rewrite everything").is_none(), ...
code_fim
hard
{ "lang": "rust", "repo": "znuznu/nunki", "path": "/src/project/regex.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> println!("Choosing device {}, printing packets..", device_name); let capture = pcap::Capture::from_device(device_name).unwrap().open().unwrap(); packet::listen_and_print_packets(capture); }<|fim_prefix|>// repo: juissi999/ramon path: /src/main.rs use std::io; use std::convert::TryFrom; mod ...
code_fim
hard
{ "lang": "rust", "repo": "juissi999/ramon", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: juissi999/ramon path: /src/main.rs use std::io; use std::convert::TryFrom; mod packet; fn main() { let network_interfaces = pcap::Device::list().unwrap(); packet::print_network_interfaces_list(&network_interfaces); <|fim_suffix|> let selection_raw: u32 = selection.trim().parse() ...
code_fim
medium
{ "lang": "rust", "repo": "juissi999/ramon", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn serialize(&self) -> String { format!("N{},{},{},{}", self.id, self.ntype, self.bias, self.af) } } #[cfg(test)] mod test { use super::Neuron; use super::Serialization; #[test] pub fn serialization_test_1() { let n = "3,0,2.3,1"; let neuron = Neuron::des...
code_fim
hard
{ "lang": "rust", "repo": "AlexanderHeim/kosmos", "path": "/src/neuron.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AlexanderHeim/kosmos path: /src/neuron.rs use crate::Serialization; #[derive(Debug)] pub struct Neuron { pub id: u32, pub ntype: u8, pub bias: f32, pub af: u8, pub value: f32, } <|fim_suffix|> let s = match s.strip_prefix("N") { Some(s) => s, ...
code_fim
medium
{ "lang": "rust", "repo": "AlexanderHeim/kosmos", "path": "/src/neuron.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pgblrsgw/investigation-rocket path: /src/obstacles.rs use rocket::http::Status; use rocket::response::status; use rocket::State; use rocket_contrib::JSON; use std::collections::hash_map::Entry; use proto; #[get("/<problem>/Obstacles")] fn get_all(state: State<super::State>, problem: &str) -> Re...
code_fim
hard
{ "lang": "rust", "repo": "pgblrsgw/investigation-rocket", "path": "/src/obstacles.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Attempt to remove a non-existing obstacle from a non-existing problem. let mut request = MockRequest::new(Method::Delete, "/test/Obstacles/asd"); let response = request.dispatch_with(&rocket); assert_eq!(response.status(), Status::NotFound); // Add "test" to the...
code_fim
hard
{ "lang": "rust", "repo": "pgblrsgw/investigation-rocket", "path": "/src/obstacles.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if is_part2 { max_distance = max(max_distance, distance(pos_x, pos_y)); } } return if is_part2 { max_distance } else { distance(pos_x, pos_y) } } pub fn part1(input: String) -> String { return path_distance(input, false).to_string(); } pub fn part2(input: String) -> String { return path_dist...
code_fim
hard
{ "lang": "rust", "repo": "apparentorder/aoc", "path": "/2017/src/day11.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn part1(input: String) -> String { return path_distance(input, false).to_string(); } pub fn part2(input: String) -> String { return path_distance(input, true).to_string(); } pub const PUZZLE_DATA: aoc::Puzzle = aoc::Puzzle { day: 11, input: "file:11-input", implementation_part1: part1, implem...
code_fim
medium
{ "lang": "rust", "repo": "apparentorder/aoc", "path": "/2017/src/day11.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: apparentorder/aoc path: /2017/src/day11.rs use crate::aoc; use std::cmp::{min,max}; fn distance(pos_x: i32, pos_y: i32) -> i32 { let distance_x = pos_x.abs(); let distance_y = pos_y.abs(); // move diagonally as much as possible: one step means moving one position on both the x and the y axi...
code_fim
hard
{ "lang": "rust", "repo": "apparentorder/aoc", "path": "/2017/src/day11.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: th0rex/zydis-rs path: /src/register.rs //! Register helper functions. use gen::*; use std::ffi::CStr; /// Extensions for `ZydisRegister` pub trait ZydisRegisterMethods { /// Returns the ID of the specified register. /// /// Returns `None` if the register is invalid. /// ///...
code_fim
hard
{ "lang": "rust", "repo": "th0rex/zydis-rs", "path": "/src/register.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Returns the width of the specified register in 64-bit mode. /// /// # Examples /// ``` /// use zydis::register::ZydisRegisterMethods; /// let dr0_width = zydis::gen::ZYDIS_REGISTER_DR0.get_width64(); /// assert_eq!(dr0_width, 64); /// ``` fn get_width64(self) -> Zyd...
code_fim
hard
{ "lang": "rust", "repo": "th0rex/zydis-rs", "path": "/src/register.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn get_width64(self) -> ZydisRegisterWidth { unsafe { ZydisRegisterGetWidth64(self as _) } } } /// Extensions for `ZydisRegisterClassesExtensions`. pub trait ZydisRegisterClassesExtensions { /// Returns the register specified by `class` and `id`. /// /// # Examples /// ```...
code_fim
hard
{ "lang": "rust", "repo": "th0rex/zydis-rs", "path": "/src/register.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: simrit1/scrappybot path: /src/main.rs extern crate anyhow; extern crate glob; extern crate select; extern crate serde_json; <|fim_suffix|>#[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { bot::run().await?; Ok(()) }<|fim_middle|>mod api; mod notification; mod sc...
code_fim
medium
{ "lang": "rust", "repo": "simrit1/scrappybot", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { bot::run().await?; Ok(()) }<|fim_prefix|>// repo: simrit1/scrappybot path: /src/main.rs extern crate anyhow; extern crate glob; extern crate select; extern crate serde_json; <|fim_middle|>mod api; mod notification; mod sc...
code_fim
medium
{ "lang": "rust", "repo": "simrit1/scrappybot", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }