text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> use diesel_demo::schema::posts; let connection = establish_connection(); let result: Vec<Post> = posts::table .filter(posts::published.eq(true)) .limit(5) .load::<Post>(&connection) .expect("Error loading posts"); println!("Displaying {} posts", result.len...
code_fim
medium
{ "lang": "rust", "repo": "sabahtalateh/diesel_demo", "path": "/src/bin/show_posts.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sabahtalateh/diesel_demo path: /src/bin/show_posts.rs use diesel::prelude::*; use diesel_demo::models::Post; use diesel_demo::*; <|fim_suffix|> let connection = establish_connection(); let result: Vec<Post> = posts::table .filter(posts::published.eq(true)) .limit(5) ...
code_fim
medium
{ "lang": "rust", "repo": "sabahtalateh/diesel_demo", "path": "/src/bin/show_posts.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let connection = establish_connection(); let result: Vec<Post> = posts::table .filter(posts::published.eq(true)) .limit(5) .load::<Post>(&connection) .expect("Error loading posts"); println!("Displaying {} posts", result.len()); for post in result { ...
code_fim
medium
{ "lang": "rust", "repo": "sabahtalateh/diesel_demo", "path": "/src/bin/show_posts.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: whereistejas/rust-practice path: /src/coinjar.rs // This programs finds the number of coins and their summed up value // Data model {{{ #[derive(Debug)] struct GenericCoin { pub value: i32, pub quantity: i32, } #[derive(Debug)] enum Coins { Penny(GenericCoin), Dime(GenericCoin),...
code_fim
hard
{ "lang": "rust", "repo": "whereistejas/rust-practice", "path": "/src/coinjar.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn get_total_qty(&mut self) -> i32 { for coin in self.coins.iter() { self.quantity = self.quantity + Self::match_coin(coin).quantity; } self.quantity } pub fn get_total_sum(&mut self) -> i32 { for coin in self.coins.iter() { self.su...
code_fim
hard
{ "lang": "rust", "repo": "whereistejas/rust-practice", "path": "/src/coinjar.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: logan-et-alessio/rust-workshop path: /solutions/src/test/_05_lifetime.rs #![allow(dead_code)] /// /// _Note: May not work in all cases but must work if values are in same scope._ /// fn longest<'a>(first: &'a str, second: &'a str) -> &'a str { <|fim_suffix|> let b = String::from("b"); ...
code_fim
hard
{ "lang": "rust", "repo": "logan-et-alessio/rust-workshop", "path": "/solutions/src/test/_05_lifetime.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn return_bb_when_bb_and_b() { let b = String::from("b"); let bb = String::from("bb"); assert_eq!("bb", longest(&bb, &b)); } }<|fim_prefix|>// repo: logan-et-alessio/rust-workshop path: /solutions/src/test/_05_lifetime.rs #![allow(dead_code)] /// /// _Note: Ma...
code_fim
medium
{ "lang": "rust", "repo": "logan-et-alessio/rust-workshop", "path": "/solutions/src/test/_05_lifetime.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: reime005/xunit-repo-client path: /src/main.rs #[macro_use] extern crate log; mod assemble; mod clap_fern; mod configuration; mod error; mod into; mod parse_glob; mod upload; fn run() -> i32 { <|fim_suffix|> let payload = match assemble::gen_payload(&cfg) { Ok(p) => p, Err(fai...
code_fim
hard
{ "lang": "rust", "repo": "reime005/xunit-repo-client", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let payload = match assemble::gen_payload(&cfg) { Ok(p) => p, Err(fail) => { error!("{}", fail); return 7; } }; let url = cfg.service_url.expect("Service URL not set"); upload::upload(&url, &payload); 0 } fn main() { std::process::ex...
code_fim
hard
{ "lang": "rust", "repo": "reime005/xunit-repo-client", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let debug = false; let mut corner_val = 3; // Starting on top right corner let mut side_len = 3; // Side length is already 3 let mut side = 1; // Side we are currently on let mut all_corners = 2; // Start with center and second corner (1, 3) let mut...
code_fim
hard
{ "lang": "rust", "repo": "mryingster/ProjectEuler", "path": "/problem_058.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mryingster/ProjectEuler path: /problem_058.rs // -*- compile-command: "rustc -o problem_058_rs problem_058.rs" -*- // Copyright (c) 2016 Michael Caldwell fn is_prime(n: u64) -> bool { if n < 2 { return false; } if n == 2 { return true; } if n % 2 == 0 { return false; } <|fim_suffix...
code_fim
hard
{ "lang": "rust", "repo": "mryingster/ProjectEuler", "path": "/problem_058.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("Project Euler - Problem 58:"); println!("Start with 1 and spiral anticlockwise with numbers incrementing from 1 forming a square. What is the side length of the square spiral for which the ratio of primes along both diagonals first falls below 10%?\n"); let debug = false; let m...
code_fim
medium
{ "lang": "rust", "repo": "mryingster/ProjectEuler", "path": "/problem_058.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl<'a, T: Clone> TriMatMut<'a, T> { pub fn fill(&mut self, value: &T) { for r in self.as_mut().to_slice() { *r = value.clone(); } } pub fn clone_from_ref(&mut self, source: TriMatRef<T>) { assert_eq!(self.shape(), source.shape()); self.as_mut().to...
code_fim
hard
{ "lang": "rust", "repo": "xrf/lutario", "path": "/src/tri_mat.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xrf/lutario path: /src/tri_mat.rs m { type Target = usize; fn deref(&self) -> &Self::Target { &self.0 } } impl TriMatDim { pub fn is_valid(dim: usize) -> bool { // make sure (dim + 1) * dim / 2 doesn't overflow || -> Result<isize, ()> { try_ca...
code_fim
hard
{ "lang": "rust", "repo": "xrf/lutario", "path": "/src/tri_mat.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xrf/lutario path: /src/tri_mat.rs pl StrictTriMatDim { pub fn is_valid(dim: usize) -> bool { // make sure (dim - 1) * dim / 2 doesn't overflow || -> Result<isize, ()> { try_cast(dim.checked_sub(1).ok_or(())?.checked_mul(dim).ok_or(())? / 2).ok_or(()) }() ...
code_fim
hard
{ "lang": "rust", "repo": "xrf/lutario", "path": "/src/tri_mat.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: graugaard/advent-of-code-2020 path: /src/util/mod.rs pub mod map; pub mod puzzle_input; /// Represent a group of a larger text. #[derive(PartialOrd, PartialEq, Debug)] pub struct Group<'a> { str: &'a str, } impl<'a> Group<'a> { pub fn new(str: &'a str) -> Self { Group { str } ...
code_fim
hard
{ "lang": "rust", "repo": "graugaard/advent-of-code-2020", "path": "/src/util/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let iterator = GroupIterator::new("grp1-1\n\ngroup2-1\ngroup2-2"); let collection: Vec<Group> = iterator.collect(); assert_eq!(collection.len(), 2); } #[test] fn test_grouping_with_two_groups() { let iterator = GroupIterator::new("grp1-1\n\ngroup2-1\ngroup2-2"...
code_fim
hard
{ "lang": "rust", "repo": "graugaard/advent-of-code-2020", "path": "/src/util/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests { use crate::util::{Group, GroupIterator}; #[test] fn grouping_of_simple_string() { let iterator = GroupIterator::new("group1-1\ngroup1-2"); let collection: Vec<Group> = iterator.collect(); assert_eq!(collection, vec![Group::new("group1-1\ngroup1...
code_fim
hard
{ "lang": "rust", "repo": "graugaard/advent-of-code-2020", "path": "/src/util/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Some(Example(kind, number)) } } pub fn main() { let which_binary = args().skip(1).collect::<Vec<_>>(); let which_binary = Example::from_list(&which_binary); match which_binary { Some(Example(ExampleKind::Regular, 1)) => _01_deserialize_uninitialized::main_(), Some...
code_fim
hard
{ "lang": "rust", "repo": "rodrimati1992/type_level", "path": "/type_level_examples/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn main() { let which_binary = args().skip(1).collect::<Vec<_>>(); let which_binary = Example::from_list(&which_binary); match which_binary { Some(Example(ExampleKind::Regular, 1)) => _01_deserialize_uninitialized::main_(), Some(Example(ExampleKind::Regular, 2)) => _02_mut...
code_fim
hard
{ "lang": "rust", "repo": "rodrimati1992/type_level", "path": "/type_level_examples/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rodrimati1992/type_level path: /type_level_examples/src/main.rs extern crate type_level_examples; use std::env::args; use type_level_examples::*; // Used because this crate supports Rust down to 1.20.0 // when `?` for Option was stabilized in Rust 1.22.0 macro_rules! try_opt { ($expr:expr...
code_fim
hard
{ "lang": "rust", "repo": "rodrimati1992/type_level", "path": "/type_level_examples/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bazelbuild/rules_rust path: /test/unit/exports/lib_c/src/lib.rs // This symbol is an export that `lib_b` exports are re-exports from `lib_a`. use lib_b::greeting_from; pub fn greeting_c() -> String { greeting_from("lib_c") } <|fim_suffix|> #[test] fn test_all_greetings() { a...
code_fim
medium
{ "lang": "rust", "repo": "bazelbuild/rules_rust", "path": "/test/unit/exports/lib_c/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> use lib_b::{greeting_a, greeting_b}; #[test] fn test_all_greetings() { assert_eq!(greeting_a(), "Hello from lib_a!".to_owned()); assert_eq!(greeting_b(), "Hello from lib_b!".to_owned()); assert_eq!(greeting_c(), "Hello from lib_c!".to_owned()); } }<|fim_prefix|>// ...
code_fim
medium
{ "lang": "rust", "repo": "bazelbuild/rules_rust", "path": "/test/unit/exports/lib_c/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: superdump/bounded-planet path: /crates/bounded_planet_core/src/networking/mod.rs pub mod id; pub mod components; pub mo<|fim_suffix|>ialization; pub mod events; pub mod client; pub mod server; pub mod crypto;<|fim_middle|>d systems; pub mod packets; pub mod ser
code_fim
easy
{ "lang": "rust", "repo": "superdump/bounded-planet", "path": "/crates/bounded_planet_core/src/networking/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>ialization; pub mod events; pub mod client; pub mod server; pub mod crypto;<|fim_prefix|>// repo: superdump/bounded-planet path: /crates/bounded_planet_core/src/networking/mod.rs pub mod id; pub mod components; pub mo<|fim_middle|>d systems; pub mod packets; pub mod ser
code_fim
easy
{ "lang": "rust", "repo": "superdump/bounded-planet", "path": "/crates/bounded_planet_core/src/networking/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aristotle9/qt_generator-output path: /qt_core/src/wait_condition.rs /// C++ type: <span style='color: green;'>```QWaitCondition```</span> #[repr(C)] pub struct WaitCondition([u8; ::type_sizes::QT_CORE_WAIT_CONDITION_WAIT_CONDITION]); impl ::cpp_utils::new_uninitialized::NewUninitialized for Wai...
code_fim
hard
{ "lang": "rust", "repo": "aristotle9/qt_generator-output", "path": "/qt_core/src/wait_condition.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// C++ method: <span style='color: green;'>```void QWaitCondition::wakeOne()```</span> /// /// pub fn wake_one(&mut self) { unsafe { ::ffi::qt_core_c_QWaitCondition_wakeOne(self as *mut ::wait_condition::WaitCondition) } } } impl Drop for ::wait_condition::WaitCondition { /// C++ method:...
code_fim
hard
{ "lang": "rust", "repo": "aristotle9/qt_generator-output", "path": "/qt_core/src/wait_condition.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ut-utp/playground path: /hdl/src/ops/op_types.rs use super::{Op, OpKind}; #[derive(Copy, Clone, Debug)] pub struct OpWrapper<T: Op>(T); impl<T: Op> OpWrapper<T> { pub(crate) fn unwrap(self) -> T { self.0 } } impl<T: Op> Op for OpWrapper<T> { type Output = <T as Op>::Output...
code_fim
medium
{ "lang": "rust", "repo": "ut-utp/playground", "path": "/hdl/src/ops/op_types.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> OpWrapper(op) } } #[derive(Copy, Clone, Debug)] pub struct LabeledOp<T: Op>(T, &'static str); // TODO!<|fim_prefix|>// repo: ut-utp/playground path: /hdl/src/ops/op_types.rs use super::{Op, OpKind}; #[derive(Copy, Clone, Debug)] pub struct OpWrapper<T: Op>(T); impl<T: Op> OpWrapper<T> { ...
code_fim
medium
{ "lang": "rust", "repo": "ut-utp/playground", "path": "/hdl/src/ops/op_types.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>use crate::option_to_ok_tuple_or_error; #[native_implemented_function(document/1)] pub fn native(process: &Process, window: Term) -> exception::Result<Term> { let boxed: Boxed<Resource> = window .try_into() .with_context(|| format!("window ({}) must be a window resource", window))?; ...
code_fim
hard
{ "lang": "rust", "repo": "shaneutt/lumen", "path": "/lumen_web/src/window/document_1.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: shaneutt/lumen path: /lumen_web/src/window/document_1.rs //! ```elixir //! case Lumen.Web.Window.document(window) do //! {:ok, document} -> ... //! :error -> ... //! end //! ``` <|fim_suffix|>#[native_implemented_function(document/1)] pub fn native(process: &Process, window: Term) -> exce...
code_fim
hard
{ "lang": "rust", "repo": "shaneutt/lumen", "path": "/lumen_web/src/window/document_1.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut info = Info { script: Script::Greek, lang: Lang::Ell, confidence: 0.0, }; assert_eq!(info.is_reliable(), false); info.confidence = 1.0; assert_eq!(info.is_reliable(), true); } }<|fim_prefix|>// repo: greyblake/whatlan...
code_fim
hard
{ "lang": "rust", "repo": "greyblake/whatlang-rs", "path": "/src/core/info.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: greyblake/whatlang-rs path: /src/core/info.rs use crate::{Lang, Script}; const RELIABLE_CONFIDENCE_THRESHOLD: f64 = 0.9; /// Represents a full outcome of language detection. #[derive(Debug, PartialEq)] pub struct Info { script: Script, lang: Lang, confidence: f64, } impl Info { ...
code_fim
medium
{ "lang": "rust", "repo": "greyblake/whatlang-rs", "path": "/src/core/info.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_is_realiable() { let mut info = Info { script: Script::Greek, lang: Lang::Ell, confidence: 0.0, }; assert_eq!(info.is_reliable(), false); info.confidence = 1.0; assert_eq!(info.is_reliable(), true); } ...
code_fim
hard
{ "lang": "rust", "repo": "greyblake/whatlang-rs", "path": "/src/core/info.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.value } } pub fn run() { let x = Bar::<u32> { value: 100 }; println!("{}", x.value()); }<|fim_prefix|>// repo: s-shin/mino.rs path: /sandbox/src/associated_trait.rs trait Foo { type Value; fn value(&self) -> Self::Value; } struct Bar<Value> { value: Value, } <|fim_...
code_fim
medium
{ "lang": "rust", "repo": "s-shin/mino.rs", "path": "/sandbox/src/associated_trait.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: s-shin/mino.rs path: /sandbox/src/associated_trait.rs trait Foo { type Value; fn value(&self) -> Self::Value; } struct Bar<Value> { value: Value, } <|fim_suffix|>pub fn run() { let x = Bar::<u32> { value: 100 }; println!("{}", x.value()); }<|fim_middle|>impl<Value: Copy> Fo...
code_fim
medium
{ "lang": "rust", "repo": "s-shin/mino.rs", "path": "/sandbox/src/associated_trait.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub fn run() { let x = Bar::<u32> { value: 100 }; println!("{}", x.value()); }<|fim_prefix|>// repo: s-shin/mino.rs path: /sandbox/src/associated_trait.rs trait Foo { type Value; fn value(&self) -> Self::Value; } struct Bar<Value> { value: Value, } <|fim_middle|>impl<Value: Copy> Fo...
code_fim
medium
{ "lang": "rust", "repo": "s-shin/mino.rs", "path": "/sandbox/src/associated_trait.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if is_action_valid(action, &entity, position, &unit_position_map, &action_query) { info!("Execute action {:?}", entity); cmds.send(UnitCmd::ExecuteAction(entity, 0, *position)); } *input_state = In...
code_fim
hard
{ "lang": "rust", "repo": "alec-mccormick/chess", "path": "/src/ui/input.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let team = action_query.get_component::<Team>(*entity).unwrap(); if team.eq(&game_state.active_team) && team.eq(&game_state.local_player_info.team) { info!("Unit for active team selected"); *input_stat...
code_fim
hard
{ "lang": "rust", "repo": "alec-mccormick/chess", "path": "/src/ui/input.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alec-mccormick/chess path: /src/ui/input.rs use bevy::prelude::*; use bevy_networking::{NetworkDelivery, NetworkResource}; use log::info; use crate::{ core::{ unit::{is_action_valid, Actions, Health, Team, Unit, UnitCmd}, GameState, Tile, }, prelude::*, }; #[derive(...
code_fim
hard
{ "lang": "rust", "repo": "alec-mccormick/chess", "path": "/src/ui/input.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: eliovir/rust-examples path: /tutorial-03-syntax_basics.rs /** * 3 Syntax basics * http://doc.rust-lang.org/tutorial.html#syntax-basics * * @license MIT license <http://www.opensource.org/licenses/mit-license.php> */ fn main() { <|fim_suffix|> /* * Although Rust can almost always infer the...
code_fim
hard
{ "lang": "rust", "repo": "eliovir/rust-examples", "path": "/tutorial-03-syntax_basics.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /* * 3.4 Syntax extensions * http://doc.rust-lang.org/tutorial.html#syntax-extensions */ // {} will print the "default format" of a type println!("{} is {}", "the answer", 43); // // {:?} will conveniently print any type println!("what is this thing: {:?}", monster_size); }<|fim_prefix|>// rep...
code_fim
hard
{ "lang": "rust", "repo": "eliovir/rust-examples", "path": "/tutorial-03-syntax_basics.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Signed SSH certificates #[derive(Serialize, Deserialize, Debug)] pub struct DeriveEcdhResponse(ecdh::UncompressedPoint); impl Response for DeriveEcdhResponse { const COMMAND_CODE: command::Code = command::Code::DeriveEcdh; } impl From<DeriveEcdhResponse> for ecdh::UncompressedPoint { fn from...
code_fim
hard
{ "lang": "rust", "repo": "iqlusioninc/yubihsm.rs", "path": "/src/ecdh/commands.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl From<DeriveEcdhResponse> for ecdh::UncompressedPoint { fn from(response: DeriveEcdhResponse) -> ecdh::UncompressedPoint { response.0 } }<|fim_prefix|>// repo: iqlusioninc/yubihsm.rs path: /src/ecdh/commands.rs //! Elliptic Curve Diffie Hellman Commands //! //! **WARNING**: This funct...
code_fim
hard
{ "lang": "rust", "repo": "iqlusioninc/yubihsm.rs", "path": "/src/ecdh/commands.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: iqlusioninc/yubihsm.rs path: /src/ecdh/commands.rs //! Elliptic Curve Diffie Hellman Commands //! //! **WARNING**: This functionality has not been tested and has not yet been //! confirmed to actually work! USE AT YOUR OWN RISK! //! //! You will need to enable the `untested` cargo feature to use...
code_fim
medium
{ "lang": "rust", "repo": "iqlusioninc/yubihsm.rs", "path": "/src/ecdh/commands.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: prscoelho/aoc2020 path: /src/day16/day16.rs use std::{ collections::{HashMap, HashSet}, ops::RangeInclusive, }; #[derive(Debug)] struct Rule { name: String, left: RangeInclusive<u64>, right: RangeInclusive<u64>, } fn parse_ticket(line: &str) -> Vec<u64> { let mut ticket...
code_fim
hard
{ "lang": "rust", "repo": "prscoelho/aoc2020", "path": "/src/day16/day16.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for ticket in other_tickets { error_rate += invalid_fields(&ticket, &rules).iter().sum::<u64>(); } error_rate } pub fn part2(input: &str) -> u64 { let (rules, my_ticket, other_tickets) = parse_input(input); let valid_tickets: Vec<_> = other_tickets .iter() .fi...
code_fim
hard
{ "lang": "rust", "repo": "prscoelho/aoc2020", "path": "/src/day16/day16.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if let Some(binding) = process.binding().find_parent(depth) { binding.set_local(index, value); Ok(Action::None) } else { Err(format!("No binding for depth {}", depth)) } } /// Gets a local variable in one of the parent bindings. /// /// This instruction requires 3 arg...
code_fim
hard
{ "lang": "rust", "repo": "netinmax/inko", "path": "/vm/src/vm/instructions/local_variable.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: netinmax/inko path: /vm/src/vm/instructions/local_variable.rs //! VM instruction handlers for local variable operations. use vm::action::Action; use vm::instruction::Instruction; use vm::instructions::result::InstructionResult; use vm::machine::Machine; use compiled_code::RcCompiledCode; use pr...
code_fim
hard
{ "lang": "rust", "repo": "netinmax/inko", "path": "/vm/src/vm/instructions/local_variable.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let identity = Quaternion::<f32>::IDENTITY; assert_eq!(identity, identity*identity); assert_eq!(identity, identity*identity*identity); } #[test] fn matrix_rotation() { let quat = Quaternion::<f32>::rotation(f32::consts::PI/2.0, Vec3::new(1.0, 0.0, 0.0)); ...
code_fim
hard
{ "lang": "rust", "repo": "seventh-chord/gondola", "path": "/cable_math/src/quat.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<T: Number + Float> From<Vec4<T>> for Quaternion<T> { fn from(vec: Vec4<T>) -> Quaternion<T> { Quaternion { x: vec.x, y: vec.y, z: vec.z, w: vec.w, } } } #[cfg(test)] mod tests { use std::f32; use super::*; use {Mat4,...
code_fim
hard
{ "lang": "rust", "repo": "seventh-chord/gondola", "path": "/cable_math/src/quat.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: seventh-chord/gondola path: /cable_math/src/quat.rs use std::ops::{Add, Sub, Mul, Div}; use std::ops::{MulAssign, DivAssign}; use vec::{Vec3, Vec4}; use mat::{Mat4, Mat3}; use traits::{Number, Float}; #[derive(Debug, Clone, PartialEq)] #[repr(C)] pub struct Quaternion<T> { pub x: T, p...
code_fim
hard
{ "lang": "rust", "repo": "seventh-chord/gondola", "path": "/cable_math/src/quat.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: craftingo/serde_minecraft path: /src/types/byte.rs //! Abstractions over the `byte` type used within Minecraft protocol packets. use std::ops::{Deref, DerefMut}; /// The `byte` type utilised by the Minecraft protocol. /// /// Bytes are signed 8-bit integers represented through the [two's compl...
code_fim
medium
{ "lang": "rust", "repo": "craftingo/serde_minecraft", "path": "/src/types/byte.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl Into<i8> for Byte { fn into(self) -> i8 { self.0 } } impl Deref for Byte { type Target = i8; fn deref(&self) -> &Self::Target { &self.0 } } impl DerefMut for Byte { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 } }<|fim_prefix|>// re...
code_fim
hard
{ "lang": "rust", "repo": "craftingo/serde_minecraft", "path": "/src/types/byte.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kitao/pyxel path: /crates/pyxel-extension/src/variable_wrapper.rs use std::ptr; use pyo3::exceptions::PyAttributeError; use pyo3::prelude::*; use pyxel::Rgb8; use crate::image_wrapper::wrap_pyxel_image; #[pyclass] struct Colors; impl Colors { fn list(&self) -> &[Rgb8] { unsafe { ...
code_fim
hard
{ "lang": "rust", "repo": "kitao/pyxel", "path": "/crates/pyxel-extension/src/variable_wrapper.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let value = match name { // System "width" => pyxel::width().to_object(py), "height" => pyxel::height().to_object(py), "frame_count" => pyxel::frame_count().to_object(py), "is_fullscreen" => pyxel::is_fullscreen().to_object(py), // Input "mouse_...
code_fim
hard
{ "lang": "rust", "repo": "kitao/pyxel", "path": "/crates/pyxel-extension/src/variable_wrapper.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Graphics "colors" => Py::new(py, Colors)?.into_py(py), "screen" => wrap_pyxel_image(pyxel::screen()).into_py(py), "cursor" => wrap_pyxel_image(pyxel::cursor()).into_py(py), "font" => wrap_pyxel_image(pyxel::font()).into_py(py), // Others _ => { ...
code_fim
hard
{ "lang": "rust", "repo": "kitao/pyxel", "path": "/crates/pyxel-extension/src/variable_wrapper.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn set_internal_feedback(&mut self, feedback: f64) { debug_assert!(feedback >= 0.0 && feedback <= 1.0); self.internal_feedback = feedback; } pub fn set_wet_dry_ratio(&mut self, wet_dry_ratio: f64) { debug_assert!(wet_dry_ratio >= 0.0 && wet_dry_ratio <= 1.0); self.wet_dry_ratio ...
code_fim
hard
{ "lang": "rust", "repo": "chris-zen/delay-demo", "path": "/delay/src/delay_line.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chris-zen/delay-demo path: /delay/src/delay_line.rs use crate::delay_buffer::DelayBuffer; pub enum FeedbackSource { Internal, External } pub struct DelayLine { buffer: DelayBuffer, delay_samples: usize, feedback_source: FeedbackSource, internal_feedback: f64, wet_dry_ratio: f64,...
code_fim
medium
{ "lang": "rust", "repo": "chris-zen/delay-demo", "path": "/delay/src/delay_line.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Maix0/pixel_engine path: /pixel_engine/src/engine/inputs.rs use px_backend::winit; #[derive(Debug, Clone, Copy)] /// A Simple Struct that Represent an Input pub struct Input { /// Is the input pressed on that frame pub pressed: bool, /// Is the input held on that frame pub...
code_fim
hard
{ "lang": "rust", "repo": "Maix0/pixel_engine", "path": "/pixel_engine/src/engine/inputs.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug, Clone, Copy)] pub(crate) struct Mouse { /// State of each mouse button /// 0 => None /// 1 => Pressed /// 2 => Held /// 3 => Released pub(crate) buttons: [Input; 3], pub(crate) pos: (u32, u32), pub(crate) wheel: MouseWheel, } impl Mouse { p...
code_fim
hard
{ "lang": "rust", "repo": "Maix0/pixel_engine", "path": "/pixel_engine/src/engine/inputs.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub use winit::event::VirtualKeyCode as Keycodes; #[derive(Eq, PartialEq, Debug, Hash, Clone, Copy)] /// Represent a Key pub struct Key { /// The keycode pub key: Keycodes, } impl From<winit::event::KeyboardInput> for Key { fn from(key: winit::event::KeyboardInput) -> Self { ...
code_fim
hard
{ "lang": "rust", "repo": "Maix0/pixel_engine", "path": "/pixel_engine/src/engine/inputs.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>otor, TachoMotor)] #[class_name = "tacho-motor"] #[driver_name = "lego-ev3-l-motor"] #[port = "crate::motors::MotorPort"] pub struct LargeMotor { driver: Driver, }<|fim_prefix|>// repo: windoze/ev3dev-lang-rust path: /src/motors/large_motor.rs use super::{Motor, TachoMotor}; use crate::{Attribute, De...
code_fim
medium
{ "lang": "rust", "repo": "windoze/ev3dev-lang-rust", "path": "/src/motors/large_motor.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>] #[port = "crate::motors::MotorPort"] pub struct LargeMotor { driver: Driver, }<|fim_prefix|>// repo: windoze/ev3dev-lang-rust path: /src/motors/large_motor.rs use super::{Motor, TachoMotor}; use crate::{Attribute, Device, Driver, Ev3Result, F<|fim_middle|>indable}; /// EV3/NXT large servo motor #[...
code_fim
medium
{ "lang": "rust", "repo": "windoze/ev3dev-lang-rust", "path": "/src/motors/large_motor.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: windoze/ev3dev-lang-rust path: /src/motors/large_motor.rs use super::{Motor, TachoMotor}; use crate::{Attribute, Device, Driver, Ev3Result, F<|fim_suffix|>] #[port = "crate::motors::MotorPort"] pub struct LargeMotor { driver: Driver, }<|fim_middle|>indable}; /// EV3/NXT large servo motor #[...
code_fim
medium
{ "lang": "rust", "repo": "windoze/ev3dev-lang-rust", "path": "/src/motors/large_motor.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mattjbray/advent-of-code-2018 path: /src/day_9.rs use std::collections::HashMap; pub fn run() { let part_1_solution = ::day_4::max_entry(&play(455, 71223)); println!("Day 9, part 1: {:?}", part_1_solution); // let part_2_solution = ::day_4::max_entry(&play(455, 71223 * 100)); /...
code_fim
hard
{ "lang": "rust", "repo": "mattjbray/advent-of-code-2018", "path": "/src/day_9.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_play() { assert_eq!(::day_4::max_entry(&play(9, 25)), Some((5, 32))); assert_eq!(::day_4::max_entry(&play(10, 1618)).map(|t| t.1), Some(8317)); assert_eq!(::day_4::max_entry(&play(13, 7999)).map(|t| t.1), Some(146373)); assert_eq!(::day_4::max_entry(...
code_fim
hard
{ "lang": "rust", "repo": "mattjbray/advent-of-code-2018", "path": "/src/day_9.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(::day_4::max_entry(&play(9, 25)), Some((5, 32))); assert_eq!(::day_4::max_entry(&play(10, 1618)).map(|t| t.1), Some(8317)); assert_eq!(::day_4::max_entry(&play(13, 7999)).map(|t| t.1), Some(146373)); assert_eq!(::day_4::max_entry(&play(17, 1104)).map(|t| t.1), So...
code_fim
hard
{ "lang": "rust", "repo": "mattjbray/advent-of-code-2018", "path": "/src/day_9.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let _ = meter_status(&opts.metrics_addr, &opts.metrics_prefix, resp.status()); Ok(()) } fn meter_status(addr: &str, prefix: &str, status: http::StatusCode) -> prometheus::Result<()> { let res_gauge = prometheus::register_gauge!( format!("{}_last_completed_epoch_seconds", prefix), ...
code_fim
hard
{ "lang": "rust", "repo": "jchorl/httprom", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jchorl/httprom path: /src/main.rs #[macro_use] extern crate prometheus; use clap::Clap; use http::header::{HeaderMap, HeaderName, HeaderValue}; use http::Method; use std::str::FromStr; use std::time::{SystemTime, UNIX_EPOCH}; #[derive(Clap)] struct Opts { #[clap(short = "X", long = "reques...
code_fim
hard
{ "lang": "rust", "repo": "jchorl/httprom", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let res_gauge = prometheus::register_gauge!( format!("{}_last_completed_epoch_seconds", prefix), String::from("The time of last completion") ) .unwrap(); res_gauge.set( SystemTime::now() .duration_since(UNIX_EPOCH) .unwrap() .as_s...
code_fim
hard
{ "lang": "rust", "repo": "jchorl/httprom", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/rewasm path: /src/analysis/mod.rs use std::collections::{HashMap, HashSet}; use crate::cfg::InstrPos; use crate::ssa::Var; mod dead_code_elimination; mod expression_propagation; pub mod used_vars; <|fim_suffix|>#[derive(Default)] pub struct DefUseMap(pub HashMap<Var, InstrPos>, pub Ha...
code_fim
medium
{ "lang": "rust", "repo": "isgasho/rewasm", "path": "/src/analysis/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl DefUseMap { pub fn new() -> Self { DefUseMap::default() } }<|fim_prefix|>// repo: isgasho/rewasm path: /src/analysis/mod.rs use std::collections::{HashMap, HashSet}; use crate::cfg::InstrPos; use crate::ssa::Var; mod dead_code_elimination; mod expression_propagation; pub mod used_v...
code_fim
medium
{ "lang": "rust", "repo": "isgasho/rewasm", "path": "/src/analysis/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>ring()+" bottles of beer on the wall, "+&n.to_string()+" bottles of beer.\n"+"Take one down and pass it around, "+&num.to_string()+" bottle of beer on the wall.\n\n")), 3...99 => v1.insert_str(0, &String::from(n.to_string()+" bottles of beer on the wall, "+&n.to_string()+" bottles of beer.\n"+...
code_fim
hard
{ "lang": "rust", "repo": "septilsnna/rust-exercism", "path": "/beer-song/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: septilsnna/rust-exercism path: /beer-song/src/lib.rs pub fn verse(n: i32) -> String { let mut v1 = String::new(); let num = n - 1; match n { 0 => v1.push_str("No more bottles of beer on the wall, no more bottles of beer.\nGo to the store and buy some more, 99 bottles of beer ...
code_fim
hard
{ "lang": "rust", "repo": "septilsnna/rust-exercism", "path": "/beer-song/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn process_events(&mut self); fn fixed_update(&mut self, delta: f64); fn update(&mut self, delta: f64); fn render(&self); }<|fim_prefix|>// repo: emersonmx/rust-sandbox path: /code/mng/src/engine/mod.rs pub trait GameLoop { fn fixed_update_delta(&self) -> f64 { 1.0 / 60.0 ...
code_fim
hard
{ "lang": "rust", "repo": "emersonmx/rust-sandbox", "path": "/code/mng/src/engine/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: emersonmx/rust-sandbox path: /code/mng/src/engine/mod.rs pub trait GameLoop { fn fixed_update_delta(&self) -> f64 { 1.0 / 60.0 } fn is_running(&self) -> bool { true } <|fim_suffix|> fn fixed_update(&mut self, delta: f64); fn update(&mut self, delta: f64);...
code_fim
hard
{ "lang": "rust", "repo": "emersonmx/rust-sandbox", "path": "/code/mng/src/engine/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> } }); } fn register_client(client: Client, clients: Arc<Mutex<Vec<Client>>>, postman_tx: Sender<PostmanMessage>) { // Say Hello to new client let msg = PostmanMessage { client: client.clone(), content: welcome_reply(client.username.clone()) }; send_message(msg...
code_fim
hard
{ "lang": "rust", "repo": "gondyb/irc-rs", "path": "/src/registration.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gondyb/irc-rs path: /src/registration.rs use std::sync::mpsc::{Receiver, Sender}; use crate::client_handler::Client; use std::thread; use std::sync::{Arc, Mutex}; use crate::postman::{PostmanMessage, send_message}; use crate::protocol::welcome_reply; use crate::channels::{ChannelMessage}; pub e...
code_fim
hard
{ "lang": "rust", "repo": "gondyb/irc-rs", "path": "/src/registration.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Vanderkast/ray-tracing-rust path: /src/model/ray.rs use crate::model::vec3::Vec3; #[derive(Debug, Copy, Clone)] pub struct Ray { origin: Vec3, direction: Vec3, } <|fim_suffix|>#[cfg(test)] mod tests { use super::*; #[test] fn point_at() { let ray = Ray { ...
code_fim
hard
{ "lang": "rust", "repo": "Vanderkast/ray-tracing-rust", "path": "/src/model/ray.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let ray = Ray { origin: Vec3::zero(), direction: Vec3::from_i32(2, 2, 2) }; let t = 0.5; assert_eq!(Vec3::one(), ray.point_at(t)); } }<|fim_prefix|>// repo: Vanderkast/ray-tracing-rust path: /src/model/ray.rs use crate::model::vec3::Vec3; #[der...
code_fim
hard
{ "lang": "rust", "repo": "Vanderkast/ray-tracing-rust", "path": "/src/model/ray.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn point_at() { let ray = Ray { origin: Vec3::zero(), direction: Vec3::from_i32(2, 2, 2) }; let t = 0.5; assert_eq!(Vec3::one(), ray.point_at(t)); } }<|fim_prefix|>// repo: Vanderkast/ray-tracing-rust path: /src/model/ray.rs use ...
code_fim
hard
{ "lang": "rust", "repo": "Vanderkast/ray-tracing-rust", "path": "/src/model/ray.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: llogiq/momo path: /wasm/src/lib.rs //! Internal WASM implementation of momo. use proc_macro2::TokenStream; use quote::quote; use std::collections::HashMap; use syn::*; use syn::{fold::Fold, punctuated::Punctuated}; #[derive(Copy, Clone)] // All conversions we support. Check references to this ...
code_fim
hard
{ "lang": "rust", "repo": "llogiq/momo", "path": "/wasm/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let ident = pat_to_ident(pat); parse_quote!(#ident) } fn convert<'a>( inputs: &'a Punctuated<FnArg, Token![,]>, ty_conversions: &HashMap<Ident, Conversion<'a>>, ) -> ( Punctuated<FnArg, Token![,]>, Conversions, Punctuated<Expr, Token![,]>, bool, ) { let mut argtypes = ...
code_fim
hard
{ "lang": "rust", "repo": "llogiq/momo", "path": "/wasm/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: purpleposeidon/rust-x86asm path: /src/test/instruction_tests/vrsqrt28ps.rs use ::{BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; use ::RegType::*; use ::instruction_def::*; use ::Operand::*; use ::Reg::*; use ::RegScale::*; fn vrsqrt28ps_1() { run...
code_fim
hard
{ "lang": "rust", "repo": "purpleposeidon/rust-x86asm", "path": "/src/test/instruction_tests/vrsqrt28ps.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> run_test(&Instruction { mnemonic: Mnemonic::VRSQRT28PS, operand1: Some(Direct(ZMM5)), operand2: Some(IndirectScaledIndexed(EDI, EDX, Four, Some(OperandSize::Dword), None)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: Some(MergeMode::Zero), sae: false, mask: Some(MaskR...
code_fim
medium
{ "lang": "rust", "repo": "purpleposeidon/rust-x86asm", "path": "/src/test/instruction_tests/vrsqrt28ps.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jerdmann/thesoulforge path: /rlox/src/expr.rs use crate::token::*; use crate::token_type::*; use std::fmt; #[derive(Clone, Copy, Debug, PartialEq)] pub enum ExprType { Assign, Binary, Call, Unary, Grouping, Literal, Logical, Variable, } #[derive(Clone, Debug, Pa...
code_fim
hard
{ "lang": "rust", "repo": "jerdmann/thesoulforge", "path": "/rlox/src/expr.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn new_unary(token: Token, node: Expr) -> Expr { let e = Expr { etype: ExprType::Unary, token: token, children: vec![node], }; e } pub fn new_grouping(expr: Expr) -> Expr { let e = Expr { etype: ExprType::Grou...
code_fim
hard
{ "lang": "rust", "repo": "jerdmann/thesoulforge", "path": "/rlox/src/expr.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>use quote::quote; use syn::parse::Nothing; use syn::parse_macro_input; mod expand; mod internal; mod parse; #[proc_macro_attribute] pub fn versioned(args: TokenStream, input: TokenStream) -> TokenStream { let _ = parse_macro_input!(args as Nothing); let input = parse_macro_input!(input as inter...
code_fim
medium
{ "lang": "rust", "repo": "cyphersnake/obake", "path": "/obake_macros/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>use syn::parse::Nothing; use syn::parse_macro_input; mod expand; mod internal; mod parse; #[proc_macro_attribute] pub fn versioned(args: TokenStream, input: TokenStream) -> TokenStream { let _ = parse_macro_input!(args as Nothing); let input = parse_macro_input!(input as internal::VersionedItem)...
code_fim
medium
{ "lang": "rust", "repo": "cyphersnake/obake", "path": "/obake_macros/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cyphersnake/obake path: /obake_macros/src/lib.rs #![deny(clippy::all, clippy::pedantic)] #![allow(clippy::wildcard_imports)] <|fim_suffix|>use syn::parse::Nothing; use syn::parse_macro_input; mod expand; mod internal; mod parse; #[proc_macro_attribute] pub fn versioned(args: TokenStream, inpu...
code_fim
medium
{ "lang": "rust", "repo": "cyphersnake/obake", "path": "/obake_macros/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DanHatesNumbers/rusty-rocket path: /src/people/repository/mod.rs use diesel; use diesel::prelude::*; use super::super::schema::people; use super::super::people::{Person, InsertablePerson}; pub fn all(connection: &PgConnection) -> QueryResult<Vec<Person>> { people::table.load::<Person>(&*co...
code_fim
hard
{ "lang": "rust", "repo": "DanHatesNumbers/rusty-rocket", "path": "/src/people/repository/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn delete(id: i32, connection: &PgConnection) -> QueryResult<usize> { diesel::delete(people::table.find(id)) .execute(connection) }<|fim_prefix|>// repo: DanHatesNumbers/rusty-rocket path: /src/people/repository/mod.rs use diesel; use diesel::prelude::*; use super::super::schema::people; ...
code_fim
medium
{ "lang": "rust", "repo": "DanHatesNumbers/rusty-rocket", "path": "/src/people/repository/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ruimaciel/mrslac path: /src/matrix/sparse_crs.rs use matrix::BasicReadableMatrix; use matrix::BasicWriteableMatrix; use matrix::SparseMatrix; pub struct SparseCRS { val: Vec<f32>, col_ind: Vec<usize>, row_ptr: Vec<usize>, columns: usize } impl SparseCRS { /// creates a new matrix p...
code_fim
hard
{ "lang": "rust", "repo": "ruimaciel/mrslac", "path": "/src/matrix/sparse_crs.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if i >= self.get_rows() || j >= self.get_columns() { panic!("access out of bounds"); } for idx in self.row_ptr[i]..self.row_ptr[i+1]{ if self.col_ind[idx] == j { return self.val[idx] } } // this bit is only reached if no el...
code_fim
hard
{ "lang": "rust", "repo": "ruimaciel/mrslac", "path": "/src/matrix/sparse_crs.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // this bit is only reached if no element was found return 0.0 } } impl BasicWriteableMatrix for SparseCRS { /// sets the (i,j)-th element of the sparse matrix fn set_element(&mut self, i: usize, j: usize, new_value: f32) { if i >= self.get_rows() || j >= self.get_columns() { panic...
code_fim
hard
{ "lang": "rust", "repo": "ruimaciel/mrslac", "path": "/src/matrix/sparse_crs.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let bindings = builder // The input header we would like to generate // bindings for. .header("wrapper.h") // Tell cargo to invalidate the built crate whenever any of the // included header files changed. .parse_callbacks(Box::new(CargoCallbacks)) ...
code_fim
hard
{ "lang": "rust", "repo": "ThijsRay/ros2_rust", "path": "/rcl_sys/build.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ThijsRay/ros2_rust path: /rcl_sys/build.rs extern crate bindgen; use bindgen::*; use std::env; use std::path::PathBuf; fn main() { let mut builder = Builder::default(); // Add all possible ROS locations to the library search and link paths. let ros_location_key = "AMENT_PREFIX_PAT...
code_fim
hard
{ "lang": "rust", "repo": "ThijsRay/ros2_rust", "path": "/rcl_sys/build.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ikedaosushi/sandbox path: /rust/osucc/src/main.rs use std::env; fn main() { let mut args = env::args(); if args.len() != 2 <|fim_suffix|>nt!(" mov rax, {}\n", args.nth(1).unwrap()); print!(" ret\n"); return; }<|fim_middle|>{ eprint!("Usage: 9cc <code>\n"); retu...
code_fim
medium
{ "lang": "rust", "repo": "ikedaosushi/sandbox", "path": "/rust/osucc/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>nt!(" mov rax, {}\n", args.nth(1).unwrap()); print!(" ret\n"); return; }<|fim_prefix|>// repo: ikedaosushi/sandbox path: /rust/osucc/src/main.rs use std::env; fn main() { let mut args = env::args(); if args.len() != 2 { eprint!("Usage: 9cc <code>\n"); return; } ...
code_fim
medium
{ "lang": "rust", "repo": "ikedaosushi/sandbox", "path": "/rust/osucc/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }