text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: ju6ge/atsame70q21 path: /src/acc.rs #[doc = r"Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - Control Register"] pub acc_cr: ACC_CR, #[doc = "0x04 - Mode Register"] pub acc_mr: ACC_MR, _reserved2: [u8; 28usize], #[doc = "0x24 - Interrupt Enable Regi...
code_fim
hard
{ "lang": "rust", "repo": "ju6ge/atsame70q21", "path": "/src/acc.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>r::W) writer structure"] impl crate::Writable for ACC_IDR {} #[doc = "Interrupt Disable Register"] pub mod acc_idr; #[doc = "Interrupt Mask Register\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about avaliabl...
code_fim
hard
{ "lang": "rust", "repo": "ju6ge/atsame70q21", "path": "/src/acc.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>; #[doc = "`read()` method returns [acc_acr::R](acc_acr::R) reader structure"] impl crate::Readable for ACC_ACR {} #[doc = "`write(|w| ..)` method takes [acc_acr::W](acc_acr::W) writer structure"] impl crate::Writable for ACC_ACR {} #[doc = "Analog Control Register"] pub mod acc_acr; #[doc = "Write Protec...
code_fim
hard
{ "lang": "rust", "repo": "ju6ge/atsame70q21", "path": "/src/acc.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: regonn/AOJ path: /ITP1/6/C.rs use std::io::*; use std::str::FromStr; fn read<T: FromStr>() -> T { let stdin = stdin(); let stdin = stdin.lock(); let token: String = stdin .bytes() .map(|c| c.expect("failed to read char") as char) .skip_while(|c| c.is_whitespa...
code_fim
hard
{ "lang": "rust", "repo": "regonn/AOJ", "path": "/ITP1/6/C.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut building_index: u8 = 0; for building in residences.iter() { for floor in building.iter() { for room in floor.iter() { print!(" {}", room); } println!(); } building_index += 1; if building_index != 4 { ...
code_fim
hard
{ "lang": "rust", "repo": "regonn/AOJ", "path": "/ITP1/6/C.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("TestType: {:?}", test_type); }<|fim_prefix|>// repo: johncf/rust-vala-gtk path: /ctrl/lib.rs #[repr(C)] #[derive(Debug)] pub struct TestType { int1: i32, int2: u8, } <|fim_middle|>#[no_mangle] pub extern fn test(slice: &[u32], test_type: &TestType) { for element in slice { ...
code_fim
medium
{ "lang": "rust", "repo": "johncf/rust-vala-gtk", "path": "/ctrl/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: johncf/rust-vala-gtk path: /ctrl/lib.rs #[repr(C)] #[derive(Debug)] pub struct TestType { int1: i32, int2: u8, } <|fim_suffix|> println!("TestType: {:?}", test_type); }<|fim_middle|>#[no_mangle] pub extern fn test(slice: &[u32], test_type: &TestType) { for element in slice { ...
code_fim
medium
{ "lang": "rust", "repo": "johncf/rust-vala-gtk", "path": "/ctrl/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Print card metadata. fn print_meta(&mut self) -> Result<(), Error> { // Print header. self.print_header(format_args!("meta"))?; // Write the metadata. let meta = self.scheduler.current_metacard(); writeln!(self.stdout, "id: {}", meta.id)?; ...
code_fim
hard
{ "lang": "rust", "repo": "ticki/mu", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Print history of the card. fn print_history(&mut self) -> Result<(), Error> { // Print header. self.print_header(format_args!("history"))?; // Print all the reviews. for (n, review) in self.scheduler.current_metacard().history.iter().enumerate() { wr...
code_fim
hard
{ "lang": "rust", "repo": "ticki/mu", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ticki/mu path: /src/main.rs termion; extern crate mu_backend as backend; extern crate clap; extern crate failure; extern crate chrono; extern crate itertools; // TODO: Add help page for formatting of .mu files. use std::io::{self, Read, Write}; use std::{path, fs, fmt, env, process}; use fai...
code_fim
hard
{ "lang": "rust", "repo": "ticki/mu", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>mod real_shutdown; use real_shutdown::RealShutdown; mod agent_connection; mod jsonrpc_handler; mod secrets; mod tg_manager; struct Delegate; impl Handler<clacks_rpc::client::Unhandled> for Delegate { type Result = (); fn handle(&mut self, unhandled: clacks_rpc::client::Unhandled, _: &mut Self...
code_fim
hard
{ "lang": "rust", "repo": "habnabit/clacks", "path": "/clacks_agentd/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: habnabit/clacks path: /clacks_agentd/src/main.rs #![warn(unused_extern_crates)] #![feature(proc_macro, proc_macro_non_items, generators)] #[macro_use] extern crate delegate; #[macro_use] extern crate failure; #[macro_use] extern crate jsonrpc_macros; #[macro_use] extern crate serde_derive; #[ma...
code_fim
hard
{ "lang": "rust", "repo": "habnabit/clacks", "path": "/clacks_agentd/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let entry = secrets::Entry::new(secrets::AppKey); entry.get() .and_then(|opt| { opt.map(Ok) .unwrap_or_else(|| { let value = secrets::AppKeyV1 { api_id: 0, api_hash: "".to_string(), ...
code_fim
hard
{ "lang": "rust", "repo": "habnabit/clacks", "path": "/clacks_agentd/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: maxtnuk/create-rust-app path: /src/plugins/container.rs use crate::fs; use crate::logger::file_msg; use crate::plugins::InstallConfig; use crate::plugins::Plugin; use anyhow::Result; use rust_embed::RustEmbed; pub struct Container {} <|fim_suffix|>## Building a container `docker build -t image...
code_fim
hard
{ "lang": "rust", "repo": "maxtnuk/create-rust-app", "path": "/src/plugins/container.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for filename in Asset::iter() { let file_contents = Asset::get(filename.as_ref()).unwrap(); let mut file_path = std::path::PathBuf::from(&install_config.project_dir); file_path.push(filename.as_ref()); let mut directory_path = std::path::PathBuf::fro...
code_fim
medium
{ "lang": "rust", "repo": "maxtnuk/create-rust-app", "path": "/src/plugins/container.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>## Running the container `docker run -e SECRET_KEY=123 -e DATABASE_URL=postgres://postgres:postgres@localhost/database -p 8080:8080 image-name` "##, )?; Ok(()) } }<|fim_prefix|>// repo: maxtnuk/create-rust-app path: /src/plugins/container.rs use crate::fs; use crate::logger::file_ms...
code_fim
hard
{ "lang": "rust", "repo": "maxtnuk/create-rust-app", "path": "/src/plugins/container.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tinmarino/libnotcurses-sys path: /src/file.rs //! Wrapper for `libc::FILE`, both as used by notcurses and the libc crate //! //! The interface is largely based on the implementation of the //! [cfile-rs crate](https://github.com/jkarns275/cfile) by Joshua Karns use core::ptr::{null_mut, NonNull...
code_fim
hard
{ "lang": "rust", "repo": "tinmarino/libnotcurses-sys", "path": "/src/file.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> unsafe { let result = fread( buf.as_ptr() as *mut c_void, 1, buf.len(), self.as_libc_ptr(), ); if result == buf.len() { Ok(()) } else { // Check if we hit...
code_fim
hard
{ "lang": "rust", "repo": "tinmarino/libnotcurses-sys", "path": "/src/file.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn is_pushpulldrive(&self) -> bool { *self == MODE3R::PUSHPULLDRIVE } #[doc = "Checks if the value of the field is `WIREDOR`"] #[inline] pub fn is_wiredor(&self) -> bool { *self == MODE3R::WIREDOR } #[doc = "Checks if the value of the field is `WIREDORPULLDOWN`...
code_fim
hard
{ "lang": "rust", "repo": "maximeborges/svd2rust_efm32gg990", "path": "/src/gpio/pd_model.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: maximeborges/svd2rust_efm32gg990 path: /src/gpio/pd_model.rs OWN } #[doc = "Checks if the value of the field is `WIREDAND`"] #[inline] pub fn is_wiredand(&self) -> bool { *self == MODE3R::WIREDAND } #[doc = "Checks if the value of the field is `WIREDANDFILTER`"] ...
code_fim
hard
{ "lang": "rust", "repo": "maximeborges/svd2rust_efm32gg990", "path": "/src/gpio/pd_model.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>s pull direction"] INPUTPULL, #[doc = "Input enabled with filter. DOUT determines pull direction"] INPUTPULLFILTER, #[doc = "Push-pull output"] PUSHPULL, #[doc = "Push-pull output with drive-strength set by DRIVEMODE"] PUSHPULLDRIVE, #[doc = "Wired-or output"] WIREDOR, ...
code_fim
hard
{ "lang": "rust", "repo": "maximeborges/svd2rust_efm32gg990", "path": "/src/gpio/pd_model.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let s = "hi"; dump!(s); } }<|fim_prefix|>// repo: naartjie/rust-belt path: /src/lib.rs #[macro_use] mod dev { #[macro_export] macro_rules! dump { ($ex: expr) => ( println!("{} => {:?}", stringify!($ex), $ex); ) } <|fim_middle|>} #[cfg(test)]...
code_fim
medium
{ "lang": "rust", "repo": "naartjie/rust-belt", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: naartjie/rust-belt path: /src/lib.rs #[macro_use] mod dev { #[macro_export] macro_rules! dump { ($ex: expr) => ( println!("{} => {:?}", stringify!($ex), $ex); ) } <|fim_suffix|> let s = "hi"; dump!(s); } }<|fim_middle|>} #[cfg(test)]...
code_fim
medium
{ "lang": "rust", "repo": "naartjie/rust-belt", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: adri326/galaxies.rs path: /src/main.rs mid = gen::null(N_ELEMS); let mut jerk_far = gen::null(N_ELEMS); position.array.push((0.0, 0.0, 0.0)); mass.array.push(BLACK_HOLE_MASS); speed.array.push((0.0, 0.0, 0.0)); accel_close.array.push((0.0, 0.0, 0.0)); accel_mid.array.pus...
code_fim
hard
{ "lang": "rust", "repo": "adri326/galaxies.rs", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: adri326/galaxies.rs path: /src/main.rs E: Prec = 0.3; // const NORM_MULT: Prec = 0.001; const WIDTH: usize = 1920; const HEIGHT: usize = 1080; const SCALE: Prec = 6000.0; const MIN_X: Prec = -SCALE * WIDTH as Prec / HEIGHT as Prec; const MAX_X: Prec = SCALE * WIDTH as Prec / HEIGHT as Prec; con...
code_fim
hard
{ "lang": "rust", "repo": "adri326/galaxies.rs", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> res = add(res, mul(speed_diff, 1.0 / distance_cubed)); let speed_pos = prod(speed_diff, pos_diff); res = add(res, normalize_difference(my_position, voxel.center_of_mass, 3.0 * speed_pos / distance_...
code_fim
hard
{ "lang": "rust", "repo": "adri326/galaxies.rs", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: facebookresearch/Private-ID path: /crypto/src/lib.rs // Copyright (c) Facebook, Inc. and its affiliates. // SPDX-License-Identifier: Apache-2.0 <|fim_suffix|>pub mod cupcake; pub mod eccipher; pub mod gcd; #[cfg(not(target_arch = "wasm32"))] pub mod paillier; pub mod prelude; pub mod prime; p...
code_fim
easy
{ "lang": "rust", "repo": "facebookresearch/Private-ID", "path": "/crypto/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub mod cupcake; pub mod eccipher; pub mod gcd; #[cfg(not(target_arch = "wasm32"))] pub mod paillier; pub mod prelude; pub mod prime; pub mod spoint;<|fim_prefix|>// repo: facebookresearch/Private-ID path: /crypto/src/lib.rs // Copyright (c) Facebook, Inc. and its affiliates. // SPDX-License-Identifier...
code_fim
easy
{ "lang": "rust", "repo": "facebookresearch/Private-ID", "path": "/crypto/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn entries(&mut self) -> LinkedHashMapEntries<ProposalShortId, TxEntry> { self.inner.entries() } // fill proposal txs pub fn fill_proposals( &self, limit: usize, exclusion: &HashSet<ProposalShortId>, proposals: &mut HashSet<ProposalShortId>, ...
code_fim
hard
{ "lang": "rust", "repo": "obsidiansystems/ckb", "path": "/tx-pool/src/component/pending.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: obsidiansystems/ckb path: /tx-pool/src/component/pending.rs use crate::component::entry::TxEntry; use ckb_types::{ core::{ cell::{CellChecker, CellMetaBuilder, CellProvider, CellStatus}, TransactionView, }, packed::{OutPoint, ProposalShortId}, prelude::*, }; use c...
code_fim
hard
{ "lang": "rust", "repo": "obsidiansystems/ckb", "path": "/tx-pool/src/component/pending.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>anic!("typechecking should handle this")}; let init_statement = seq(formals .iter() .map(|(name, _, order)| { Move!( MEM(Box::new(plus!( fields_level.access_to_exp(memory_address.clone(), fi...
code_fim
hard
{ "lang": "rust", "repo": "ivoelbert/HECTOR", "path": "/src/tree/translate/recordexp.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ivoelbert/HECTOR path: /src/tree/translate/recordexp.rs use crate::ast::*; use crate::tree::*; pub use std::sync::Arc; use crate::typecheck::TigerType; pub fn trans_exp( AST {node, typ, ..}: &AST, level: Level, value_env: &ValueEnviroment, breaks_stack: &[Option<Label>], fr...
code_fim
hard
{ "lang": "rust", "repo": "ivoelbert/HECTOR", "path": "/src/tree/translate/recordexp.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>// @p procedure print_mode(@!m:integer); {prints the mode represented by |m|} /// prints the mode represented by `m` #[allow(unused_variables)] pub(crate) fn print_mode(globals: &mut TeXGlobals, m: integer) { // begin if m>0 then if m > 0 { // case m div (max_command+1) of match m ...
code_fim
hard
{ "lang": "rust", "repo": "harpsword/tex-rs", "path": "/src/tex_the_program/section_0211.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: harpsword/tex-rs path: /src/tex_the_program/section_0211.rs //! @* \[16] The semantic nest. //! \TeX\ is typically in the midst of building many lists at once. For example, //! when a math formula is being processed, \TeX\ is in math mode and //! working on an mlist; this formula has temporarily...
code_fim
hard
{ "lang": "rust", "repo": "harpsword/tex-rs", "path": "/src/tex_the_program/section_0211.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: JoelAtDeluxe/AdventOfCode2015-rust path: /day20/src/main.rs use day20; fn main() { // let deliveries = simulate_gift_delivery(51); // day20::print_house_deliveries(&deliveries, 10); // println!("----------------"); // let deliveries = simulate_gift_delivery_part_2(51); // da...
code_fim
medium
{ "lang": "rust", "repo": "JoelAtDeluxe/AdventOfCode2015-rust", "path": "/day20/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> simulate_gift_delivery_gp(num_houses, |_, _| false) } fn simulate_gift_delivery_part_2(num_houses: usize) -> Vec<u32> { simulate_gift_delivery_gp(num_houses, |elf, house| { house >= 50 * elf }) }<|fim_prefix|>// repo: JoelAtDeluxe/AdventOfCode2015-rust path: /day20/src/main.rs use da...
code_fim
hard
{ "lang": "rust", "repo": "JoelAtDeluxe/AdventOfCode2015-rust", "path": "/day20/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: urbandove/rust-analyzer path: /crates/ra_assists/src/handlers/remove_dbg.rs use ra_syntax::{ ast::{self, AstNode}, TextSize, T, }; use crate::{AssistContext, AssistId, AssistKind, Assists}; // Assist: remove_dbg // // Removes `dbg!()` macro call. // // ``` // fn main() { // <|>dbg!...
code_fim
hard
{ "lang": "rust", "repo": "urbandove/rust-analyzer", "path": "/crates/ra_assists/src/handlers/remove_dbg.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> check_assist( remove_dbg, " fn foo(n: usize) { if let Some(_) = dbg!(n.<|>checked_sub(4)) { // ... } } ", " fn foo(n: usize) { if let Some(_) = n.checked_sub(4) { // ... } } ", ); } #[test] fn test_remove_dbg_w...
code_fim
hard
{ "lang": "rust", "repo": "urbandove/rust-analyzer", "path": "/crates/ra_assists/src/handlers/remove_dbg.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_remove_dbg() { check_assist(remove_dbg, "<|>dbg!(1 + 1)", "1 + 1"); check_assist(remove_dbg, "dbg!<|>((1 + 1))", "(1 + 1)"); check_assist(remove_dbg, "dbg!(1 <|>+ 1)", "1 + 1"); check_assist(remove_dbg, "let _ = <|>dbg!(1 + 1)", "let _ = 1 + 1"); ...
code_fim
hard
{ "lang": "rust", "repo": "urbandove/rust-analyzer", "path": "/crates/ra_assists/src/handlers/remove_dbg.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: samschlinkertcnn/slack-rs-api path: /src/mod_types/usergroups/mod.rs son => write!(f, "Server returned error invalid_json"), DisableError::InvalidPostType => write!(f, "Server returned error invalid_post_type"), DisableError::JsonNotObject => write!(f, "Server returned er...
code_fim
hard
{ "lang": "rust", "repo": "samschlinkertcnn/slack-rs-api", "path": "/src/mod_types/usergroups/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: samschlinkertcnn/slack-rs-api path: /src/mod_types/usergroups/mod.rs self.ok { Ok(self) } else { Err(self.error.as_ref().map(String::as_ref).unwrap_or("").into()) } } } #[derive(Debug)] pub enum CreateError<E: Error> { AccountInactive, FatalEr...
code_fim
hard
{ "lang": "rust", "repo": "samschlinkertcnn/slack-rs-api", "path": "/src/mod_types/usergroups/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl<E: Error> fmt::Display for EnableError<E> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { EnableError::AccountInactive => write!(f, "Server returned error account_inactive"), EnableError::FatalError => write!(f, "Server returned error fat...
code_fim
hard
{ "lang": "rust", "repo": "samschlinkertcnn/slack-rs-api", "path": "/src/mod_types/usergroups/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Gibbs::standard(fa) }); let mut eval = SARSA { q_func: q_func.clone(), policy: policy.clone(), gamma: 1.0, }; let critic = { let q = q_func.clone(); let p = policy.clone(); move |t: &Transition<_, _>| { let qs = q.evalua...
code_fim
hard
{ "lang": "rust", "repo": "tspooner/rsrl", "path": "/rsrl/examples/a2c.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tspooner/rsrl path: /rsrl/examples/a2c.rs #[macro_use] extern crate rsrl; use rand::thread_rng; use rsrl::{ control::{ac::ActorCritic, td::SARSA}, domains::{Domain, MountainCar, Transition}, fa::linear::{ basis::{Combinators, Fourier}, optim::SGD, LFA, },...
code_fim
medium
{ "lang": "rust", "repo": "tspooner/rsrl", "path": "/rsrl/examples/a2c.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut eval = SARSA { q_func: q_func.clone(), policy: policy.clone(), gamma: 1.0, }; let critic = { let q = q_func.clone(); let p = policy.clone(); move |t: &Transition<_, _>| { let qs = q.evaluate((t.from.state(),)); le...
code_fim
medium
{ "lang": "rust", "repo": "tspooner/rsrl", "path": "/rsrl/examples/a2c.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ehooper/aoc2017 path: /3_spiral-memory/src/main.rs use std::io; /* S2 .. S2 S1 * S3 . * . . * . S1 * S3 S4 .. S4 */ fn spiral_to_cart(i : i32) -> (i32, i32) { if i == 1 { return (0, 0); } let ring : i32 = (f64::from(i).sqrt().ceil() as i32) / 2; ...
code_fim
hard
{ "lang": "rust", "repo": "ehooper/aoc2017", "path": "/3_spiral-memory/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> print!("> "); io::stdout().flush().unwrap(); } fn main() { let arg = std::env::args().nth(1); let part2 = arg.map_or(false, |s| s == "--part2"); let mut input = String::new(); prompt(); while let Ok(_) = io::stdin().read_line(&mut input) { let num : i32 = input.trim_r...
code_fim
hard
{ "lang": "rust", "repo": "ehooper/aoc2017", "path": "/3_spiral-memory/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dtolnay/serde-yaml path: /tests/test_serde.rs #![allow( clippy::decimal_literal_representation, clippy::derive_partial_eq_without_eq, clippy::unreadable_literal, clippy::shadow_unrelated )] use indoc::indoc; use serde::ser::SerializeMap; use serde_derive::{Deserialize, Serialize...
code_fim
hard
{ "lang": "rust", "repo": "dtolnay/serde-yaml", "path": "/tests/test_serde.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let thing = i64::MIN; let yaml = indoc! {" -9223372036854775808 "}; test_serde(&thing, yaml); } #[test] fn test_int_max_i64() { let thing = i64::MAX; let yaml = indoc! {" 9223372036854775807 "}; test_serde(&thing, yaml); } #[test] fn test_i128_small() { ...
code_fim
hard
{ "lang": "rust", "repo": "dtolnay/serde-yaml", "path": "/tests/test_serde.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn test_vec() { let thing = vec![1, 2, 3]; let yaml = indoc! {" - 1 - 2 - 3 "}; test_serde(&thing, yaml); } #[test] fn test_map() { let mut thing = BTreeMap::new(); thing.insert("x".to_owned(), 1); thing.insert("y".to_owned(), 2); let yaml =...
code_fim
hard
{ "lang": "rust", "repo": "dtolnay/serde-yaml", "path": "/tests/test_serde.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> client.query(&statment, &[&title]) .await .expect("Error creando el Todo") .iter() .map(|row| TodoList::from_row_ref(row).unwrap()) .collect::<Vec<TodoList>>() .pop() .ok_or(io::Error::new(io::ErrorKind::Other, "Error creando el Todo")) } pub async fn check_ite...
code_fim
hard
{ "lang": "rust", "repo": "mAaD0107/TODO-APP-BACKEND", "path": "/src/dao.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mAaD0107/TODO-APP-BACKEND path: /src/dao.rs use crate::model::{TodoList, TodoItem}; use deadpool_postgres::Client; use tokio_pg_mapper::FromTokioPostgresRow; use std::io; pub async fn get_todos(client: &Client) -> Result<Vec<TodoList>, io::Error>{ let statment = client.prepare("...
code_fim
medium
{ "lang": "rust", "repo": "mAaD0107/TODO-APP-BACKEND", "path": "/src/dao.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub async fn check_item(client: &Client, list_id: i32, item_id: i32) -> Result<(), io::Error>{ let statment = client.prepare("update todo_item set checked = (CASE WHEN checked = false THEN true ELSE false END) where list_id = $1 and id = $2").await.unwrap(); ...
code_fim
hard
{ "lang": "rust", "repo": "mAaD0107/TODO-APP-BACKEND", "path": "/src/dao.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { () } #[cfg(test)] mod tests { use super::*; #[test] fn test_search() { assert_eq!(Solution::search(vec![4, 5, 6, 7, 0, 1, 2], 0), 4); assert_eq!(Solution::search(vec![4, 5, 6, 7, 0, 1, 2], 3), -1); assert_eq!(Solution::search(vec![4, 5, 6, 7, 0, 1, 2],...
code_fim
hard
{ "lang": "rust", "repo": "magurotuna/leetcode-rust", "path": "/src/bin/33.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: magurotuna/leetcode-rust path: /src/bin/33.rs struct Solution; impl Solution { pub fn search(nums: Vec<i32>, target: i32) -> i32 { if nums.is_empty() { return -1; } let first = nums[0]; let last = nums[nums.len() - 1]; let idx = if first...
code_fim
hard
{ "lang": "rust", "repo": "magurotuna/leetcode-rust", "path": "/src/bin/33.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_search() { assert_eq!(Solution::search(vec![4, 5, 6, 7, 0, 1, 2], 0), 4); assert_eq!(Solution::search(vec![4, 5, 6, 7, 0, 1, 2], 3), -1); assert_eq!(Solution::search(vec![4, 5, 6, 7, 0, 1, 2], 5), 1); assert_eq!(Solution::search(vec![], 5), -1); ...
code_fim
hard
{ "lang": "rust", "repo": "magurotuna/leetcode-rust", "path": "/src/bin/33.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn debug_tol() { let a = MyUnitType {}; let b = MyUnitType {}; assert_eq!(a.debug_abs_tol(&b, &MyUnitType {}), MyUnitType {}); assert_eq!(a.debug_rel_tol(&b, &MyUnitType {}), MyUnitType {}); assert_eq!(a.debug_ulps_tol(&b, &MyUnitTypeUlps {}), MyUnitTypeUlps {}); } fn main() { de...
code_fim
medium
{ "lang": "rust", "repo": "jtempest/float_eq-rs", "path": "/float_eq/tests/derive_tests/assert_float_eq/assert_float_eq_unit.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jtempest/float_eq-rs path: /float_eq/tests/derive_tests/assert_float_eq/assert_float_eq_unit.rs use float_eq::{AssertFloatEq, FloatEq, FloatEqDebugUlpsDiff, FloatEqUlpsTol}; #[derive( Debug, Clone, Copy, PartialEq, FloatEqUlpsTol, FloatEq, FloatEqDebugUlpsDiff, AssertFloatEq, )] #[float_eq(...
code_fim
hard
{ "lang": "rust", "repo": "jtempest/float_eq-rs", "path": "/float_eq/tests/derive_tests/assert_float_eq/assert_float_eq_unit.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(a.debug_abs_tol(&b, &MyUnitType {}), MyUnitType {}); assert_eq!(a.debug_rel_tol(&b, &MyUnitType {}), MyUnitType {}); assert_eq!(a.debug_ulps_tol(&b, &MyUnitTypeUlps {}), MyUnitTypeUlps {}); } fn main() { debug_diff(); debug_tol(); }<|fim_prefix|>// repo: jtempest/float_eq-r...
code_fim
medium
{ "lang": "rust", "repo": "jtempest/float_eq-rs", "path": "/float_eq/tests/derive_tests/assert_float_eq/assert_float_eq_unit.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let socket = (**ZMQ_CONTEXT).as_mut() .socket(zmq::PUSH) .expect("Failure to create the ZMQ push socket"); socket.set_linger(1000) .expect("Failure to set the ZMQ push socket to not linger"); socket.set_tcp_keepalive(0) ...
code_fim
hard
{ "lang": "rust", "repo": "habitat-sh/habitat", "path": "/components/butterfly/src/server/push.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: habitat-sh/habitat path: /components/butterfly/src/server/push.rs //! The push thread. //! //! This is the thread for distributing rumors to members. It distributes to `FANOUT` members, no //! more often than `Timing::GOSSIP_PERIOD_DEFAULT_MS`. use crate::{member::{Member, ...
code_fim
hard
{ "lang": "rust", "repo": "habitat-sh/habitat", "path": "/components/butterfly/src/server/push.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ivanceras/sauron path: /examples/data-viewer/src/assets.rs use sauron::{html::units::*, svg::attributes::*, svg::*, Node}; #[allow(unused)] pub fn svg_table_icon<MSG>() -> Node<MSG> where MSG: Clone, { svg([ xmlns("http://www.w3.org/2000/svg"), width(20), height(20), view_box([0, 0, 24, ...
code_fim
hard
{ "lang": "rust", "repo": "ivanceras/sauron", "path": "/examples/data-viewer/src/assets.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[allow(unused)] pub fn close_button<MSG>(w: i32, h: i32, kolor: &'static str) -> Node<MSG> where MSG: Clone, { svg([version("1.1"), width(px(w)), height(px(h)), view_box([0, 0, 512, 512]), enable_background("new 0 0 512 512")], [path([d("M256,33C132.3,33,32,133.3,32,257c0,123.7,100.3,224,...
code_fim
hard
{ "lang": "rust", "repo": "ivanceras/sauron", "path": "/examples/data-viewer/src/assets.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests { #[test] fn example() { use super::{Solution, ListNode}; let sol = Solution::add_two_numbers( Some(Box::new(ListNode { val: 2, next: Some(Box::new(ListNode { val: 4, next: So...
code_fim
hard
{ "lang": "rust", "repo": "shamiao/leetcode-dec_2018_in_rust", "path": "/p2/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let append = Box::new(ListNode { val: count, next: None }); if let Some(x) = sol_last { x.next = Some(append); sol_last = x.next.as_mut(); } else { sol = Some(append); sol_last = Some(sol.as_mut().unwrap())...
code_fim
hard
{ "lang": "rust", "repo": "shamiao/leetcode-dec_2018_in_rust", "path": "/p2/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: shamiao/leetcode-dec_2018_in_rust path: /p2/src/lib.rs #![allow(dead_code)] struct Solution {} //Definition for singly-linked list. #[derive(PartialEq, Eq, Debug)] pub struct ListNode { pub val: i32, pub next: Option<Box<ListNode>>, } impl ListNode { #[inline] #[allow(dead_cod...
code_fim
hard
{ "lang": "rust", "repo": "shamiao/leetcode-dec_2018_in_rust", "path": "/p2/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug)] pub enum GameFromMainGameMap { }<|fim_prefix|>// repo: yeliknewo/ai-4x-rs path: /src/events/game_x_main_game_map.rs use specs::Entity; <|fim_middle|>#[derive(Debug)] pub enum GameToMainGameMap { Cleanup, SetEntityMap(Entity), }
code_fim
medium
{ "lang": "rust", "repo": "yeliknewo/ai-4x-rs", "path": "/src/events/game_x_main_game_map.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yeliknewo/ai-4x-rs path: /src/events/game_x_main_game_map.rs use specs::Entity; <|fim_suffix|>#[derive(Debug)] pub enum GameFromMainGameMap { }<|fim_middle|>#[derive(Debug)] pub enum GameToMainGameMap { Cleanup, SetEntityMap(Entity), }
code_fim
medium
{ "lang": "rust", "repo": "yeliknewo/ai-4x-rs", "path": "/src/events/game_x_main_game_map.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oscaroox/rune-lang path: /src/parser/list.rs use lexer::token_type::TokenType; use parser::parser::Parser; pub struct ListParser<'a> { parser: &'a mut Parser } impl <'a>ListParser<'a> { pub fn new(parser: &'a mut Parser) -> ListParser { ListParser { parser: parser ...
code_fim
hard
{ "lang": "rust", "repo": "oscaroox/rune-lang", "path": "/src/parser/list.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> while self.parser.next_char.id == TokenType::COMMA { self.parser.matches(TokenType::COMMA); self.element(); } } fn element(&mut self) { if self.parser.next_char.id == TokenType::NAME { self.parser.matches(TokenType::NAME); } els...
code_fim
medium
{ "lang": "rust", "repo": "oscaroox/rune-lang", "path": "/src/parser/list.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sampersand/qutie_rust path: /src/builtins/functions/types.rs use std::rc::Rc; use objects::universe::{Universe, AccessType}; use objects::number::Number; <|fim_suffix|>pub fn num_fn(args: Rc<Universe>, env: &mut Environment) -> ObjResult { let arg_pos = new_obj!(NUM, 0); let arg = get_arg...
code_fim
medium
{ "lang": "rust", "repo": "sampersand/qutie_rust", "path": "/src/builtins/functions/types.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn num_fn(args: Rc<Universe>, env: &mut Environment) -> ObjResult { let arg_pos = new_obj!(NUM, 0); let arg = get_arg!(args, arg_pos; Stack, panic!("No argument found")); match arg.qt_to_num(env){ // because implicit casting Ok(obj) => Ok(obj), Err(err) => Err(err) } } pub fn ...
code_fim
medium
{ "lang": "rust", "repo": "sampersand/qutie_rust", "path": "/src/builtins/functions/types.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: purpleposeidon/rust-x86asm path: /src/test/instruction_tests/instr_vpcompressd.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;...
code_fim
hard
{ "lang": "rust", "repo": "purpleposeidon/rust-x86asm", "path": "/src/test/instruction_tests/instr_vpcompressd.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> run_test(&Instruction { mnemonic: Mnemonic::VPCOMPRESSD, operand1: Some(Direct(YMM3)), operand2: Some(Direct(YMM4)), operand3: None, operand4: None, lock: false, rounding_mode: None, merge_mode: Some(MergeMode::Zero), sae: false, mask: Some(MaskReg::K6), broadcast: None }, &[98, 242, 125, 174, 139, 22...
code_fim
hard
{ "lang": "rust", "repo": "purpleposeidon/rust-x86asm", "path": "/src/test/instruction_tests/instr_vpcompressd.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn test_read_exit_server_counters() { use std::net::Ipv6Addr; use std::os::unix::process::ExitStatusExt; use std::process::ExitStatus; use std::process::Output; use KI; let mut counter = 0; KI.set_mock(Box::new(move |program, args| { counter += 1; mat...
code_fim
hard
{ "lang": "rust", "repo": "asoltys/althea_rs", "path": "/althea_kernel_interface/src/exit_server_counter.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: asoltys/althea_rs path: /althea_kernel_interface/src/exit_server_counter.rs use super::KernelInterface; use std::collections::HashMap; use std::net::IpAddr; use std::str::FromStr; use regex::Regex; use failure::Error; #[derive(Debug, Eq, PartialEq)] pub enum ExitFilterTarget { Input, ...
code_fim
hard
{ "lang": "rust", "repo": "asoltys/althea_rs", "path": "/althea_kernel_interface/src/exit_server_counter.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Vec3d { x: self.x * f, y: self.y * f, z: self.z * f, } } } impl std::ops::Div<f64> for Vec3d { type Output = Self; fn div(self, f: f64) -> Self::Output { Vec3d { x: self.x / f, y: self.y / f, z: sel...
code_fim
hard
{ "lang": "rust", "repo": "j2ghz/RayTracingInOneWeekend", "path": "/src/vec3d.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: j2ghz/RayTracingInOneWeekend path: /src/vec3d.rs use rand::{thread_rng, Rng}; use std::ops::{Add, Neg}; #[derive(Clone, Copy, Debug)] pub struct Vec3d { x: f64, y: f64, z: f64, } impl Vec3d { pub fn new(x: f64, y: f64, z: f64) -> Self { Vec3d { x, y, z } } pub f...
code_fim
hard
{ "lang": "rust", "repo": "j2ghz/RayTracingInOneWeekend", "path": "/src/vec3d.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.x -= rhs.x; self.y -= rhs.y; self.z -= rhs.z; } } impl std::ops::MulAssign for Vec3d { fn mul_assign(&mut self, rhs: Self) { self.x *= rhs.x; self.y *= rhs.y; self.z *= rhs.z; } } impl std::ops::DivAssign for Vec3d { fn div_assign(&mut s...
code_fim
hard
{ "lang": "rust", "repo": "j2ghz/RayTracingInOneWeekend", "path": "/src/vec3d.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl MessageReceiver { fn new(bus_recv: MessageBusReceiver) -> Self { Self { bus_recv, shutdown: false, } } #[inline] pub fn stream<F: FnMut(&MessageBusView)>(mut self, mut f: F) { if self.shutdown { return; } lo...
code_fim
hard
{ "lang": "rust", "repo": "tmzint/roundabout", "path": "/src/schedule.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tmzint/roundabout path: /src/schedule.rs use crate::handler::{MessageGroup, RuntimeContext}; use crate::message::bus::{MessageBus, MessageBusReceiver, MessageBusSender}; use crate::message::{MessageRegistry, MessageSender, ShutdownCommand, ShutdownRequestedEvent}; use crate::prelude::{MessageBus...
code_fim
hard
{ "lang": "rust", "repo": "tmzint/roundabout", "path": "/src/schedule.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub struct MessageReceiver { bus_recv: MessageBusReceiver, shutdown: bool, } impl MessageReceiver { fn new(bus_recv: MessageBusReceiver) -> Self { Self { bus_recv, shutdown: false, } } #[inline] pub fn stream<F: FnMut(&MessageBusView)>(mut ...
code_fim
hard
{ "lang": "rust", "repo": "tmzint/roundabout", "path": "/src/schedule.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dgrunwald/rust-cpython path: /src/objects/module.rs // Copyright (c) 2015 Daniel Grunwald // // Permission is hereby granted, free of charge, to any person obtaining a copy of this // software and associated documentation files (the "Software"), to deal in the Software // without restriction, in...
code_fim
hard
{ "lang": "rust", "repo": "dgrunwald/rust-cpython", "path": "/src/objects/module.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Gets the module filename. /// /// May fail if the module does not have a `__file__` attribute. #[allow(deprecated)] pub fn filename(&self, py: Python) -> PyResult<&str> { unsafe { self.str_from_ptr(py, ffi::PyModule_GetFilename(self.0.as_ptr())) } } /// Gets the mo...
code_fim
hard
{ "lang": "rust", "repo": "dgrunwald/rust-cpython", "path": "/src/objects/module.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn read_byte(&self, addr: u16) -> u8 { match self.mapper_impl.map_cpu_read(addr) { MapperAddr::PrgRom(offset) => self.prg_rom[offset as usize], MapperAddr::PrgRam(offset) => self.prg_ram[offset as usize], MapperAddr::InternalReg(value) => value, ...
code_fim
hard
{ "lang": "rust", "repo": "decden/rnes", "path": "/rnes-core/src/cartridge.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: decden/rnes path: /rnes-core/src/cartridge.rs use crate::log; use mapper::{Mapper, Mapper000, Mapper001, MapperAddr, MapperPpuAddr}; use std::fs::File; use std::io::Read; use std::str; #[derive(Debug)] pub enum NametableMirroring { Horizontal, Vertical, } pub struct Cartridge { pr...
code_fim
hard
{ "lang": "rust", "repo": "decden/rnes", "path": "/rnes-core/src/cartridge.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mapper: Box<dyn Mapper> = match mapper { 0 => Box::new(Mapper000::new( nametable_mirroring, prg_rom_banks, chr_rom_banks, )), 1 => Box::new(Mapper001::new(nametable_mirroring, prg_rom_banks)), _ => ...
code_fim
hard
{ "lang": "rust", "repo": "decden/rnes", "path": "/rnes-core/src/cartridge.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Loop(ref body) => { let begin_label = self.asm.new_dynamic_label(); let end_label = self.asm.new_dynamic_label(); self.interpreter.enter_loop(body); dynasm!(self.asm ; jmp =>end_label ; ...
code_fim
hard
{ "lang": "rust", "repo": "OpenByteDev/bf-rs", "path": "/src/jit/compiler.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: OpenByteDev/bf-rs path: /src/jit/compiler.rs use dynasmrt::x64::Assembler; use dynasmrt::{DynasmApi, DynasmLabelApi}; use super::*; use super::analysis::{BoundsAnalysis, AbstractInterpreter, NoAnalysis}; use common::Count; use peephole; use rts; /// Program forms that can be JIT compiled. pub ...
code_fim
hard
{ "lang": "rust", "repo": "OpenByteDev/bf-rs", "path": "/src/jit/compiler.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// The log is printed to the user. /// The newest message is always at the top, /// older ones can be seen by scrolling down. pub fn view(&mut self, log: &Log) -> Element<Message> { let font_size = self.font_size; let scrollbar = Scrollable::new(&mut self.scrollbar_state) ...
code_fim
hard
{ "lang": "rust", "repo": "radrow/satisfaction", "path": "/tents/src/widgets/log_widget.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: radrow/satisfaction path: /tents/src/widgets/log_widget.rs use super::{Log, LogType}; use crate::game::Config; use crate::message::Message; use iced::{scrollable::State, Color, Element, Length, Scrollable, Text}; /// A widget that holds information about /// how text messages are sent to the us...
code_fim
hard
{ "lang": "rust", "repo": "radrow/satisfaction", "path": "/tents/src/widgets/log_widget.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[macro_export] macro_rules! fizz_buzz_custom { () => { fizz_buzz_custom_solver("Fizz", "Buzz", 3, 5) }; ($str_one:expr) => { fizz_buzz_custom_solver($str_one, "Buzz", 3, 5) }; ($str_one:expr, $str_two:expr) => { fizz_buzz_custom_solver($str_one, $str_two, 3, 5) }; ($str_one:expr, $str_two...
code_fim
hard
{ "lang": "rust", "repo": "mkt-Do/codewars", "path": "/rust/src/custom_fizzbuzz_array.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(fizz_buzz_custom!()[3], "4".to_string()); assert_eq!(fizz_buzz_custom!()[15], "16".to_string()); } }<|fim_prefix|>// repo: mkt-Do/codewars path: /rust/src/custom_fizzbuzz_array.rs #[allow(dead_code)] fn fizz_buzz_custom_solver(string_one: &str, string_two: &str, num_one: us...
code_fim
medium
{ "lang": "rust", "repo": "mkt-Do/codewars", "path": "/rust/src/custom_fizzbuzz_array.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mkt-Do/codewars path: /rust/src/custom_fizzbuzz_array.rs #[allow(dead_code)] fn fizz_buzz_custom_solver(string_one: &str, string_two: &str, num_one: usize, num_two: usize) -> Vec<String> { <|fim_suffix|>#[cfg(test)] mod tests { use super::*; #[test] fn test_basic() { assert_...
code_fim
hard
{ "lang": "rust", "repo": "mkt-Do/codewars", "path": "/rust/src/custom_fizzbuzz_array.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.rows.get_mut(index).unwrap() } } #[cfg(test)] mod tests { use crate as couch_rs; use crate::document::TypedCouchDocument; use couch_rs_derive::CouchDocument; use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, CouchDocument, Debug, Default)] str...
code_fim
hard
{ "lang": "rust", "repo": "sify21/couch-rs", "path": "/couch_rs/src/document.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sify21/couch-rs path: /couch_rs/src/document.rs use serde::de::DeserializeOwned; use serde::{Deserialize, Serialize}; use serde_json::Value; use std::borrow::Cow; use std::ops::{Index, IndexMut}; /// Trait to deal with typed CouchDB documents. pub trait TypedCouchDocument: DeserializeOwned + Se...
code_fim
hard
{ "lang": "rust", "repo": "sify21/couch-rs", "path": "/couch_rs/src/document.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub use arg::Arg; pub use author::Author; pub use environment::Env; pub use example::Example; pub use flag::Flag; pub use man::Manual; pub use option::Opt; pub use section::Section;<|fim_prefix|>// repo: rust-cli/man path: /src/lib.rs #![cfg_attr(feature = "nightly", deny(missing_docs))] #![cfg_attr(feat...
code_fim
medium
{ "lang": "rust", "repo": "rust-cli/man", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-cli/man path: /src/lib.rs #![cfg_attr(feature = "nightly", deny(missing_docs))] #![cfg_attr(feature = "nightly", feature(external_doc))] #![cfg_attr(feature = "nightly", doc(include = "../README.md"))] #![cfg_attr(test, deny(warnings))] <|fim_suffix|>pub mod prelude; pub use arg::Arg; pub...
code_fim
medium
{ "lang": "rust", "repo": "rust-cli/man", "path": "/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let g = Grid::from(grid); g.num_trees_from(3, 1) } fn solve_task2(grid: String) -> u64 { let g = Grid::from(grid); let mut slopes = Vec::new(); slopes.push(g.num_trees_from(1, 1)); slopes.push(g.num_trees_from(3, 1)); slopes.push(g.num_trees_from(5, 1)); slopes.push(g.num_...
code_fim
hard
{ "lang": "rust", "repo": "fapete/advent_of_code", "path": "/2020/day3/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fapete/advent_of_code path: /2020/day3/src/main.rs use day3::aoclib::*; fn main() { println!("Task 1: {}", solve_task1(read_file("input").unwrap())); println!("Task 2: {}", solve_task2(read_file("input").unwrap())); } struct Grid { // true: tree, false: empty grid: Vec<Vec<bool...
code_fim
hard
{ "lang": "rust", "repo": "fapete/advent_of_code", "path": "/2020/day3/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }