text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> board: B, maximizing: bool, original_player: P, max_depth: i32, alpha: f32, beta: f32, ) -> f32 { // defaults: max_depth=8, alpha=-inf, beta=inf // Base case – terminal position or maximum depth reached if board.is_win() || board.is_draw() || max_depth == 0 { re...
code_fim
hard
{ "lang": "rust", "repo": "davidssmith/classic", "path": "/src/minimax.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: davidssmith/classic path: /src/minimax.rs use crate::board::{Board, Move, Piece}; fn f32_max(a: f32, b: f32) -> f32 { if a < b { b } else { a } } fn f32_min(a: f32, b: f32) -> f32 { if a < b { a } else { b } } // Find the best possible ou...
code_fim
hard
{ "lang": "rust", "repo": "davidssmith/classic", "path": "/src/minimax.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Moran296/esparrag_meta_service path: /src/lib.rs use serde::{Deserialize, Serialize}; use serde_json::Value; use std::io; //used for testing #[allow(dead_code)] const SERVICE_1: &str = r#"{ "service_name": "service_1", "description": "a test service", "actions": [ { "action_name...
code_fim
hard
{ "lang": "rust", "repo": "Moran296/esparrag_meta_service", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests { use super::*; fn mock_service() -> ServiceMeta { ServiceMeta { service_name: "service_1".to_string(), description: "a test service".to_string(), actions: vec![Action { action_name: "action_1".to_string(), ...
code_fim
hard
{ "lang": "rust", "repo": "Moran296/esparrag_meta_service", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vtavernier/hyperion.rs path: /src/instance/muxer/muxed_message.rs use std::{convert::TryFrom, sync::Arc}; use super::InputMessageData; use crate::{image::RawImage, models::Color}; #[derive(Debug, Clone)] pub struct MuxedMessage { data: MuxedMessageData, } impl MuxedMessage { pub fn ne...
code_fim
hard
{ "lang": "rust", "repo": "vtavernier/hyperion.rs", "path": "/src/instance/muxer/muxed_message.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn color(&self) -> Option<Color> { match self { MuxedMessageData::SolidColor { color, .. } => Some(*color), _ => None, } } } impl TryFrom<InputMessageData> for MuxedMessageData { type Error = (); fn try_from(value: InputMessageData) -> Result<S...
code_fim
hard
{ "lang": "rust", "repo": "vtavernier/hyperion.rs", "path": "/src/instance/muxer/muxed_message.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl HumanPlayer for Player { fn act(&self, table: &Table) -> Command { let options = self.get_options(table); ui::get_player_action(options) } } #[derive(Debug, Clone, PartialEq)] pub enum Command { PostBlind, Fold, Check, Call, Raise(i32), Leave, } impl ...
code_fim
hard
{ "lang": "rust", "repo": "sbue/rust-poker", "path": "/src/game/player.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl fmt::Display for Command { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { &Command::PostBlind => write!(f, "Post Blind"), &Command::Raise(x) => write!(f, "Raise _ (max is {})", x), cmd => write!(f, "{}", format!("{:?}", cmd)), ...
code_fim
hard
{ "lang": "rust", "repo": "sbue/rust-poker", "path": "/src/game/player.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sbue/rust-poker path: /src/game/player.rs use super::card::Card; use super::table::Table; use ui; use std::rc::Rc; use std::fmt; const CHIPS_AT_START: i32 = 100; pub struct Player { pub name: String, pub is_human: bool, pub chips: i32, pub chips_in_play: i32, pub cards: Op...
code_fim
hard
{ "lang": "rust", "repo": "sbue/rust-poker", "path": "/src/game/player.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: artursapek/iced path: /web/src/widget/image.rs use crate::{style, Bus, Element, Length, Widget}; use dodrio::bumpalo; /// A frame that displays an image while keeping aspect ratio. /// /// # Example /// /// ``` /// # use iced_web::Image; /// /// let image = Image::new("resources/ferris.png"); ...
code_fim
hard
{ "lang": "rust", "repo": "artursapek/iced", "path": "/web/src/widget/image.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match self.width { Length::Shrink => {} Length::Fill | Length::FillPortion(_) => { image = image.attr("width", "100%"); } Length::Units(px) => { image = image.attr( "width", bump...
code_fim
hard
{ "lang": "rust", "repo": "artursapek/iced", "path": "/web/src/widget/image.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[no_mangle] pub extern "C" fn AddRef(ptr: *mut c_void) { println!("AddRef({:?})", ptr); } #[no_mangle] pub extern "C" fn Release(ptr: *mut c_void) { println!("Release({:?})", ptr); } extern "C" { fn do_something() -> c_int; } #[no_mangle] pub unsafe extern "C" fn Servo_DoSomething() -> c_...
code_fim
hard
{ "lang": "rust", "repo": "emilio/ubuntu-x86-fun", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: emilio/ubuntu-x86-fun path: /src/lib.rs use std::marker::PhantomData; use std::ffi::c_void; use std::os::raw::c_int; pub struct Foreign { address: u8, } #[repr(C)] pub struct GenericFoo<F> { ptr: *const F, _marker: PhantomData<F>, } <|fim_suffix|>extern "C" { fn do_something()...
code_fim
hard
{ "lang": "rust", "repo": "emilio/ubuntu-x86-fun", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: travistrue2008/tim2-rs path: /viewer/src/main.rs use anyhow::{bail, Error}; use iced::{window, Application, Settings}; use structopt::StructOpt; <|fim_suffix|>pub fn main() -> Result<(), Error> { let opts = cli::Opts::from_args(); if !opts.directory.is_dir() { bail!("<directory...
code_fim
medium
{ "lang": "rust", "repo": "travistrue2008/tim2-rs", "path": "/viewer/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> viewer::Viewer::run(Settings { flags: viewer::Flags { directory: opts.directory, }, window: window::Settings { size: (512, 512), ..Default::default() }, ..Default::default() }); Ok(()) }<|fim_prefix|>// repo: travistr...
code_fim
medium
{ "lang": "rust", "repo": "travistrue2008/tim2-rs", "path": "/viewer/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn main() -> Result<(), Error> { let opts = cli::Opts::from_args(); if !opts.directory.is_dir() { bail!("<directory> must be a valid directory"); } viewer::Viewer::run(Settings { flags: viewer::Flags { directory: opts.directory, }, window: ...
code_fim
medium
{ "lang": "rust", "repo": "travistrue2008/tim2-rs", "path": "/viewer/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> write!(f, "(id: {}, time: {})", self.id, self.time) } } impl Debug for Op { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { std::fmt::Display::fmt(self, f) } }<|fim_prefix|>// repo: tcrain/nw path: /src/log/op.rs use std::fmt::{Debug, Display, Formatter}; use std::{fmt}...
code_fim
hard
{ "lang": "rust", "repo": "tcrain/nw", "path": "/src/log/op.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tcrain/nw path: /src/log/op.rs use std::fmt::{Debug, Display, Formatter}; use std::{fmt}; use rand::{thread_rng, Rng}; use crate::verification::{Id, Time, Hash}; use crate::verification; const OP_LEN: usize = 5; pub type OpData = [u8; OP_LEN]; pub fn gen_rand_data() -> OpData { let mut rng...
code_fim
hard
{ "lang": "rust", "repo": "tcrain/nw", "path": "/src/log/op.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Display for Op { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { write!(f, "(id: {}, time: {})", self.id, self.time) } } impl Debug for Op { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { std::fmt::Display::fmt(self, f) } }<|fim_prefix|>// repo: tcrain/nw...
code_fim
hard
{ "lang": "rust", "repo": "tcrain/nw", "path": "/src/log/op.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nephele-rs/nephele path: /nephele/src/common/codec/lines_codec.rs use bytes::{Buf, BufMut, BytesMut}; use std::{cmp, fmt, io, str, usize}; use crate::common::codec::decoder::Decoder; use crate::common::codec::encoder::Encoder; #[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] pub s...
code_fim
hard
{ "lang": "rust", "repo": "nephele-rs/nephele", "path": "/nephele/src/common/codec/lines_codec.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl fmt::Display for LinesCodecError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { LinesCodecError::MaxLineLengthExceeded => write!(f, "max line length exceeded"), LinesCodecError::Io(e) => write!(f, "{}", e), } } } impl From<io...
code_fim
hard
{ "lang": "rust", "repo": "nephele-rs/nephele", "path": "/nephele/src/common/codec/lines_codec.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn utf8(buf: &[u8]) -> Result<&str, io::Error> { str::from_utf8(buf) .map_err(|_| io::Error::new(io::ErrorKind::InvalidData, "Unable to decode input as UTF8")) } fn without_carriage_return(s: &[u8]) -> &[u8] { if let Some(&b'\r') = s.last() { &s[..s.len() - 1] } else { ...
code_fim
hard
{ "lang": "rust", "repo": "nephele-rs/nephele", "path": "/nephele/src/common/codec/lines_codec.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug, Serialize)] struct Record<'a> { path: &'a Path, game_uuid: Uuid, map_name: Cow<'a, str>, reset_file: Cow<'a, str>, } struct Config { ignore_ext: bool, } fn handle_dir<'a>( writer: &mut csv::Writer<Box<dyn Write>>, dir: &Path, config: &Config, ) -> Result<(...
code_fim
hard
{ "lang": "rust", "repo": "heinrich5991/libtw2", "path": "/tools/src/bin/teehistorian_nonsolo_solo.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: heinrich5991/libtw2 path: /tools/src/bin/teehistorian_nonsolo_solo.rs extern crate chrono; extern crate clap; extern crate csv; extern crate itertools; extern crate logger; extern crate serde; #[macro_use] extern crate serde_derive; extern crate teehistorian; extern crate uuid; extern crate walk...
code_fim
hard
{ "lang": "rust", "repo": "heinrich5991/libtw2", "path": "/tools/src/bin/teehistorian_nonsolo_solo.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/antlog path: /macros/tests/ui/fail/capture_unsatisfied_trait.rs #![feature(stmt_expr_attributes, proc_macro_hygiene)] #[macro_use] extern crate antlog_macros; <|fim_suffix|> let kvs: &[(&str, antlog_macros_private::__private::Value)] = &[ #[display] input, ]; print...
code_fim
medium
{ "lang": "rust", "repo": "isgasho/antlog", "path": "/macros/tests/ui/fail/capture_unsatisfied_trait.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let kvs: &[(&str, antlog_macros_private::__private::Value)] = &[ #[display] input, ]; println!("{:?}", kvs); }<|fim_prefix|>// repo: isgasho/antlog path: /macros/tests/ui/fail/capture_unsatisfied_trait.rs #![feature(stmt_expr_attributes, proc_macro_hygiene)] #[macro_use] extern crat...
code_fim
easy
{ "lang": "rust", "repo": "isgasho/antlog", "path": "/macros/tests/ui/fail/capture_unsatisfied_trait.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wahello/spin path: /tests/http/headers-env-routes-test/src/lib.rs // Import the HTTP objects from the generated bindings. use spin_http::{Request, Response}; // Generate Rust bindings for interface defined in spin-http.wit file wit_bindgen_rust::export!("spin-http.wit"); struct SpinHttp; impl ...
code_fim
medium
{ "lang": "rust", "repo": "wahello/spin", "path": "/tests/http/headers-env-routes-test/src/lib.rs", "mode": "psm", "license": "LLVM-exception", "source": "the-stack-v2" }
<|fim_suffix|> let mut res = vec![]; std::env::vars().for_each(|(k, v)| res.push((format!("ENV_{}", k), v))); res } fn append_request_headers( res_headers: &mut Vec<(String, String)>, req_headers: &[(String, String)], ) { for (k, v) in req_headers { ...
code_fim
hard
{ "lang": "rust", "repo": "wahello/spin", "path": "/tests/http/headers-env-routes-test/src/lib.rs", "mode": "spm", "license": "LLVM-exception", "source": "the-stack-v2" }
<|fim_suffix|>impl SpinHttp { fn env_to_headers() -> Vec<(String, String)> { let mut res = vec![]; std::env::vars().for_each(|(k, v)| res.push((format!("ENV_{}", k), v))); res } fn append_request_headers( res_headers: &mut Vec<(String, String)>, req_headers: &[(Stri...
code_fim
hard
{ "lang": "rust", "repo": "wahello/spin", "path": "/tests/http/headers-env-routes-test/src/lib.rs", "mode": "spm", "license": "LLVM-exception", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn sol_test() { let (n, p, r) = solution(10_000_000_000); assert_eq!(n, 21033); assert_eq!(p, 237733); assert_eq!(r, 10000476378); } pub fn main() { let (n, p, r) = solution(10_000_000_000); println!("n: {}, p: {}, r: {}", n, p, r); // Prints: // n: 21033, p: 237...
code_fim
hard
{ "lang": "rust", "repo": "wackywendell/eulerrust", "path": "/src/bin/euler123.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wackywendell/eulerrust path: /src/bin/euler123.rs /** Prime square remainders Problem 123 Let p_n be the nth prime: 2, 3, 5, 7, 11, ..., and let r be the remainder when (p_n−1)^n + (p_n+1)^n is divided by p_n^2. For example, when n = 3, p_3 = 5, and 43 + 63 = 280 ≡ 5 mod 25. The least value o...
code_fim
medium
{ "lang": "rust", "repo": "wackywendell/eulerrust", "path": "/src/bin/euler123.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>fn get_rem(a: u64, n: u64) -> u64 { if n % 2 == 0 { 2 } else { (2 * a * n) % (a * a) } } #[test] fn test_123() { let mut pset = eulerrust::PrimeSet::new(); let (mut n, mut r) = (0, 0); while r < 1000_000_000 { n += 1; let p = pset.get(n as usize); ...
code_fim
hard
{ "lang": "rust", "repo": "wackywendell/eulerrust", "path": "/src/bin/euler123.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: theseus-os/Theseus path: /kernel/tlb_shootdown/src/lib.rs //! Support for broadcasting and handling TLB shootdown IPIs. #![no_std] use core::sync::atomic::{AtomicBool, AtomicU32, Ordering}; use irq_safety::hold_interrupts; use memory::PageRange; use cpu::cpu_count; use core::hint::spin_loop; ...
code_fim
hard
{ "lang": "rust", "repo": "theseus-os/Theseus", "path": "/kernel/tlb_shootdown/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // acquire lock // TODO: add timeout!! loop { if TLB_SHOOTDOWN_IPI_LOCK.compare_exchange_weak( false, true, Ordering::AcqRel, Ordering::Relaxed, ).is_ok() { break; } spin_loop(); } *TLB_SHOOTDO...
code_fim
hard
{ "lang": "rust", "repo": "theseus-os/Theseus", "path": "/kernel/tlb_shootdown/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: YuhanLiin/msp430fr2355-quickstart path: /src/serial.rs use crate::clocks::{Aclk, Clock, Smclk}; use msp430fr2355 as pac; use pac::e_usci_a1::uca1ctlw0::{UC7BIT_A, UCMSB_A, UCSPB_A, UCSSEL_A}; use pac::E_USCI_A1; enum Parity { Even, Odd, NoParity, } pub struct NoBaudConfig; pub en...
code_fim
hard
{ "lang": "rust", "repo": "YuhanLiin/msp430fr2355-quickstart", "path": "/src/serial.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let n = clk_freq / bps; if n == 0 { Err(BaudError::BpsTooHigh) } else if n > 0xFFFF { Err(BaudError::BpsTooLow) } else { let brs = Self::lookup_brs(clk_freq, bps); if n >= 16 { let div = bps * 16; ...
code_fim
hard
{ "lang": "rust", "repo": "YuhanLiin/msp430fr2355-quickstart", "path": "/src/serial.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wsgalaxy/fastxdr path: /src/impls/wire_size.rs use super::{NonDigitName, SafeName}; use crate::ast::{indexes::AstType, Ast, BasicType}; use crate::impls::template::*; use crate::Result; pub fn print_impl_wire_size<W: std::fmt::Write, T: FromTemplate>( mut w: W, template: T, ast: &As...
code_fim
hard
{ "lang": "rust", "repo": "wsgalaxy/fastxdr", "path": "/src/impls/wire_size.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> writeln!(w, r#"fn wire_size(&self) -> usize {{"#)?; func(&mut w)?; writeln!(w, "}}\n}}")?; Ok(()) } #[cfg(test)] mod tests { use super::*; use crate::impls::template::bytes::RefMutBytes; macro_rules! test_convert { ($name: ident, $input: expr, $want: expr) => { ...
code_fim
hard
{ "lang": "rust", "repo": "wsgalaxy/fastxdr", "path": "/src/impls/wire_size.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Tattomoosa/rust_music_player path: /src/main.rs // #![allow(non_snake_case)] #![allow(unused_variables)] // extern crate rodio; extern crate sciter; // use std::fs::File; use sciter::Element; use self::sciter::dom::event::*; use self::sciter::dom::HELEMENT; use std::io::BufReader; use rodio::S...
code_fim
hard
{ "lang": "rust", "repo": "Tattomoosa/rust_music_player", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> inputbot::KeybdKey::MKey.bind(|| { let mut player = Player::new(); player.load_folder("test_songs"); let html = include_bytes!("minimal.html"); println!("yooooooo"); let mut frame = sciter::Window::new(); frame.event_handler(player); frame.load_h...
code_fim
hard
{ "lang": "rust", "repo": "Tattomoosa/rust_music_player", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn literal_to_string(lit: ::proc_macro::Literal) -> Result<String,::proc_macro::Literal> { let formatted = lit.to_string(); let mut it = formatted.chars(); if it.next() != Some('"') { return Err(lit); } let mut rv = String::new(); loop { match it.next() { Some('"') => match it.next() ...
code_fim
hard
{ "lang": "rust", "repo": "fossabot/SnowFlake", "path": "/share/utf16_literal/src/lib.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fossabot/SnowFlake path: /share/utf16_literal/src/lib.rs #![feature(proc_macro)] // allow defining non-derive proc macros extern crate proc_macro; use proc_macro::TokenStream; #[proc_macro] pub fn utf16(input: TokenStream) -> TokenStream { let mut it = input.into_iter(); let mut rv = Vec::...
code_fim
hard
{ "lang": "rust", "repo": "fossabot/SnowFlake", "path": "/share/utf16_literal/src/lib.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> let mut b = Board::new(); for i in 0..64 { let s = Square::from_int(i); if let Some(p) = b.get_piece(s) { println!("{:} {:?}", s, p); } } let white_pawn = Piece::new(PieceKind::Pawn, Color::White); let e2 = Square::from_str("e2").unwrap(); let e4...
code_fim
medium
{ "lang": "rust", "repo": "trolley813/rusty-board", "path": "/tests/test_board.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: trolley813/rusty-board path: /tests/test_board.rs extern crate rusty_board; use rusty_board::board::*; use rusty_board::square::*; use rusty_board::moves::*; use rusty_board::piece::*; <|fim_suffix|> let mut b = Board::new(); for i in 0..64 { let s = Square::from_int(i); ...
code_fim
medium
{ "lang": "rust", "repo": "trolley813/rusty-board", "path": "/tests/test_board.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ehooper/aoc2017 path: /5_maze-of-trampolines/src/main.rs use std::io; fn count_steps(jump_list : &mut [i32]) -> usize { let mut index : i32 = 0; let mut count : usize = 0; let len = jump_list.len() as i32; while index >= 0 && index < len { let temp = index as usize; ...
code_fim
medium
{ "lang": "rust", "repo": "ehooper/aoc2017", "path": "/5_maze-of-trampolines/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let arg = std::env::args().nth(1); let part2 = arg.map_or(false, |s| s == "--part2"); let mut jump_list = Vec::<i32>::new(); let mut input = String::new(); println!("Enter jump list:"); while let Ok(_) = io::stdin().read_line(&mut input) { if let Ok(x) = input....
code_fim
hard
{ "lang": "rust", "repo": "ehooper/aoc2017", "path": "/5_maze-of-trampolines/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut jump_list = Vec::<i32>::new(); let mut input = String::new(); println!("Enter jump list:"); while let Ok(_) = io::stdin().read_line(&mut input) { if let Ok(x) = input.trim_right().parse::<i32>() { jump_list.push(x); } else { let steps = if pa...
code_fim
hard
{ "lang": "rust", "repo": "ehooper/aoc2017", "path": "/5_maze-of-trampolines/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn auto_trait_def_is_denied() { assert_ink_trait_eq_err!( error: "ink! trait definitions cannot be automatically implemented traits", pub auto trait MyTrait {} ); } #[test] fn non_pub_trait_def_is_denied() { assert_ink_trait_eq_e...
code_fim
hard
{ "lang": "rust", "repo": "patractlabs/ink", "path": "/crates/lang/ir/src/ir/trait_def.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> assert_ink_trait_eq_err!( error: "unsafe ink! trait methods are not supported", pub trait MyTrait { #[ink(constructor)] unsafe fn const_constructor() -> Self; } ); assert_ink_trait_eq_err!( error: "unsa...
code_fim
hard
{ "lang": "rust", "repo": "patractlabs/ink", "path": "/crates/lang/ir/src/ir/trait_def.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: patractlabs/ink path: /crates/lang/ir/src/ir/trait_def.rs structors = constructors.join(","); let joined_messages = messages.join(","); let mut buffer = vec!["__ink_trait".to_string(), trait_name.to_string()]; if !joined_constructors.is_empty() { buffer.push(j...
code_fim
hard
{ "lang": "rust", "repo": "patractlabs/ink", "path": "/crates/lang/ir/src/ir/trait_def.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pablo-mansanet-bluefruit/efm32gg11b path: /src/uart1/irctrl.rs "] pub type W = crate::W<u32, super::IRCTRL>; #[doc = "Register IRCTRL `reset()`'s with value 0"] impl crate::ResetValue for super::IRCTRL { type Type = u32; #[inline(always)] fn reset_value() -> Self::Type { 0 } } #[doc ...
code_fim
hard
{ "lang": "rust", "repo": "pablo-mansanet-bluefruit/efm32gg11b", "path": "/src/uart1/irctrl.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>SEL_A::PRSCH3) } #[doc = "PRS Channel 4 selected"] #[inline(always)] pub fn prsch4(self) -> &'a mut W { self.variant(IRPRSSEL_A::PRSCH4) } #[doc = "PRS Channel 5 selected"] #[inline(always)] pub fn prsch5(self) -> &'a mut W { self.variant(IRPRSSEL_A::PRSCH5) } #[doc = "PRS Chan...
code_fim
hard
{ "lang": "rust", "repo": "pablo-mansanet-bluefruit/efm32gg11b", "path": "/src/uart1/irctrl.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> { self.variant(IRPRSSEL_A::PRSCH5) } #[doc = "PRS Channel 6 selected"] #[inline(always)] pub fn prsch6(self) -> &'a mut W { self.variant(IRPRSSEL_A::PRSCH6) } #[doc = "PRS Channel 7 selected"] #[inline(always)] pub fn prsch7(self) -> &'a mut W { self.variant(IRPRSSEL_A::PRSCH7) } ...
code_fim
hard
{ "lang": "rust", "repo": "pablo-mansanet-bluefruit/efm32gg11b", "path": "/src/uart1/irctrl.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let auth = req.headers().get(header::AUTHORIZATION); let token = match auth { Some(header_value) => match header_value.to_str() { Ok(value) => Some(value.replace("Bearer", "").trim().to_string()), Err(_) => None, }, None =...
code_fim
hard
{ "lang": "rust", "repo": "engylemure/rust-graphql-with-dataloader", "path": "/app/src/handlers/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: engylemure/rust-graphql-with-dataloader path: /app/src/handlers/mod.rs use crate::models::user::SlimUser; use crate::utils::jwt::decode_token; use actix_web::{dev, http::header, Error, FromRequest, HttpRequest}; use futures::future::{ok, Ready}; pub type LoggedUser = SlimUser; <|fim_suffix|> ...
code_fim
hard
{ "lang": "rust", "repo": "engylemure/rust-graphql-with-dataloader", "path": "/app/src/handlers/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn generate_circle_points(radius: i32) -> Vec<(i32, i32)> { let mut points = Vec::new(); let mut col = radius; // why is this 90? if this was octects wouldn't it be 45? let degrees: f64 = 0.90; let num_to_go = degrees.sin() * radius as f64; for row in 0..num_to_go.round() as i32 { ...
code_fim
hard
{ "lang": "rust", "repo": "brandonphelps/rasteroids", "path": "/src/circles.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> canvas.set_draw_color(Color::RGB(0, 255, 0)); canvas.copy(&circle_texture, None, None).unwrap(); canvas.present(); // hold the app and wait for user to quit. 'holding_loop: loop { for event in event_pump.poll_iter() { match event { ...
code_fim
hard
{ "lang": "rust", "repo": "brandonphelps/rasteroids", "path": "/src/circles.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: brandonphelps/rasteroids path: /src/circles.rs #![allow(dead_code)] use sdl2::pixels::{Color, PixelFormatEnum}; use sdl2::rect::Point; use sdl2::render::{Canvas, Texture, TextureCreator}; use sdl2::surface::Surface; use sdl2::video::{Window, WindowContext}; fn circle_formula(x: u32, y: u32) ->...
code_fim
hard
{ "lang": "rust", "repo": "brandonphelps/rasteroids", "path": "/src/circles.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: GaloisInc/mir-verifier path: /lib/libstd/sys/cloudabi/args.rs pub use crate::sys::cloudabi::shims::args::*; <|fim_suffix|>#[allow(dead_code)] pub fn cleanup() {}<|fim_middle|>#[allow(dead_code)] pub fn init(_: isize, _: *const *const u8) {}
code_fim
medium
{ "lang": "rust", "repo": "GaloisInc/mir-verifier", "path": "/lib/libstd/sys/cloudabi/args.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>#[allow(dead_code)] pub fn cleanup() {}<|fim_prefix|>// repo: GaloisInc/mir-verifier path: /lib/libstd/sys/cloudabi/args.rs pub use crate::sys::cloudabi::shims::args::*; <|fim_middle|>#[allow(dead_code)] pub fn init(_: isize, _: *const *const u8) {}
code_fim
medium
{ "lang": "rust", "repo": "GaloisInc/mir-verifier", "path": "/lib/libstd/sys/cloudabi/args.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>pub fn draw_man_made_line_string( geo_tile: Arc<GeoTile>, data_structure: GeoTilesDataStructure, _man_made_type: ManMadeType, line_string: gt::LineString<f64>, ) { let points = line_string.into_points(); let mut first_iteration = true; let mut last_point = points[0]; for po...
code_fim
hard
{ "lang": "rust", "repo": "rustbunker/osm-geo-mapper", "path": "/src/features/man_made_feature.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rustbunker/osm-geo-mapper path: /src/features/man_made_feature.rs use crate::{ features::{GeoTile, GeoTileProperties, GeoTilesDataStructure, Geometry, ManMadeType}, operations::{line_string_operations::draw_line, address_from_properties, property_to_option_string}, }; use osm_geo_mapper_...
code_fim
hard
{ "lang": "rust", "repo": "rustbunker/osm-geo-mapper", "path": "/src/features/man_made_feature.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified-and-comments-removed path: /third_party/rust/winapi/src/vc/mod.rs # [ cfg ( feature = " excpt " ) ] pub mod excpt ; # [ cfg ( feature = " limits " ) ] pub mod limits ; # [<|fim_suffix|>cfg ( feature = " vcruntime " ) ] pub mod vcruntime ;<|fim_middle|> cfg ( feature =...
code_fim
easy
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified-and-comments-removed", "path": "/third_party/rust/winapi/src/vc/mod.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> cfg ( feature = " vadefs " ) ] pub mod vadefs ; # [ cfg ( feature = " vcruntime " ) ] pub mod vcruntime ;<|fim_prefix|>// repo: marco-c/gecko-dev-wordified-and-comments-removed path: /third_party/rust/winapi/src/vc/mod.rs # [ cfg ( feature = " excpt " ) ] pub mod excpt ; # <|fim_middle|>[ cfg ( feature ...
code_fim
easy
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified-and-comments-removed", "path": "/third_party/rust/winapi/src/vc/mod.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: soleinik/net-gazer-sensor path: /lib-comm/src/lib.rs #[macro_use] extern crate log; extern crate async_std; extern crate lib_data; extern crate net_gazer_core; #[allow(dead_code)] #[allow(unused_imports)] mod messaging_generated; use messaging_generated::*; use net_gazer_core::{CoreMessage, ...
code_fim
hard
{ "lang": "rust", "repo": "soleinik/net-gazer-sensor", "path": "/lib-comm/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut args = MessageArgs::default(); args.seq = self.seq; args.uptime = self.start_time.elapsed().as_secs(); args.sensor_id = Some(self.bldr.create_string(self.sensor_id)); args.ptype = comm_msg.0; args.payload = Some(self.bldr.create_vector(&comm_msg.1)...
code_fim
hard
{ "lang": "rust", "repo": "soleinik/net-gazer-sensor", "path": "/lib-comm/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn new(sensor_id:&'fbb str) -> Self{ Builder { seq:0, sensor_id, start_time:Instant::now(), bldr: flatbuffers::FlatBufferBuilder::new() } } fn reset(&mut self){ self.bldr.reset(); self.seq += 1; //FIXME: ove...
code_fim
hard
{ "lang": "rust", "repo": "soleinik/net-gazer-sensor", "path": "/lib-comm/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Cargill/splinter path: /libsplinter/src/peer/mod.rs t_peer", ]))) .with_matrix_life_cycle(mesh.get_life_cycle()) .with_matrix_sender(mesh.get_sender()) .with_transport(transport.clone()) .start() .expect("Unable to start Con...
code_fim
hard
{ "lang": "rust", "repo": "Cargill/splinter", "path": "/libsplinter/src/peer/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> for endpoint in endpoints.iter() { match connector.request_connection( endpoint, &connection_id, Some(peer_id.clone().into()), Some(required_local_auth.clone().into()), ) { Ok(()) => { active_endpoint = endpoin...
code_fim
hard
{ "lang": "rust", "repo": "Cargill/splinter", "path": "/libsplinter/src/peer/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> false } #[cfg(test)] pub mod tests { use super::*; use std::collections::VecDeque; use std::sync::mpsc; use std::time::Duration; use protobuf::Message; use crate::mesh::Mesh; use crate::network::auth::ConnectionAuthorizationType; use crate::network::connection_manag...
code_fim
hard
{ "lang": "rust", "repo": "Cargill/splinter", "path": "/libsplinter/src/peer/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>e ADCL = crate::Reg<u32, _ADCL>; #[allow(missing_docs)] #[doc(hidden)] pub struct _ADCL; #[doc = "`read()` method returns [adcl::R](adcl::R) reader structure"] impl crate::Readable for ADCL {} #[doc = "`write(|w| ..)` method takes [adcl::W](adcl::W) writer structure"] impl crate::Writable for ADCL {} #[do...
code_fim
hard
{ "lang": "rust", "repo": "pipex/cc2538", "path": "/src/soc_adc.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pipex/cc2538 path: /src/soc_adc.rs #[doc = r"Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - This register controls the ADC."] pub adccon1: ADCCON1, #[doc = "0x04 - This register controls the ADC."] pub adccon2: ADCCON2, #[doc = "0x08 - This register co...
code_fim
hard
{ "lang": "rust", "repo": "pipex/cc2538", "path": "/src/soc_adc.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mvertescher/lvgl-rs path: /lvgl/src/ui.rs use crate::Box; use crate::{Color, Event, LvError, LvResult, Obj, Widget}; use core::marker::PhantomData; use core::mem::MaybeUninit; use core::ptr; use core::ptr::NonNull; use core::sync::atomic::{AtomicBool, Ordering}; use core::time::Duration; use emb...
code_fim
hard
{ "lang": "rust", "repo": "mvertescher/lvgl-rs", "path": "/lvgl/src/ui.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn get_display_ref(&self) -> Option<&T> { match self.display_data.as_ref() { None => None, Some(v) => Some(&v.display), } } pub fn scr_act(&self) -> LvResult<Obj> { unsafe { let screen = lvgl_sys::lv_disp_get_scr_act(ptr::null_mu...
code_fim
hard
{ "lang": "rust", "repo": "mvertescher/lvgl-rs", "path": "/lvgl/src/ui.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn scr_act(&self) -> LvResult<Obj> { unsafe { let screen = lvgl_sys::lv_disp_get_scr_act(ptr::null_mut()); if let Some(v) = NonNull::new(screen) { Ok(Obj::from_raw(v)) } else { Err(LvError::InvalidReference) } ...
code_fim
hard
{ "lang": "rust", "repo": "mvertescher/lvgl-rs", "path": "/lvgl/src/ui.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let session = args.session.lock()?; let storage = Arc::clone(&session.storage); let path = session.cwd.join(self.path.clone()); let tx_success = args.tx.clone(); let tx_fail = args.tx.clone(); tokio::spawn( storage .mkd(&session.u...
code_fim
hard
{ "lang": "rust", "repo": "omikuji/libunftp", "path": "/src/server/commands/mkd.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: omikuji/libunftp path: /src/server/commands/mkd.rs //! The RFC 959 Make Directory (`MKD`) command // // This command causes the directory specified in the pathname // to be created as a directory (if the pathname is absolute) // or as a subdirectory of the current working directory (if // the pa...
code_fim
medium
{ "lang": "rust", "repo": "omikuji/libunftp", "path": "/src/server/commands/mkd.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub mod prelude; pub mod uicontext; pub mod traits; pub mod widgets; pub mod theme; pub mod enums; mod event;<|fim_prefix|>// repo: garkimasera/tenuki-ui path: /src/lib.rs extern crate sdl2; extern crate sdl2_ttf; <|fim_middle|>#[macro_use] extern crate lazy_static;
code_fim
easy
{ "lang": "rust", "repo": "garkimasera/tenuki-ui", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: garkimasera/tenuki-ui path: /src/lib.rs extern crate sdl2; extern crate sdl2_ttf; <|fim_suffix|>pub mod prelude; pub mod uicontext; pub mod traits; pub mod widgets; pub mod theme; pub mod enums; mod event;<|fim_middle|>#[macro_use] extern crate lazy_static;
code_fim
easy
{ "lang": "rust", "repo": "garkimasera/tenuki-ui", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: WereDiggle/pathtracer path: /src/geometry/hit.rs use std::sync::Arc; use crate::*; pub struct HitRecord { pub material: Arc<dyn Material>, pub position: Vec3, pub normal: Vec3, pub distance: f64, pub front_face: bool, pub u: f64, pub v: f64, } impl HitRecord { ...
code_fim
hard
{ "lang": "rust", "repo": "WereDiggle/pathtracer", "path": "/src/geometry/hit.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> direction[0] = self.cos_theta * r.direction[0] - self.sin_theta * r.direction[2]; direction[2] = self.sin_theta * r.direction[0] + self.cos_theta * r.direction[2]; let rotated_r = Ray::new(origin, direction, r.time); self.object .hit(&rotated_r, t_min, t_max) ...
code_fim
hard
{ "lang": "rust", "repo": "WereDiggle/pathtracer", "path": "/src/geometry/hit.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: datastark/interbtc path: /crates/refund/src/types.rs pub use primitives::refund::RefundRequest; <|fim_suffix|>pub(crate) type Wrapped<T> = BalanceOf<T>;<|fim_middle|>pub(crate) type BalanceOf<T> = <T as vault_registry::Config>::Balance;
code_fim
medium
{ "lang": "rust", "repo": "datastark/interbtc", "path": "/crates/refund/src/types.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub(crate) type Wrapped<T> = BalanceOf<T>;<|fim_prefix|>// repo: datastark/interbtc path: /crates/refund/src/types.rs pub use primitives::refund::RefundRequest; <|fim_middle|>pub(crate) type BalanceOf<T> = <T as vault_registry::Config>::Balance;
code_fim
medium
{ "lang": "rust", "repo": "datastark/interbtc", "path": "/crates/refund/src/types.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: caojen/heystack path: /src/diskio/read_write.rs //! write a struct into ::std::fs::File (append) //! read struct(s) from ::std::fs::File //! help change a sturct of ::std::fs::File use ::std::io; use ::std::io::prelude::*; use ::std::fs; use ::std::mem; use super::struct_slice; /// OpenOption...
code_fim
hard
{ "lang": "rust", "repo": "caojen/heystack", "path": "/src/diskio/read_write.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] pub fn test_read_and_write_complex_struct() -> io::Result<()> { let a = TestStruct2::new(1, 291, true, 0, 199992); let b = TestStruct2::new(98, 23123, false, 12, 22); let c = TestStruct2::new(26, 8, false, 0, 1277372); let filename = "test333"; { let mut f = fs::File:...
code_fim
hard
{ "lang": "rust", "repo": "caojen/heystack", "path": "/src/diskio/read_write.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: forkkit/jsonpath path: /tests/op.rs #[macro_use] extern crate serde_json; use common::{read_json, select_and_then_compare, setup}; mod common; #[test] fn op_object_eq() { setup(); select_and_then_compare( "$.school[?(@.friends == @.friends)]", read_json("./benchmark/d...
code_fim
hard
{ "lang": "rust", "repo": "forkkit/jsonpath", "path": "/tests/op.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> setup(); select_and_then_compare( r#"$.[?(@.a == @.c)]"#, json!({"a": { "1": 1 }, "b": { "2": 2 }, "c": { "1": 1 }}), json!([{"a": { "1": 1 }, "b": { "2": 2 }, "c": { "1": 1 }}]), ); } /// /// It seems to Jayway's bug. /// /// 빈 배열이 아니라 current context가 리턴되야 하는데 빈배열이 ...
code_fim
hard
{ "lang": "rust", "repo": "forkkit/jsonpath", "path": "/tests/op.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>} #[test] fn op_lt_for_string_value() { setup(); select_and_then_compare( r#"$.[?(@.a < "b")]"#, json!({ "a": "b" }), json!([]), ); } #[test] fn op_le_for_string_value() { setup(); select_and_then_compare( r#"$.[?(@.a <= "b")]"#, json!({ "a": "b" }), json!([{ "a": "...
code_fim
hard
{ "lang": "rust", "repo": "forkkit/jsonpath", "path": "/tests/op.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: euclio/seventeen path: /src/editor/window.rs use std::io::{self, Write}; use euclid::{Rect, SideOffsets2D}; use log::*; use super::line_cache::LineCache; use super::styles::Styles; use crate::screen::{Coordinate, Screen}; #[derive(Debug)] pub struct Window { pub cursor: Coordinate, pu...
code_fim
hard
{ "lang": "rust", "repo": "euclio/seventeen", "path": "/src/editor/window.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod test { use std::io::Cursor; use euclid::{Rect, Size2D}; use super::{LineCache, Screen, Window}; use crate::editor::styles::Styles; use crate::screen::Coordinate; #[test] fn cache_smaller_than_window() { let styles = Styles::new(); let bounds ...
code_fim
hard
{ "lang": "rust", "repo": "euclio/seventeen", "path": "/src/editor/window.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: threecgreen/vinoteca path: /src/colors.rs use crate::error::{RestResult, VinotecaError}; use crate::models::{generic, Color}; use crate::schema::{colors, purchases, wines}; use crate::users::Auth; use crate::DbConn; use diesel::dsl::sql; use diesel::prelude::*; use rocket_contrib::json::Json; ...
code_fim
hard
{ "lang": "rust", "repo": "threecgreen/vinoteca", "path": "/src/colors.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[get("/colors/top")] pub fn top(auth: Auth, connection: DbConn) -> RestResult<Vec<generic::TopEntity>> { let limit = 20; top_table!( colors::table .inner_join(wines::table.inner_join(purchases::table)) .filter(wines::user_id.eq(auth.id)), colors::id, ...
code_fim
hard
{ "lang": "rust", "repo": "threecgreen/vinoteca", "path": "/src/colors.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fernandobatels/fiscal-rs path: /nfe/src/base/ide/operacao.rs //! Dados da operação da NF-e use chrono::prelude::*; use serde_repr::{Deserialize_repr, Serialize_repr}; /// Dados referentes a operação da nota #[derive(Debug, PartialEq, Clone)] pub struct Operacao { pub horario: Option<DateTi...
code_fim
hard
{ "lang": "rust", "repo": "fernandobatels/fiscal-rs", "path": "/nfe/src/base/ide/operacao.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Tipo do intermediador #[derive(Debug, Eq, PartialEq, Copy, Clone, Deserialize_repr, Serialize_repr)] #[repr(u8)] pub enum TipoIntermediador { /// Operação sem intermediador (em site ou plataforma própria) SemIntermediador = 0, /// Operação em site ou plataforma de terceiros (intermediadore...
code_fim
hard
{ "lang": "rust", "repo": "fernandobatels/fiscal-rs", "path": "/nfe/src/base/ide/operacao.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for t in threads { t.join().unwrap(); } }<|fim_prefix|>// repo: chinanf-boy/gentle-intro path: /code/thread7.rs // thread7.rs use std::thread; use std::sync::Arc; use std::sync::Barrier; fn main() { <|fim_middle|> let nthreads = 5; let mut threads = Vec::new(); let barrier = A...
code_fim
hard
{ "lang": "rust", "repo": "chinanf-boy/gentle-intro", "path": "/code/thread7.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chinanf-boy/gentle-intro path: /code/thread7.rs // thread7.rs use std::thread; use std::sync::Arc; use std::sync::Barrier; <|fim_suffix|> let nthreads = 5; let mut threads = Vec::new(); let barrier = Arc::new(Barrier::new(nthreads)); for i in 0..nthreads { let barrier = ...
code_fim
medium
{ "lang": "rust", "repo": "chinanf-boy/gentle-intro", "path": "/code/thread7.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut index = 0; while index < 5 { println!("the value is: {}", array[index]); index = index + 1; } println!("inside for loop"); for element in array.iter() { println!("{}", element); } for number in (1..4).rev() { println!("{}!", number);...
code_fim
hard
{ "lang": "rust", "repo": "Thiago18l/Rust", "path": "/src/basic/control_flow.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Thiago18l/Rust path: /src/basic/control_flow.rs fn main() { let number = 3; if number < 5 { println!("Condition was true"); } else { println!("Condition was false"); } let six: i32 = 6; if six % 4 == 0 { println!("Number is divisible by 4"); } ...
code_fim
hard
{ "lang": "rust", "repo": "Thiago18l/Rust", "path": "/src/basic/control_flow.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> println!("The frequency {} occurred twice.", freq); return; }, Err(index) => v.insert(index, freq), } } } }<|fim_prefix|>// repo: miterion/adventofcode18 path: /src/days/first.rs pub fn first_day(input: &String){ let mut start_freq = 0; ...
code_fim
hard
{ "lang": "rust", "repo": "miterion/adventofcode18", "path": "/src/days/first.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: miterion/adventofcode18 path: /src/days/first.rs pub fn first_day(input: &String){ let mut start_freq = 0; for number in input.split_whitespace() { start_freq += number.parse::<i32>().unwrap(); } <|fim_suffix|> println!("The frequency {} occurred twice.", freq); ...
code_fim
hard
{ "lang": "rust", "repo": "miterion/adventofcode18", "path": "/src/days/first.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }