text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: AJTJ/rust_big_o path: /src/main.rs // How is time complexity measured? // By counting the number of primitive operations performed by the algorithm on a given input size // constant complexity // O(1) , i.e. the pidgeon // always takes thes same amount of time fn _return_double_index(i: usize, ...
code_fim
hard
{ "lang": "rust", "repo": "AJTJ/rust_big_o", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rune-rs/rune path: /crates/rune/src/tests/stmt_reordering.rs prelude!(); #[test] fn test_stmt_reordering() { let len: i64 = rune! { pub fn main() { let len = 0; let value = String::from("Hello"); len = value.len(); let value2 = drop(va...
code_fim
medium
{ "lang": "rust", "repo": "rune-rs/rune", "path": "/crates/rune/src/tests/stmt_reordering.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let n: i64 = rune! { const fn foo() { let n = 0; n = 1; let n = 2; n } pub fn main() { foo() } }; assert_eq!(n, 2); }<|fim_prefix|>// repo: rune-rs/rune path: /crates/rune/src/tests/stmt_reordering.r...
code_fim
medium
{ "lang": "rust", "repo": "rune-rs/rune", "path": "/crates/rune/src/tests/stmt_reordering.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AJTJ/tools_rocket path: /src/main.rs #[macro_use] extern crate rocket; #[get("/")] fn index() -> &'static str { "Hello, world!" } #[get("/posts")] fn get_all_posts() -> &'static str { "Hello, world!" } #[get("/post")] fn get_one_post() -> &'static str { "Hello, world!" } #[post("...
code_fim
medium
{ "lang": "rust", "repo": "AJTJ/tools_rocket", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[post("/new")] fn create_new_post() -> &'static str { "Hello, world!" } #[put("/update")] fn update_one_post() -> &'static str { "Hello, world!" } #[post("/publish")] fn publish_post() -> &'static str { "Hello, world!" } #[delete("/delete")] fn delete_post() -> &'static str { "Hello, wo...
code_fim
medium
{ "lang": "rust", "repo": "AJTJ/tools_rocket", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vraisamis/memoru path: /src/options.rs use clap::{AppSettings, Clap}; mod edit; mod new; <|fim_suffix|>#[derive(Clap)] pub enum Command { New(new::New), Edit(edit::Edit), }<|fim_middle|>#[derive(Clap)] #[clap(setting = AppSettings::ColoredHelp)] pub struct Opts { #[clap(subcommand)...
code_fim
medium
{ "lang": "rust", "repo": "vraisamis/memoru", "path": "/src/options.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Clap)] pub enum Command { New(new::New), Edit(edit::Edit), }<|fim_prefix|>// repo: vraisamis/memoru path: /src/options.rs use clap::{AppSettings, Clap}; mod edit; mod new; <|fim_middle|>#[derive(Clap)] #[clap(setting = AppSettings::ColoredHelp)] pub struct Opts { #[clap(subcommand)...
code_fim
medium
{ "lang": "rust", "repo": "vraisamis/memoru", "path": "/src/options.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vraisamis/memoru path: /src/options.rs use clap::{AppSettings, Clap}; <|fim_suffix|>#[derive(Clap)] pub enum Command { New(new::New), Edit(edit::Edit), }<|fim_middle|>mod edit; mod new; #[derive(Clap)] #[clap(setting = AppSettings::ColoredHelp)] pub struct Opts { #[clap(subcommand)...
code_fim
medium
{ "lang": "rust", "repo": "vraisamis/memoru", "path": "/src/options.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/wasmer path: /src/spectests/f64_cmp.rs object); c612_l624_action_invoke(&result_object); c613_l625_action_invoke(&result_object); c614_l626_action_invoke(&result_object); c615_l627_action_invoke(&result_object); c616_l628_action_invoke(&result_object); c617_l629_a...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/wasmer", "path": "/src/spectests/f64_cmp.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> println!("Executing function {}", "c335_l347_action_invoke"); let func_index = match result_object.module.info.exports.get("eq") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), }; let invoke_fn: fn(f64, f64, &Instance) -> i32 = get_instance_fun...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/wasmer", "path": "/src/spectests/f64_cmp.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> println!("Executing function {}", "c1703_l1715_action_invoke"); let func_index = match result_object.module.info.exports.get("gt") { Some(&Export::Function(index)) => index, _ => panic!("Function not found"), }; let invoke_fn: fn(f64, f64, &Instance) -> i32 = get_instance_f...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/wasmer", "path": "/src/spectests/f64_cmp.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: evaporei/scoolite path: /src/lib.rs /// Module for `AsAny` trait pub mod as_any; <|fim_suffix|>/// Module for `Error` type pub mod error; /// Module for interacting with stdin and stdout pub mod io; /// Module for `Table` type pub mod table; /// Module for `Row` type pub mod row;<|fim_middle...
code_fim
medium
{ "lang": "rust", "repo": "evaporei/scoolite", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// Module for `Row` type pub mod row;<|fim_prefix|>// repo: evaporei/scoolite path: /src/lib.rs /// Module for `AsAny` trait pub mod as_any; /// Module for `Command`s/`Statement`s of the SQL-like language pub mod command; /// Module for `Error` type pub mod error; /// Module for interacting with stdi...
code_fim
easy
{ "lang": "rust", "repo": "evaporei/scoolite", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.start_time = std::time::Instant::now(); self.last_frame_time = std::time::Instant::now(); self.frame_count = 0; self.date = current_date_as_float4(); self.pause_time = None; } fn toggle_paused(&mut self) { if let Some(pause_time) = self.pause_t...
code_fim
hard
{ "lang": "rust", "repo": "xixixao/shader-roy", "path": "/shader_roy/src/shader_roy.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xixixao/shader-roy path: /shader_roy/src/shader_roy.rs _ref())); } let draw_size = window.inner_size(); layer.set_drawable_size(CGSize::new(draw_size.width as f64, draw_size.height as f64)); let vector_rect = vec![Float4 { x: -1.0, y: -1.0, z: 2.0, ...
code_fim
hard
{ "lang": "rust", "repo": "xixixao/shader-roy", "path": "/shader_roy/src/shader_roy.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> scale: (f32, f32), events_loop: &winit::event_loop::EventLoop<()>, ) -> ( winit::dpi::LogicalSize<f32>, winit::dpi::LogicalPosition<f32>, ) { let size_scale: vek::Vec2<_> = scale.into(); let screen = events_loop.primary_monitor().unwrap(); let screen_size: vek::Vec2<f32> = { ...
code_fim
hard
{ "lang": "rust", "repo": "xixixao/shader-roy", "path": "/shader_roy/src/shader_roy.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DanielMowitz/U4x path: /src/sprite.rs use std::fs::File; use std::io::Read; use super::img::Img; pub struct Sprite { ///A sprite with animations (using the function animate) pos: (u32, u32), frames: Vec<Img>, anims: Vec<(usize, usize)>, current_anim: usize, current_frame: usize, dt_sinc...
code_fim
hard
{ "lang": "rust", "repo": "DanielMowitz/U4x", "path": "/src/sprite.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn get_height(&self) -> u32 { return 2 * (self.get_current_frame().get_length() / *self.get_current_frame().get_width()) as u32; } pub fn get_current_frame(&self) -> Img { self.frames[self.current_frame].clone() } /// Wraps Img::new_from_file. pub fn new_from_file(mut f: File, pix_per_fram...
code_fim
hard
{ "lang": "rust", "repo": "DanielMowitz/U4x", "path": "/src/sprite.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dcabrejas/wf2 path: /wf2/src/tests/update_images_cmd.rs #[cfg(test)] mod tests { use crate::cli_input::CLIInput; use crate::cli_output::CLIOutput; use crate::tests::_commands; use wf2_core::task::Task; <|fim_suffix|> #[test] fn test_update_images_subset() { let ar...
code_fim
hard
{ "lang": "rust", "repo": "dcabrejas/wf2", "path": "/wf2/src/tests/update_images_cmd.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let args = vec!["prog", "update-images", "php", "db", "lol"]; let cli_output = CLIOutput::from_input(CLIInput::_from_args(args)); match cli_output.expect("test").tasks.expect("test").get(0) { Some(Task::NotifyError { .. }) => { /* noop */ } _ => unreachable!...
code_fim
medium
{ "lang": "rust", "repo": "dcabrejas/wf2", "path": "/wf2/src/tests/update_images_cmd.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bistin/wasm-ray-tracing path: /src/material.rs use crate::hittable::HitRecord; use crate::color::Color; use crate::ray::Ray; use crate::vec3::Vec3; pub struct ScatterRecord { pub scattered: Ray, pub attenuation: Color, } pub trait Material { fn scatter(&self, r_in: &Ray, hit_reco...
code_fim
hard
{ "lang": "rust", "repo": "bistin/wasm-ray-tracing", "path": "/src/material.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> r0 = r0*r0; return r0 + (1-r0)*pow((1 - cosine),5); }*/ fn schlick(cosine: f32, ref_idx: f32) -> f32 { let mut r0 = (1.0 - ref_idx) / (1.0 + ref_idx); r0 = r0 * r0; return r0 + (1.0 - r0) * (1.0 - cosine).powi(5); } impl Material for Dielectric { fn scatter(&self, r_in: &Ray, ...
code_fim
hard
{ "lang": "rust", "repo": "bistin/wasm-ray-tracing", "path": "/src/material.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: NeillJohnston/genetic-tetris-bot path: /interface/src/main.rs mod protocol; use std::net::{TcpListener, TcpStream}; use std::io::prelude::*; use protocol::*; <|fim_suffix|>fn handle(mut stream: TcpStream) { println!("received a connection"); loop { let mut buffer = Vec::new(); stream.re...
code_fim
hard
{ "lang": "rust", "repo": "NeillJohnston/genetic-tetris-bot", "path": "/interface/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let (state, mino) = parse_request(&request); // ... let response = make_response(Vec::new()); } }<|fim_prefix|>// repo: NeillJohnston/genetic-tetris-bot path: /interface/src/main.rs mod protocol; use std::net::{TcpListener, TcpStream}; use std::io::prelude::*; use protocol::*; fn main() { let...
code_fim
medium
{ "lang": "rust", "repo": "NeillJohnston/genetic-tetris-bot", "path": "/interface/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> loop { let mut buffer = Vec::new(); stream.read(&mut buffer).unwrap(); let request = String::from_utf8(buffer).unwrap(); let (state, mino) = parse_request(&request); // ... let response = make_response(Vec::new()); } }<|fim_prefix|>// repo: NeillJohnston/genetic-tetris-bot path: /interf...
code_fim
hard
{ "lang": "rust", "repo": "NeillJohnston/genetic-tetris-bot", "path": "/interface/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TrveFenris/unlam-crypto-rustchain path: /server/src/main.rs #[macro_use] extern crate lazy_static; extern crate futures; extern crate hyper; mod api; mod blockdata; mod types; use futures::{future, Future}; use std::env; use hyper::client::HttpConnector; use hyper::service::service_fn; use hy...
code_fim
hard
{ "lang": "rust", "repo": "TrveFenris/unlam-crypto-rustchain", "path": "/server/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("Received request: {:#?}", req); match (req.method(), req.uri().path()) { (&Method::POST, "/transactions/new") => api::get_transactions_new(req), (&Method::OPTIONS, "/transactions/new") => Box::new(future::ok( Response::builder() .status(StatusC...
code_fim
hard
{ "lang": "rust", "repo": "TrveFenris/unlam-crypto-rustchain", "path": "/server/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: j4in/cdrs path: /src/consistency.rs #![warn(missing_docs)] //! The module contains Rust representation of Cassandra consistency levels. use std::io; use std::convert::From; use super::{IntoBytes, FromCursor}; use super::types::*; use super::FromBytes; /// `Consistency` is an enum which represen...
code_fim
hard
{ "lang": "rust", "repo": "j4in/cdrs", "path": "/src/consistency.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> return match from_bytes(bytes.clone()) { 0x0000 => Consistency::Any, 0x0001 => Consistency::One, 0x0002 => Consistency::Two, 0x0003 => Consistency::Three, 0x0004 => Consistency::Quorum, 0x0005 => Consistency::All, ...
code_fim
hard
{ "lang": "rust", "repo": "j4in/cdrs", "path": "/src/consistency.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl From<i32> for Consistency { fn from(bytes: i32) -> Consistency { return match bytes { 0x0000 => Consistency::Any, 0x0001 => Consistency::One, 0x0002 => Consistency::Two, 0x0003 => Consistency::Three, 0x0004 => Consistency::Quorum...
code_fim
hard
{ "lang": "rust", "repo": "j4in/cdrs", "path": "/src/consistency.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> num_count.entry(num).and_modify(|c| *c += 1).or_insert(1); counts[idx] = num_count .range(..num) .fold(0, |sum, (_, count)| sum + *count); } counts } }<|fim_prefix|>// repo: dtynn/learning path: /leetcode-rs/p0315_count_of_small...
code_fim
medium
{ "lang": "rust", "repo": "dtynn/learning", "path": "/leetcode-rs/p0315_count_of_smaller_numbers_after_self/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dtynn/learning path: /leetcode-rs/p0315_count_of_smaller_numbers_after_self/src/lib.rs pub struct Solution {} use std::collections::BTreeMap; impl Solution { pub fn count_smaller(nums: Vec<i32>) -> Vec<i32> { let size = nums.len(); if size == 0 { return vec![]; ...
code_fim
medium
{ "lang": "rust", "repo": "dtynn/learning", "path": "/leetcode-rs/p0315_count_of_smaller_numbers_after_self/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for i in 0..size { let idx = size - 1 - i; let num = nums[idx]; num_count.entry(num).and_modify(|c| *c += 1).or_insert(1); counts[idx] = num_count .range(..num) .fold(0, |sum, (_, count)| sum + *count); } ...
code_fim
medium
{ "lang": "rust", "repo": "dtynn/learning", "path": "/leetcode-rs/p0315_count_of_smaller_numbers_after_self/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // start up our connector let connection = Connection::builder() // <2> .single_node_connection(endpoint) .await; // Subscription subscription(&connection, database_url).await; // <3> } // end::start[] // Copied from ch02/db_iron_example/src/db/connectrs pub type ...
code_fim
hard
{ "lang": "rust", "repo": "eveningcafe/rustfortheiot", "path": "/retrieval_svc/src/cqrs.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pooled_conn_mgr } pub fn establish_connection_pool(database_url: &str) -> PgPool { let manager = ConnectionManager::<PgConnection>::new(database_url); // Get the pooled connection manager Pool::new(manager).expect("Failed creating connection pool") } // tag::sub[] // Constants pub const...
code_fim
hard
{ "lang": "rust", "repo": "eveningcafe/rustfortheiot", "path": "/retrieval_svc/src/cqrs.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: eveningcafe/rustfortheiot path: /retrieval_svc/src/cqrs.rs use eventstore::{ Connection, EventData }; //use futures::executor::block_on; use log::{info, debug}; use tokio::prelude::*; use std::error::Error; use diesel::r2d2::{ Pool, PooledConnection, ConnectionManager, PoolError }; use diesel::...
code_fim
hard
{ "lang": "rust", "repo": "eveningcafe/rustfortheiot", "path": "/retrieval_svc/src/cqrs.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[test] // from positive isize fn pos_xxx_isiz() { assert_eq!( Frac::new(5, 1), Frac::from(5_isize), ); } #[test] // from zero i8 fn zer_xxx_i8xx() { assert_eq!( Frac::new(0, 1), Frac::from(0_i8), ); } #[test] // from zero i16 fn zer_xxx_i16x() { asser...
code_fim
hard
{ "lang": "rust", "repo": "nekodjin/frac", "path": "/src/tests/frm.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nekodjin/frac path: /src/tests/frm.rs use super::super::Frac; #[test] // from positive u8 fn pos_xxx_u8xx() { assert_eq!( Frac::new(5, 1), Frac::from(5_u8), ); } #[test] // from positive u16 fn pos_xxx_u16x() { assert_eq!( Frac::new(5, 1), Frac::from...
code_fim
hard
{ "lang": "rust", "repo": "nekodjin/frac", "path": "/src/tests/frm.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: three-rs/three path: /src/util.rs //! Internal utility functions. use std::{fs, io, path}; use std::hash::{Hash, Hasher}; /// Reads the entire contents of a file into a `String`. pub fn read_file_to_string<P: AsRef<path::Path>>(path: P) -> io::Result<String> { use self::io::Read; let f...
code_fim
medium
{ "lang": "rust", "repo": "three-rs/three", "path": "/src/util.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Hash slice of floats using its bit interpretation. pub fn hash_f32_slice<H: Hasher>( value: &[f32], state: &mut H, ) { for element in value { element.to_bits().hash(state); } }<|fim_prefix|>// repo: three-rs/three path: /src/util.rs //! Internal utility functions. use std::{f...
code_fim
hard
{ "lang": "rust", "repo": "three-rs/three", "path": "/src/util.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn only_two_adjacent_same(digits: Password) -> bool { let mut i = 0; let end = digits.len() - 1; while i < end { let mut run_len = 1; let mut candidate = digits[i]; let mut next = digits[i + 1]; while candidate == next && i < end - 1 { i += 1; ...
code_fim
hard
{ "lang": "rust", "repo": "nathanjhaveri/advent-of-code-2019", "path": "/4/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nathanjhaveri/advent-of-code-2019 path: /4/src/main.rs type Password = [i32; 6]; fn main() { let lower = 372_304; let upper = 847_060; let valid = find_valid(lower, upper); println!("valid: {}", valid); } fn find_valid(lower: i32, upper: i32) -> i32 { let mut count = 0; ...
code_fim
hard
{ "lang": "rust", "repo": "nathanjhaveri/advent-of-code-2019", "path": "/4/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut args = env::args(); if args.len() == 2 { println!("{}", secd::run_lisp_file(&args.nth(1).unwrap()).expect("main")); } else { println!("expected 1 file"); } }<|fim_prefix|>// repo: kmtoki/secd-rs path: /src/main.rs extern crate secd; use std::env; ...
code_fim
easy
{ "lang": "rust", "repo": "kmtoki/secd-rs", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kmtoki/secd-rs path: /src/main.rs extern crate secd; use std::env; <|fim_suffix|> let mut args = env::args(); if args.len() == 2 { println!("{}", secd::run_lisp_file(&args.nth(1).unwrap()).expect("main")); } else { println!("expected 1 file"); } ...
code_fim
easy
{ "lang": "rust", "repo": "kmtoki/secd-rs", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ynotstartups/advent_of_code_2018 path: /t13/src/main.rs use std::cmp::Ordering; use std::fs; enum CartTurn { Left, Straight, Right, } #[derive(Debug)] enum Direction { Up, Down, Left, Right, } #[derive(Debug, Copy, Clone)] struct Position { x: usize, y: usize...
code_fim
hard
{ "lang": "rust", "repo": "ynotstartups/advent_of_code_2018", "path": "/t13/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut remove_index = Vec::new(); for (index, cart) in &mut self.carts.iter().enumerate() { for (o_index, other_cart) in &mut self.carts.iter().enumerate() { if index != o_index && cart.position == other_cart.position { ...
code_fim
hard
{ "lang": "rust", "repo": "ynotstartups/advent_of_code_2018", "path": "/t13/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub use self::{ meta_type::MetaType, registry::{IntoCompact, Registry}, type_def::*, type_id::*, }; #[cfg(feature = "derive")] pub use type_metadata_derive::{Metadata, TypeDef, TypeId}; pub trait Metadata: HasTypeId + HasTypeDef { fn meta_type() -> MetaType; } impl<T> Metadata for T where T: ?Siz...
code_fim
medium
{ "lang": "rust", "repo": "Robbepop/type-metadata", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Robbepop/type-metadata path: /src/lib.rs // Copyright 2019 // by Centrality Investments Ltd. // and Parity Technologies (UK) Ltd. // // 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...
code_fim
hard
{ "lang": "rust", "repo": "Robbepop/type-metadata", "path": "/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests; pub use self::{ meta_type::MetaType, registry::{IntoCompact, Registry}, type_def::*, type_id::*, }; #[cfg(feature = "derive")] pub use type_metadata_derive::{Metadata, TypeDef, TypeId}; pub trait Metadata: HasTypeId + HasTypeDef { fn meta_type() -> MetaType; } impl<T> Meta...
code_fim
hard
{ "lang": "rust", "repo": "Robbepop/type-metadata", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Laegel/wp-theme-studio path: /vendors/elementor/src-tauri/src/main.rs #![cfg_attr( all(not(debug_assertions), target_os = "windows"), windows_subsystem = "windows" )] use std::process::{Command, Stdio}; mod cmd; mod utils; use fs_extra::dir::{copy, CopyOptions}; use serde::Serialize; use ...
code_fim
hard
{ "lang": "rust", "repo": "Laegel/wp-theme-studio", "path": "/vendors/elementor/src-tauri/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> tauri::execute_promise( _webview, move || Ok(serde_json::to_string(&themes).unwrap()), callback, error, ) } FetchTemplatesCommand { // identifier, callback, ...
code_fim
hard
{ "lang": "rust", "repo": "Laegel/wp-theme-studio", "path": "/vendors/elementor/src-tauri/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marcosvscampos/rust-strategy-pattern-demo path: /src/main.rs #[macro_use] extern crate lazy_static; use std::collections::HashMap; mod models; mod strategies; mod utils; use utils::printer::*; use utils::input::*; use models::order::Order; use strategies::payment_method::PaymentMethod; use s...
code_fim
hard
{ "lang": "rust", "repo": "marcosvscampos/rust-strategy-pattern-demo", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> while !order.is_closed() { let mut continue_choice; loop { print_products_menu(); let choice = get_user_input(); let cost = match price_on_products.get(&choice) { Some(&price) => price, None => { ...
code_fim
hard
{ "lang": "rust", "repo": "marcosvscampos/rust-strategy-pattern-demo", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut price_on_products : HashMap<String, i32> = HashMap::new(); let mut order = Order::new(); price_on_products.insert("1".to_string(), 2200); price_on_products.insert("2".to_string(), 1850); price_on_products.insert("3".to_string(), 1100); price_on_products.insert("4".to_strin...
code_fim
hard
{ "lang": "rust", "repo": "marcosvscampos/rust-strategy-pattern-demo", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bkircher/crazytanks path: /src/main.rs use bevy::prelude::*; const ARENA_WIDTH: u32 = 10; const ARENA_HEIGHT: u32 = 10; #[derive(Bundle)] struct Tank {} struct Materials { body: Handle<ColorMaterial>, } struct Size { width: f32, height: f32, } impl Size { pub fn square(x: f3...
code_fim
hard
{ "lang": "rust", "repo": "bkircher/crazytanks", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn size_scaling(windows: Res<Windows>, mut query: Query<(&Size, &mut Sprite)>) { let window = windows.get_primary().unwrap(); for (sprite_size, mut sprite) in query.iter_mut() { sprite.size = Vec2::new( sprite_size.width / ARENA_WIDTH as f32 * window.width() as f32, ...
code_fim
hard
{ "lang": "rust", "repo": "bkircher/crazytanks", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: j1ah0ng/leetcode path: /problems/add_two_numbers_ii/solution.rs // Definition for singly-linked list. // #[derive(PartialEq, Eq, Clone, Debug)] // pub struct ListNode { // pub val: i32, // pub next: Option<Box<ListNode>> // } // // impl ListNode { // #[inline] // fn new(val: i32) -> Sel...
code_fim
hard
{ "lang": "rust", "repo": "j1ah0ng/leetcode", "path": "/problems/add_two_numbers_ii/solution.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut overflow: i32 = 0; let mut last: Option<Box<ListNode>> = None; let min = min(stack1.len(), stack2.len()); let mut ordered_stacks = match stack1.len() < stack2.len() { true => (stack1, stack2), _ => (stack2, stack1), ...
code_fim
medium
{ "lang": "rust", "repo": "j1ah0ng/leetcode", "path": "/problems/add_two_numbers_ii/solution.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cksac/fake-rs path: /fake/src/impls/std/num.rs use crate::{Dummy, Faker}; use rand::distributions::{Distribution, Uniform}; use rand::Rng; use std::num::{NonZeroI8, NonZeroI16, NonZeroI32, NonZeroI64, NonZeroI128, NonZeroIsize, NonZeroU8, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU128, NonZeroU...
code_fim
medium
{ "lang": "rust", "repo": "cksac/fake-rs", "path": "/fake/src/impls/std/num.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> impl Dummy<Faker> for $nz_typ { fn dummy_with_rng<R: Rng + ?Sized>(_: &Faker, rng: &mut R) -> Self { if rng.gen_bool(0.5) { let u = Uniform::new_inclusive(<$typ>::MIN, -1); <$nz_typ>::new(u.sample(rng)).unwrap() }...
code_fim
medium
{ "lang": "rust", "repo": "cksac/fake-rs", "path": "/fake/src/impls/std/num.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: purpleposeidon/rust-x86asm path: /src/test/instruction_tests/instr_idiv.rs use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; use ::test::run_test; #[tes...
code_fim
hard
{ "lang": "rust", "repo": "purpleposeidon/rust-x86asm", "path": "/src/test/instruction_tests/instr_idiv.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> run_test(&Instruction { mnemonic: Mnemonic::IDIV, operand1: Some(Direct(ESP)), operand2: None, operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: None, sae: false, mask: None, broadcast: None }, &[247, 252], OperandSize::Dword) } #[test] fn idiv_18() { run_test(&Instruc...
code_fim
hard
{ "lang": "rust", "repo": "purpleposeidon/rust-x86asm", "path": "/src/test/instruction_tests/instr_idiv.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Ok(()) } pub async fn start_watch_for_partition( &self, socket: &mut AllMultiplexerSocket, ) -> Result<(), KfSocketError> { use dataplane::api::RequestMessage; use fluvio_sc_schema::objects::WatchRequest; debug!("start watch for partition"); ...
code_fim
hard
{ "lang": "rust", "repo": "davidftv/fluvio", "path": "/src/client/src/sync/store.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: davidftv/fluvio path: /src/client/src/sync/store.rs use tracing::debug; use kf_socket::AllMultiplexerSocket; use kf_socket::KfSocketError; use crate::metadata::spu::SpuSpec; use crate::metadata::partition::PartitionSpec; use super::controller::MetadataSyncController; use super::StoreContext; ...
code_fim
hard
{ "lang": "rust", "repo": "davidftv/fluvio", "path": "/src/client/src/sync/store.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub async fn start_watch_for_partition( &self, socket: &mut AllMultiplexerSocket, ) -> Result<(), KfSocketError> { use dataplane::api::RequestMessage; use fluvio_sc_schema::objects::WatchRequest; debug!("start watch for partition"); let req_msg = R...
code_fim
hard
{ "lang": "rust", "repo": "davidftv/fluvio", "path": "/src/client/src/sync/store.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>ine(always)] #[must_use] pub fn eocie(&mut self) -> EOCIE_W<CR_SPEC, 5> { EOCIE_W::new(self) } #[doc = "Bit 6 - Header Parsing Done Interrupt Enable"] #[inline(always)] #[must_use] pub fn hpdie(&mut self) -> HPDIE_W<CR_SPEC, 6> { HPDIE_W::new(self) } #[d...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32f7/src/stm32f7x7/jpeg/cr.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stm32-rs/stm32-rs-nightlies path: /stm32f7/src/stm32f7x7/jpeg/cr.rs #[doc = "Register `CR` reader"] pub type R = crate::R<CR_SPEC>; #[doc = "Register `CR` writer"] pub type W = crate::W<CR_SPEC>; #[doc = "Field `JCEN` reader - JPEG Core Enable"] pub type JCEN_R = crate::BitReader; #[doc = "Field...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32f7/src/stm32f7x7/jpeg/cr.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>Parsing Done Interrupt Enable"] #[inline(always)] pub fn hpdie(&self) -> HPDIE_R { HPDIE_R::new(((self.bits >> 6) & 1) != 0) } #[doc = "Bit 11 - Input DMA Enable"] #[inline(always)] pub fn idmaen(&self) -> IDMAEN_R { IDMAEN_R::new(((self.bits >> 11) & 1) != 0) }...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32f7/src/stm32f7x7/jpeg/cr.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> IPTAT_CTBM_TRIM_R::new(((self.bits >> 4) & 0x0f) as u8) } } impl W { #[doc = "Bits 0:3 - IPTAT trim 0x0 : Minimum IPTAT current (~150nA at room) 0xF : Maximum IPTAT current (~350nA at room)"] #[inline(always)] pub fn iptat_core_trim(&mut self) -> IPTAT_CORE_TRIM_W { IPTAT_CO...
code_fim
hard
{ "lang": "rust", "repo": "mvertescher/psoc6-pac", "path": "/src/pass/iptat_trim0.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mvertescher/psoc6-pac path: /src/pass/iptat_trim0.rs #[doc = "Reader of register IPTAT_TRIM0"] pub type R = crate::R<u32, super::IPTAT_TRIM0>; #[doc = "Writer for register IPTAT_TRIM0"] pub type W = crate::W<u32, super::IPTAT_TRIM0>; #[doc = "Register IPTAT_TRIM0 `reset()`'s with value 0"] impl ...
code_fim
hard
{ "lang": "rust", "repo": "mvertescher/psoc6-pac", "path": "/src/pass/iptat_trim0.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> for hitable in self { if let Some(candidateHit) = hitable.hit(r, tmin, tmax) { match hit { None => hit = Some(candidateHit), Some(prev) => if candidateHit.t < prev.t { hit = Some(candidateHit); } } } } hit } ...
code_fim
hard
{ "lang": "rust", "repo": "ankmachine/rure", "path": "/rure/src/hitable.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ankmachine/rure path: /rure/src/hitable.rs use crate::helper::vec3::{Vec3, unit_vector}; use crate::core::ray::Ray; #[derive(Clone, Copy)] pub struct HitRecord{ pub t: f32, pub p: Vec3, pub normal: Vec3 } pub trait Hitable{ // book returns boolean, but we are retuening hitrecord object ...
code_fim
hard
{ "lang": "rust", "repo": "ankmachine/rure", "path": "/rure/src/hitable.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DownWithUp/WhoCalls path: /src/main.rs use std::fs; use clap::Parser; use goblin::Object; /// Puts all the files in a directory into a vector. On success returns None, else returns the std::io::error /// from io::Result. /// /// # Arguments /// /// * `directory_path` - The path which to colle...
code_fim
hard
{ "lang": "rust", "repo": "DownWithUp/WhoCalls", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if let Some(error) = collect_all_files("C:\\Windows\\System32\\Drivers", &mut total_paths) { panic!("[!] Error: {error}"); } for path in &total_paths { if let Ok(buffer) = fs::read(path) { let object = Object::parse(&buffer); match object { ...
code_fim
hard
{ "lang": "rust", "repo": "DownWithUp/WhoCalls", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kaj/rsass path: /rsass/tests/spec/directives/warn.rs //! Tests auto-converted from "sass-spec/spec/directives/warn.hrx" #[allow(unused)] fn runner() -> crate::TestRunner { super::runner().with_cwd("warn") } #[test] fn escaped() { assert_eq!( runner().ok("@w\\61rn warning;\ ...
code_fim
hard
{ "lang": "rust", "repo": "kaj/rsass", "path": "/rsass/tests/spec/directives/warn.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn function() { assert_eq!( runner().ok("@function c() {\ \n @warn test;\ \n @return d;\ \n}\n\ \na {\ \n b: c();\ \n}\n"), "a {\ \n b: d;\ \n}\n" ); ...
code_fim
hard
{ "lang": "rust", "repo": "kaj/rsass", "path": "/rsass/tests/spec/directives/warn.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!( runner().ok("@mixin b() {\ \n @warn test;\ \n c: d;\ \n}\n\ \na {\ \n @include b();\ \n}\n"), "a {\ \n c: d;\ \n}\n" ); } #[test] fn property(...
code_fim
hard
{ "lang": "rust", "repo": "kaj/rsass", "path": "/rsass/tests/spec/directives/warn.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn after(start_date: DateTime<UTC>) -> DateTime<UTC> { return start_date + Duration::seconds(1_000_000_000) }<|fim_prefix|>// repo: BenBarrett89/exercism path: /rust/gigasecond/src/lib.rs extern crate chrono; <|fim_middle|>use chrono::{DateTime, Duration, UTC};
code_fim
easy
{ "lang": "rust", "repo": "BenBarrett89/exercism", "path": "/rust/gigasecond/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: BenBarrett89/exercism path: /rust/gigasecond/src/lib.rs extern crate chrono; <|fim_suffix|>pub fn after(start_date: DateTime<UTC>) -> DateTime<UTC> { return start_date + Duration::seconds(1_000_000_000) }<|fim_middle|>use chrono::{DateTime, Duration, UTC};
code_fim
easy
{ "lang": "rust", "repo": "BenBarrett89/exercism", "path": "/rust/gigasecond/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for line in reader.lines() { let line = line?; let output: Output = serde_json::from_str(&line)?; if let Some(message) = output.message { for child in message.children { for span in child.spans { if file == Path::new(&span.file_n...
code_fim
hard
{ "lang": "rust", "repo": "jD91mZM2/rust-import", "path": "/src/compile.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jD91mZM2/rust-import path: /src/compile.rs use failure::Error; use serde_json; use std::io::BufReader; use std::io::prelude::*; use std::path::Path; use std::process::{Command, Stdio}; use syn::{self, ItemUse}; #[derive(Deserialize, Debug)] struct Span { file_name: String, suggested_rep...
code_fim
hard
{ "lang": "rust", "repo": "jD91mZM2/rust-import", "path": "/src/compile.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> (import, imports.iter().all(|&(ref import, _)| import.trim() != trim)) }; if add { // ItemUse does not implement PartialEq. // Can't push trimmed because ...
code_fim
hard
{ "lang": "rust", "repo": "jD91mZM2/rust-import", "path": "/src/compile.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> }, capabilities: huelib::resource::light::Capabilities { certified: true, control: huelib::resource::light::ControlCapabilities { min_dimlevel: None, max_lumen: None, color_gamut: None, ...
code_fim
hard
{ "lang": "rust", "repo": "rustyforks/Friday", "path": "/friday/friday-vendor/vendor-philips-hue/src/serializeable_lights.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> huelib::resource::Light { id: light.id, name: light.name, kind: light.kind, state: huelib::resource::light::State { on: light.state.on, brightness: light.state.brightness, saturation: light.state.satura...
code_fim
hard
{ "lang": "rust", "repo": "rustyforks/Friday", "path": "/friday/friday-vendor/vendor-philips-hue/src/serializeable_lights.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rustyforks/Friday path: /friday/friday-vendor/vendor-philips-hue/src/serializeable_lights.rs use huelib; use serde_derive::{Deserialize, Serialize}; use crate::core::State; /// This module exists because huelib does not /// derive Serialize on its Lights struct /// So I am using this to be a...
code_fim
hard
{ "lang": "rust", "repo": "rustyforks/Friday", "path": "/friday/friday-vendor/vendor-philips-hue/src/serializeable_lights.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn h_side_i_longer_overlap_2() { let src = vec![22, 14, 5, 7, 11, 6, 9, 17, 28, 28, 16, 21, 5, 3, 5, 27, 10, 30, 20, 4, 28, 5, 8, 3, 3, 11, 13, 5, 6, 9, 25, 8, 2, 3, 18, 24, 29, 17, 15, 25, 28, 3, 3, 3, 12, 3, 11, 11, 11, 19, 5, 26, 1, 5, 6, 28, 23, 6]; let dst = vec![5, 5, 22, 3, 16, 21, ...
code_fim
hard
{ "lang": "rust", "repo": "robmoore-i/AdaptiveCompression", "path": "/Code/proj/src/test.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn h_side_i_longer_overlap() { let src = vec![19, 19, 13, 28, 19, 21, 29, 18, 22, 28, 29, 12, 24, 1, 20, 19, 23, 5, 19, 3, 28, 30, 23, 16, 27, 18, 15, 17, 15, 18, 12, 18, 2, 11, 19, 12, 12, 18, 6, 13, 13, 15, 29, 28, 4, 13, 10, 7, 3, 22, 25, 28, 9, 22, 23, 8, 26, 14]; let dst = vec![24, 15...
code_fim
hard
{ "lang": "rust", "repo": "robmoore-i/AdaptiveCompression", "path": "/Code/proj/src/test.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: robmoore-i/AdaptiveCompression path: /Code/proj/src/test.rs use bit_vec::BitVec; use std::collections::HashMap; use overswap_rle_compression; fn discover(dst: i64, visited: &mut BitVec, frontier: &mut Vec<i64>) { if !visited.get((dst as usize) - 1).unwrap_or(false) && !frontier.contains(&...
code_fim
hard
{ "lang": "rust", "repo": "robmoore-i/AdaptiveCompression", "path": "/Code/proj/src/test.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: schnell18/play-rust path: /iterator/src/main.rs use std::ffi::OsStr; use std::path::Path; use std::collections::BTreeSet; use std::collections::HashMap; use std::iter::{once, repeat}; use rand::{Rng, thread_rng}; fn main() { println!("Hello, world!"); test_flat_map(); fizz_buzz(); ...
code_fim
hard
{ "lang": "rust", "repo": "schnell18/play-rust", "path": "/iterator/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut major_cities = HashMap::new(); major_cities.insert("Japan", vec!["Tokyo", "Kyoto"]); major_cities.insert("US", vec!["Portland", "Nashville"]); major_cities.insert("Brazil", vec!["Sao Paulo", "Brasilia"]); major_cities.insert("Kenya", vec!["Nairobi", "Mombasa"]); major_citie...
code_fim
hard
{ "lang": "rust", "repo": "schnell18/play-rust", "path": "/iterator/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wdhg/game-boy path: /src/cpu/mod.rs mod instr; mod instr_funcs; extern crate maplit; use crate::cpu::instr::instr::Instr; use crate::gameboy::MEMORY_SIZE; const INITIAL_PC: u16 = 0x100; const INITIAL_SP: u16 = 0xfff; const REG_8_COUNT: usize = 8; const REG_16_COUNT: usize = 2; // SP and PC onl...
code_fim
hard
{ "lang": "rust", "repo": "wdhg/game-boy", "path": "/src/cpu/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match self.state { Fetch => self.fetch(memory), FetchPrefixed => self.fetch_prefixed(memory), Excute(instr, start_cycle) => self.execute(instr, start_cycle), Halted => return, Stopped => return, // TODO continue on button press } ...
code_fim
hard
{ "lang": "rust", "repo": "wdhg/game-boy", "path": "/src/cpu/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: torkleyy/xi-win path: /xi-win-ui/examples/calc.rs // Copyright 2018 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.apache.org/lice...
code_fim
hard
{ "lang": "rust", "repo": "torkleyy/xi-win", "path": "/xi-win-ui/examples/calc.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Padding::uniform(5.0).ui(widget, ui) } fn digit_button(ui: &mut UiState, display: Id, calc: &Rc<RefCell<CalcState>>, digit: u8) -> Id { let button = Button::new(digit.to_string()).ui(ui); let calc = calc.clone(); ui.add_listener(button, move |_: &mut bool, mut ctx| { let mut c...
code_fim
hard
{ "lang": "rust", "repo": "torkleyy/xi-win", "path": "/xi-win-ui/examples/calc.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn build_calc(ui: &mut UiState) { let calc = Rc::new(RefCell::new(CalcState { display: "0".to_string(), operand: 0.0, operator: 'C', in_num: false, })); let display = Label::new(calc.borrow().display.clone()).ui(ui); let row0 = pad(display, ui); let ro...
code_fim
hard
{ "lang": "rust", "repo": "torkleyy/xi-win", "path": "/xi-win-ui/examples/calc.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl<T: Clone> Into<Vec<T>> for SimpleLinkedList<T> { fn into(self) -> Vec<T> { let mut vec: Vec<T> = vec![]; let mut cloned_list = self.clone(); while let Some(value) = cloned_list.pop() { vec.push(value); } vec.reverse(); vec } }<|fim_prefix|>// repo: DLSLegacy/exercis...
code_fim
hard
{ "lang": "rust", "repo": "DLSLegacy/exercism-rust", "path": "/simple-linked-list/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DLSLegacy/exercism-rust path: /simple-linked-list/src/lib.rs #[derive(Clone)] struct Node<T> { data: T, next: Option<Box<Node<T>>>, } #[derive(Clone)] pub struct SimpleLinkedList<T> { head: Option<Box<Node<T>>>, } impl<T> Default for SimpleLinkedList<T> { fn default() -> Self { Sim...
code_fim
hard
{ "lang": "rust", "repo": "DLSLegacy/exercism-rust", "path": "/simple-linked-list/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut list = SimpleLinkedList::new(); for value in item.iter().cloned() { list.push(value); } list } } impl<T: Clone> Into<Vec<T>> for SimpleLinkedList<T> { fn into(self) -> Vec<T> { let mut vec: Vec<T> = vec![]; let mut cloned_list = self.clone(); while let Some(...
code_fim
hard
{ "lang": "rust", "repo": "DLSLegacy/exercism-rust", "path": "/simple-linked-list/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for n in current.adjacent() { let mut entry = dist.entry(n.clone()).or_insert(::std::usize::MAX); if *entry > current_dist + 1 { *entry = current_dist + 1; q.push_back(n.clone()); } } } ...
code_fim
hard
{ "lang": "rust", "repo": "lux01/advent-of-code-2016", "path": "/day_11_rust/src/graph.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lux01/advent-of-code-2016 path: /day_11_rust/src/graph.rs use std::hash::Hash; use std::collections::{HashMap, VecDeque}; use std::marker::Sized; pub trait Graph { fn adjacent(&self) -> Vec<Self> where Self: Sized; <|fim_suffix|> where T: Graph + Hash + Clone + Eq { let m...
code_fim
hard
{ "lang": "rust", "repo": "lux01/advent-of-code-2016", "path": "/day_11_rust/src/graph.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }