text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: DiogenesPolanco/L5P-Keyboard-RGB path: /src/gui/options_tile.rs use std::sync::{ atomic::{AtomicBool, Ordering}, mpsc::Sender, Arc, }; use crate::enums::Message; use super::enums::Colors; use fltk::{ enums::{Color, FrameType}, group::Tile, menu::Choice, prelude::*, }; struct OptionsCho...
code_fim
hard
{ "lang": "rust", "repo": "DiogenesPolanco/L5P-Keyboard-RGB", "path": "/src/gui/options_tile.rs", "mode": "psm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|> //Brightness brightness_choice.set_callback({ let tx = tx.clone(); let stop_signal = stop_signal.clone(); move |choice| { stop_signal.store(true, Ordering::SeqCst); if let Some(value) = choice.choice() { let brightness = value.parse::<u8>().unwrap(); if (1..=2).contains(&bri...
code_fim
hard
{ "lang": "rust", "repo": "DiogenesPolanco/L5P-Keyboard-RGB", "path": "/src/gui/options_tile.rs", "mode": "spm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|> // Options tile options_tile.set_frame(FrameType::FlatBox); options_tile.set_color(Color::from_u32(Colors::DarkGray as u32)); speed_choice.set_callback({ let tx = tx.clone(); let stop_signal = stop_signal.clone(); move |choice| { stop_signal.store(true, Ordering::SeqCst); if let ...
code_fim
hard
{ "lang": "rust", "repo": "DiogenesPolanco/L5P-Keyboard-RGB", "path": "/src/gui/options_tile.rs", "mode": "spm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|> #[derive(Deserialize, Debug)] pub struct UserResponse { pub id: i16, pub name: String, pub email: String, } #[repr(C)] pub struct UserStruct { pub id: i16, pub name: *mut c_char, pub email: *mut c_char, }<|fim_prefix|>// repo: CarlosLanderas/dotnet2021-aot-compilation path: /int...
code_fim
hard
{ "lang": "rust", "repo": "CarlosLanderas/dotnet2021-aot-compilation", "path": "/interop/csharp-to-rust/rust-lib/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: CarlosLanderas/dotnet2021-aot-compilation path: /interop/csharp-to-rust/rust-lib/src/lib.rs use serde_derive::Deserialize; use std::{ffi::CString, os::raw::c_char}; static mut NAME_POINTER: *mut c_char = 0 as *mut c_char; static mut EMAIL_POINTER: *mut c_char = 0 as *mut c_char; #[no_mangle] p...
code_fim
hard
{ "lang": "rust", "repo": "CarlosLanderas/dotnet2021-aot-compilation", "path": "/interop/csharp-to-rust/rust-lib/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Deserialize, Debug)] pub struct UserResponse { pub id: i16, pub name: String, pub email: String, } #[repr(C)] pub struct UserStruct { pub id: i16, pub name: *mut c_char, pub email: *mut c_char, }<|fim_prefix|>// repo: CarlosLanderas/dotnet2021-aot-compilation path: /inte...
code_fim
medium
{ "lang": "rust", "repo": "CarlosLanderas/dotnet2021-aot-compilation", "path": "/interop/csharp-to-rust/rust-lib/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AljoschaMeyer/panda_pile path: /src/nb_send.rs //! Nonblocking, threadsafe traits for lazily producing or consuming sequences of arbitrary length, and functions for piping producers into consumers. All asynchronous APIs are derived from the corresponding [synchronous APIs](crate::sync) through t...
code_fim
hard
{ "lang": "rust", "repo": "AljoschaMeyer/panda_pile", "path": "/src/nb_send.rs", "mode": "psm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Returns a nonempty buffer from which items can be taken, or the last sequence item if it has been reached. /// /// This method must be compatible with [`Self::produce`](Producer::produce): when returning a slice of length `n`, the next `n` calls to [`Self::produce`](Producer::produce) have...
code_fim
hard
{ "lang": "rust", "repo": "AljoschaMeyer/panda_pile", "path": "/src/nb_send.rs", "mode": "spm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ericrobolson/valkyrie path: /valkyrie_core/crates/_platform_specific/platform_window_gfx/src/glow_wingfx.rs use glutin::event::{Event, WindowEvent}; use glutin::event_loop::{ControlFlow, EventLoop}; use glutin::window::WindowBuilder; use glutin::{ContextBuilder, ContextWrapper}; use core_render...
code_fim
hard
{ "lang": "rust", "repo": "ericrobolson/valkyrie", "path": "/valkyrie_core/crates/_platform_specific/platform_window_gfx/src/glow_wingfx.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let windowed_context = unsafe { windowed_context.make_current().unwrap() }; let mut renderer = core_renderer::make_renderer(Box::new(make(self.w, self.h, &windowed_context))); let mut last_frame = u64::MAX; el.run(move |event, _, control_flow| { *c...
code_fim
hard
{ "lang": "rust", "repo": "ericrobolson/valkyrie", "path": "/valkyrie_core/crates/_platform_specific/platform_window_gfx/src/glow_wingfx.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let ev = match &ev { Some(ev) => { match ev { WindowMsg::RedrawRequested => { renderer.dispatch(); windowed_context.swap_buffers().unwrap(); } ...
code_fim
hard
{ "lang": "rust", "repo": "ericrobolson/valkyrie", "path": "/valkyrie_core/crates/_platform_specific/platform_window_gfx/src/glow_wingfx.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let cur = self.current_pos; let next = (cur.0 + self.down, cur.1 + self.right); if self.grid.get(next.0, next.1).is_some() { self.current_pos = next; Some(next) } else { None } } } #[cfg(test)] mod tests { use super::*; ...
code_fim
hard
{ "lang": "rust", "repo": "ijagberg/aoc-2020", "path": "/src/grid.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn next(&mut self) -> Option<Self::Item> { let cur = self.current_pos; let next = (cur.0 + self.down, cur.1 + self.right); if self.grid.get(next.0, next.1).is_some() { self.current_pos = next; Some(next) } else { None } }...
code_fim
hard
{ "lang": "rust", "repo": "ijagberg/aoc-2020", "path": "/src/grid.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ijagberg/aoc-2020 path: /src/grid.rs use std::convert::TryFrom; use simple_grid::Grid; pub fn parse_toboggan_map(lines: &[String]) -> TobogganMap { let height = lines.len(); if height == 0 { return TobogganMap::from_grid(Grid::new(0, 0, Vec::new())); } let width = lin...
code_fim
hard
{ "lang": "rust", "repo": "ijagberg/aoc-2020", "path": "/src/grid.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut s_min = ::std::f32::INFINITY; let mut t_min = ::std::f32::INFINITY; let mut s_max = ::std::f32::NEG_INFINITY; let mut t_max = ::std::f32::NEG_INFINITY; for edge_idx in &edgelist[face.edge_id..face.edge_id + face.edge_count] { let vertex_id = edg...
code_fim
hard
{ "lang": "rust", "repo": "cormac-obrien/richter", "path": "/src/common/bsp/load.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // render nodes reader.seek(SeekFrom::Start(render_node_section.offset))?; debug!("Render node count = {}", render_node_count); let mut render_nodes = Vec::with_capacity(render_node_count); for _ in 0..render_node_count { render_nodes.push(load_render_node(&mut reader)?); }...
code_fim
hard
{ "lang": "rust", "repo": "cormac-obrien/richter", "path": "/src/common/bsp/load.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cormac-obrien/richter path: /src/common/bsp/load.rs _section_ofs: u64, tex_ofs: u64, ) -> Result<BspFileTexture, failure::Error> where R: ReadBytesExt + Seek, { // convert texture name from NUL-terminated to str let mut tex_name_bytes = [0u8; TEX_NAME_MAX]; reader.read(&mut t...
code_fim
hard
{ "lang": "rust", "repo": "cormac-obrien/richter", "path": "/src/common/bsp/load.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn write_traces(html_file: &mut File, counts_file: &mut File, traces: &[Rec]) { let capacity = traces.iter().fold(0, |acc, t| acc + 1 + t.extent.len()); let mut counts = FxHashMap::with_capacity_and_hasher(capacity, Default::default()); compute_counts_rec(&mut counts, traces); write_co...
code_fim
hard
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/librustc_interface/profile/trace.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/librustc_interface/profile/trace.rs use super::*; use syntax_pos::SpanData; use rustc_data_structures::fx::FxHashMap; use rustc::util::common::QueryMsg; use std::fs::File; use std::time::{Duration, Instant}; use rustc::dep_graph::{DepNode}; #[derive(De...
code_fim
hard
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/librustc_interface/profile/trace.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if percent > 0.1 { (format!("{:.1}%", percent), css) } else { ("< 0.1%".to_string(), css) } } fn total_duration(traces: &[Rec]) -> Duration { Duration::new(0, 0) + traces.iter().map(|t| t.dur_total).sum() } fn duration_div(nom: Duration, den: Duration) -> f64 { fn to_...
code_fim
hard
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/librustc_interface/profile/trace.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ljgago/advent-of-code-2020 path: /day01/src/main.rs // Advent of Code 2020 - Day 1 use std::collections::HashSet; use aoc2020::input::read_by_line; mod part_one; mod part_two; fn main() { let data: Vec<i64> = read_by_line("./resources/input.txt"); let (sum, multiply) = part_one::che...
code_fim
hard
{ "lang": "rust", "repo": "ljgago/advent-of-code-2020", "path": "/day01/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let multiply = part_two::check_expense_report_op(data_hash.clone(), 2020).unwrap(); println!("--- Part Two Optimized ---"); println!("Multiply: {}", multiply); }<|fim_prefix|>// repo: ljgago/advent-of-code-2020 path: /day01/src/main.rs // Advent of Code 2020 - Day 1 use std::collections::Has...
code_fim
hard
{ "lang": "rust", "repo": "ljgago/advent-of-code-2020", "path": "/day01/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: programble/patience path: /src/card/pile.rs use std::fmt::{Debug, Formatter, Error as FmtError}; use std::iter::FromIterator; use std::slice::Iter; use rand::{self, Rng}; use super::Face; /// Pile of face-down or face-up cards. #[derive(Clone, PartialEq, Eq, Default)] #[allow(missing_docs)] p...
code_fim
hard
{ "lang": "rust", "repo": "programble/patience", "path": "/src/card/pile.rs", "mode": "psm", "license": "ISC", "source": "the-stack-v2" }
<|fim_suffix|> /// Gets the card at the index from the bottom. pub fn get(&self, index: usize) -> Option<Face> { self.vec.get(index).cloned() } /// Gets the card at the index from the top. pub fn get_back(&self, index: usize) -> Option<Face> { self.vec.len() .checked_sub(...
code_fim
hard
{ "lang": "rust", "repo": "programble/patience", "path": "/src/card/pile.rs", "mode": "spm", "license": "ISC", "source": "the-stack-v2" }
<|fim_suffix|>impl Transaction for RaiseBid { fn verify(&self) -> bool { self.verify_signature(self.customer_key()) } fn execute(&self, fork: &mut Fork) -> ExecutionResult { let mut schema = Schema::new(fork); let customer_key = self.customer_key(); let hash = self.hash(); ...
code_fim
hard
{ "lang": "rust", "repo": "mulder93/exonum_auction", "path": "/backend/src/transactions.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mulder93/exonum_auction path: /backend/src/transactions.rs use exonum::{ blockchain::{ExecutionError, ExecutionResult, Transaction}, crypto::{CryptoHash, PublicKey}, messages::Message, storage::Fork, }; use schema::Schema; use SERVICE_ID; #[derive(Debug, Fail)] #[repr(u8)] pub enum Err...
code_fim
hard
{ "lang": "rust", "repo": "mulder93/exonum_auction", "path": "/backend/src/transactions.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut x: i32 = 3; dbg!(x); dbg!(x.setmin(5)); dbg!(x); dbg!(x.setmin(2)); dbg!(x); dbg!(mat![[1, 2], [3, 4]]); dbg!(mat![0; 2; 3]); }<|fim_prefix|>// repo: imos/icfpc2021 path: /src/bin/tos1.rs use icfpc2021::{mat, util::SetMinMax as _}; <|fim_middle|>fn main() {
code_fim
easy
{ "lang": "rust", "repo": "imos/icfpc2021", "path": "/src/bin/tos1.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: imos/icfpc2021 path: /src/bin/tos1.rs use icfpc2021::{mat, util::SetMinMax as _}; <|fim_suffix|> let mut x: i32 = 3; dbg!(x); dbg!(x.setmin(5)); dbg!(x); dbg!(x.setmin(2)); dbg!(x); dbg!(mat![[1, 2], [3, 4]]); dbg!(mat![0; 2; 3]); }<|fim_middle|>fn main() {
code_fim
easy
{ "lang": "rust", "repo": "imos/icfpc2021", "path": "/src/bin/tos1.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>unsafe impl<H> Sync for SPIHandler<H> {} impl<H> SPIHandler<H> { // NOTE(uninit): Before the init function is run, no SPI exists so its methods can't be called. // The handle_interrupt can't be safely called manually. It will be called if the interrupt // handler triggers, but it should only ...
code_fim
hard
{ "lang": "rust", "repo": "tweedegolf/async-spi", "path": "/src/common.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tweedegolf/async-spi path: /src/common.rs use core::cell::UnsafeCell; use core::mem::MaybeUninit; use core::ptr::null_mut; use async_heapless::Oneshot; // Hardware management of NSS is not sufficient: It drives the pin low when SPE is enabled but does // not drive the pin high when it is disab...
code_fim
hard
{ "lang": "rust", "repo": "tweedegolf/async-spi", "path": "/src/common.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// A `SPI` can be obtained by calling `init` on a static `SPIHandler`. impl<H: SPIHardware> SPI<H> { async fn begin(&mut self, buf: Buffer) -> Result<(), Error> { if buf.start == buf.end { return Ok(()); } let recv = unsafe { self.handler.result.take()...
code_fim
hard
{ "lang": "rust", "repo": "tweedegolf/async-spi", "path": "/src/common.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // msb to lsb if the number 1 first bit in msb that means its signed or 0 means its not signed<|fim_prefix|>// repo: nomansadiq11/rust-learning path: /datatypes/src/main.rs fn main() { let age = 30; let Percentage = 90; let grade = 'A'; let passed = true; let secret_number : i32...
code_fim
easy
{ "lang": "rust", "repo": "nomansadiq11/rust-learning", "path": "/datatypes/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nomansadiq11/rust-learning path: /datatypes/src/main.rs fn main() { let age = 30; let Percentage = 90; let grade = 'A'; let passed = true; <|fim_suffix|> // msb to lsb if the number 1 first bit in msb that means its signed or 0 means its not signed<|fim_middle|> let secre...
code_fim
medium
{ "lang": "rust", "repo": "nomansadiq11/rust-learning", "path": "/datatypes/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>// msb to lsb if the number 1 first bit in msb that means its signed or 0 means its not signed<|fim_prefix|>// repo: nomansadiq11/rust-learning path: /datatypes/src/main.rs fn main() { let age = 30; let Percentage = 90; let grade = 'A'; let passed = true; let secret_number : i32 ...
code_fim
easy
{ "lang": "rust", "repo": "nomansadiq11/rust-learning", "path": "/datatypes/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: risoflora/fiscalidade_server path: /src/routes/auth.rs use rocket::{ http::Status, request::{self, FromRequest, Request}, Outcome, }; use crate::db::{self, taxpayer}; use crate::models::taxpayer::QueryableTaxpayer; pub struct Auth { pub id: i64, pub token: String, } impl A...
code_fim
hard
{ "lang": "rust", "repo": "risoflora/fiscalidade_server", "path": "/src/routes/auth.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub struct AuthAdmin { pub id: i64, pub token: String, pub manager: bool, } impl AuthAdmin { pub fn enter<'a, 'r>( request: &'a Request<'r>, ) -> request::Outcome<(db::Conn, QueryableTaxpayer, bool), ()> { let (conn, taxpayer) = Auth::enter(request)?; let is_ma...
code_fim
hard
{ "lang": "rust", "repo": "risoflora/fiscalidade_server", "path": "/src/routes/auth.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl<'a, 'r> FromRequest<'a, 'r> for AuthAdmin { type Error = (); fn from_request(request: &'a Request<'r>) -> request::Outcome<Self, Self::Error> { let (_, taxpayer, is_manager) = AuthAdmin::enter(request)?; Outcome::Success(Self { id: taxpayer.id, token: ...
code_fim
hard
{ "lang": "rust", "repo": "risoflora/fiscalidade_server", "path": "/src/routes/auth.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> for pass in boarding_passes { let seat_id: u32 = find_row(pass) * 8 + find_column(pass); if seat_id > max { max = seat_id; } } max } fn part2(boarding_passes: &Vec<&str>) -> u32 { let mut seat_ids = boarding_passes.iter() .map(|pass| 8 * find_r...
code_fim
hard
{ "lang": "rust", "repo": "ginglis13/advent-of-code-2020", "path": "/d05/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ginglis13/advent-of-code-2020 path: /d05/src/main.rs /* Advent of Code Day 5 * * https://adventofcode.com/2020/day/5 * * Part 1 * Find row and column of seat on plane using binary partitioning * First 7 letters are (F)ront or (B)ack, last 3 are (L)eft or (R)ight. * 128 rows (0-127) and 8 ...
code_fim
hard
{ "lang": "rust", "repo": "ginglis13/advent-of-code-2020", "path": "/d05/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> return if start < end {start} else {end} } fn part1(boarding_passes: &Vec<&str>) -> u32 { let mut max: u32 = 0; for pass in boarding_passes { let seat_id: u32 = find_row(pass) * 8 + find_column(pass); if seat_id > max { max = seat_id; } } max } ...
code_fim
hard
{ "lang": "rust", "repo": "ginglis13/advent-of-code-2020", "path": "/d05/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Arrays. let arr = [1, 2, 3, 4, 5]; println!("Print first array:"); for i in 0..arr.len() { println!("{}", arr[i]); } println!("Print second array:"); let arr2 = [1; 10]; // Array with 10 ones. for i in 0..arr2.len() { println!("{}", arr2[i]); } }<|fi...
code_fim
hard
{ "lang": "rust", "repo": "AlexHart/rust-book", "path": "/variables/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Tuples. let tup: (i32, f64, char) = (1234, 56789.0, 'A'); println!("With direct access: {} {} {}", tup.0, tup.1, tup.2); let (a, b, c) = tup; println!("With destructuring: {} {} {}", a, b, c); // Arrays. let arr = [1, 2, 3, 4, 5]; println!("Print first array:"); for...
code_fim
hard
{ "lang": "rust", "repo": "AlexHart/rust-book", "path": "/variables/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AlexHart/rust-book path: /variables/src/main.rs const MAX_POINTS: u32 = 100_000; fn main() { let mut x = 5; println!("The value of x is: {}", x); x = 6; println!("The value of x is: {}", x); println!("The value of MAX_POINTS is: {}", MAX_POINTS); <|fim_suffix|> // Tuple...
code_fim
hard
{ "lang": "rust", "repo": "AlexHart/rust-book", "path": "/variables/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hgzimmerman/HLWNPA path: /src/main.rs //#![feature(discriminant_value)] #![feature(trace_macros)] #![feature(test)] #![recursion_limit="100"] #![macro_use] extern crate nom; #[cfg(test)] extern crate test; extern crate clap; extern crate uuid; use clap::{Arg, App}; use nom::IResult; use std::...
code_fim
hard
{ "lang": "rust", "repo": "hgzimmerman/HLWNPA", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match program(preprocessed_program.as_bytes()) { IResult::Done(_, ast) => { let mut map: VariableStore = VariableStore::new(); let mut mutability_map: MutabilityMap = MutabilityMap::new(); ...
code_fim
hard
{ "lang": "rust", "repo": "hgzimmerman/HLWNPA", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let repl_after_parse: bool = matches.is_present("repl"); match matches.value_of("file") { Some(filename) => { // read the file into a string, parse it, and execute the resulting AST match OpenOptions::new().read(true).open(&filename) { Ok(file) => ...
code_fim
hard
{ "lang": "rust", "repo": "hgzimmerman/HLWNPA", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>l, pub tag: String, pub timestamps: bool, }<|fim_prefix|>// repo: LukasOtter/chipmunk path: /application/apps/indexer-neon/native/src/config.rs use std::path; #[derive(Debug)] pub struct Indexi<|fim_middle|>ngThreadConfig { pub in_file: path::PathBuf, pub out_path: path::PathBuf, pub...
code_fim
medium
{ "lang": "rust", "repo": "LukasOtter/chipmunk", "path": "/application/apps/indexer-neon/native/src/config.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: LukasOtter/chipmunk path: /application/apps/indexer-neon/native/src/config.rs use std::path; #[derive(Debug)] pub struct Indexi<|fim_suffix|> pub out_path: path::PathBuf, pub append: bool, pub tag: String, pub timestamps: bool, }<|fim_middle|>ngThreadConfig { pub in_file: path:...
code_fim
easy
{ "lang": "rust", "repo": "LukasOtter/chipmunk", "path": "/application/apps/indexer-neon/native/src/config.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub out_path: path::PathBuf, pub append: bool, pub tag: String, pub timestamps: bool, }<|fim_prefix|>// repo: LukasOtter/chipmunk path: /application/apps/indexer-neon/native/src/config.rs use std::path; #[derive(Debug)] pub struct Indexi<|fim_middle|>ngThreadConfig { pub in_file: path:...
code_fim
easy
{ "lang": "rust", "repo": "LukasOtter/chipmunk", "path": "/application/apps/indexer-neon/native/src/config.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>air_and_mount; pub use unmount::unmount_device; pub use unpair::unpair_device;<|fim_prefix|>// repo: koompi/imount path: /src/lib.rs pub mod known; pub mod mount; pub mod notification; pub mod pair; pub mod unm<|fim_middle|>ount; pub mod unpair; pub use known::is_known; pub use mount::mount_device; pub ...
code_fim
medium
{ "lang": "rust", "repo": "koompi/imount", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: koompi/imount path: /src/lib.rs pub mod known; pub mod mount; pub mod notification; pub mod pair; pub mod unm<|fim_suffix|>air_and_mount; pub use unmount::unmount_device; pub use unpair::unpair_device;<|fim_middle|>ount; pub mod unpair; pub use known::is_known; pub use mount::mount_device; pub ...
code_fim
medium
{ "lang": "rust", "repo": "koompi/imount", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: iCodeIN/hgrep path: /src/ripgrep.rs max: u64) -> Self { let mut config = Self::default(); config.min_context(min).max_context(max); config } pub fn min_context(&mut self, num: u64) -> &mut Self { self.min_context = num; self } pub fn max...
code_fim
hard
{ "lang": "rust", "repo": "iCodeIN/hgrep", "path": "/src/ripgrep.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if self.multiline { builder.dotall(self.multiline_dotall); } if self.line_regexp { Ok(builder.build(&format!("^(?:{})$", pat))?) } else { Ok(builder.build(pat)?) } } fn build_searcher(&self) -> Searcher { let mut...
code_fim
hard
{ "lang": "rust", "repo": "iCodeIN/hgrep", "path": "/src/ripgrep.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: iCodeIN/hgrep path: /src/ripgrep.rs self } pub fn hidden(&mut self, yes: bool) -> &mut Self { self.hidden = yes; self } pub fn case_insensitive(&mut self, yes: bool) -> &mut Self { self.case_insensitive = yes; if yes { self.smar...
code_fim
hard
{ "lang": "rust", "repo": "iCodeIN/hgrep", "path": "/src/ripgrep.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: johnstonskj/rust-xml_dom_xpath path: /src/xpath1/model/path.rs use crate::xpath1::model::step::Step; use crate::xpath1::model::ToAbbrString; use std::fmt::{Display, Formatter, Result}; use std::slice::Iter; // -------------------------------------------------------------------------------------...
code_fim
hard
{ "lang": "rust", "repo": "johnstonskj/rust-xml_dom_xpath", "path": "/src/xpath1/model/path.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// /// `true` if this path has no steps, otherwise `false`. /// pub fn is_empty(&self) -> bool { self.steps.is_empty() } /// /// Return an iterator over the steps in this path. /// pub fn steps(&self) -> Iter<Step> { self.steps.iter() } path_f...
code_fim
hard
{ "lang": "rust", "repo": "johnstonskj/rust-xml_dom_xpath", "path": "/src/xpath1/model/path.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>stSpace, // ViBusAddress64 destOffset, ViUInt16 destWidth, // ViBusSize srcLength); // ViStatus _VI_FUNC viMoveAsyncEx (ViSession vi, ViUInt16 srcSpace, ViBusAddress64 srcOffset, // ViUInt16 s...
code_fim
hard
{ "lang": "rust", "repo": "menyoung/RusticLab", "path": "/src/visafn.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: menyoung/RusticLab path: /src/visafn.rs :c_char; // VISA functions // They're slowly being ported on an as-needed basis. // /*- Resource Manager Functions and Operations -------------------------------*/ #[link(name = "VISA", kind = "framework")] extern { // ViStatus _VI_FUNC viOpenDefaultRM ...
code_fim
hard
{ "lang": "rust", "repo": "menyoung/RusticLab", "path": "/src/visafn.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>} // Create stream pub fn init_stream( program_id: &Pubkey, accounts: &[AccountInfo], deposit_amount: u64, start_time: u64, end_time: u64 ) -> Result<(), ProgramError> { // Iterating accounts is safer then indexing let accounts_iter = &mut accounts.iter(); // ...
code_fim
hard
{ "lang": "rust", "repo": "tHeMaskedMan981/solana-streams", "path": "/program/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>// Withdraw money from the stream pub fn withdraw( program_id: &Pubkey, accounts: &[AccountInfo], withdraw_amount: u64 ) -> Result<(), ProgramError> { // Iterating accounts is safer then indexing let accounts_iter = &mut accounts.iter(); // Get the accounts let stream_accou...
code_fim
hard
{ "lang": "rust", "repo": "tHeMaskedMan981/solana-streams", "path": "/program/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tHeMaskedMan981/solana-streams path: /program/src/lib.rs use borsh::{BorshDeserialize, BorshSerialize}; use solana_program::{ account_info::{next_account_info, AccountInfo}, entrypoint, msg, entrypoint::ProgramResult, program_error::ProgramError, pubkey::Pubkey, clock...
code_fim
hard
{ "lang": "rust", "repo": "tHeMaskedMan981/solana-streams", "path": "/program/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut world: World<WorldId1> = World::new(); bencher.iter(|| { for _ in range(0usize, 1_000_000usize) { world.create_entity(); } }); } #[bench] fn bench_create_destroy_1mm_entities(bencher: &mut Bencher) { struct WorldI...
code_fim
hard
{ "lang": "rust", "repo": "mtsr/entityx-ecs-rs", "path": "/src/world.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mtsr/entityx-ecs-rs path: /src/world.rs use std::marker::PhantomData; use std::collections::{ BitVec }; use entity::{ EntityManager, Entity, EntityIterator }; use component::{ ComponentManager, ComponentList, ComponentData }; use system::{ SystemManager, System }; // TODO Add Entity Templates ...
code_fim
hard
{ "lang": "rust", "repo": "mtsr/entityx-ecs-rs", "path": "/src/world.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chromium/chromium path: /third_party/rust/winapi/v0_3/crate/src/um/commoncontrols.rs // Licensed under the Apache License, Version 2.0 // <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. // A...
code_fim
hard
{ "lang": "rust", "repo": "chromium/chromium", "path": "/third_party/rust/winapi/v0_3/crate/src/um/commoncontrols.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> punk: *mut IUnknown, ) -> HRESULT, fn GetCallback( riid: REFIID, ppv: *mut *mut c_void, ) -> HRESULT, fn ForceImagePresent( iImage: c_int, dwFlags: DWORD, ) -> HRESULT, fn DiscardImages( iFirstImage: c_int, iLastImage: c_int, ...
code_fim
hard
{ "lang": "rust", "repo": "chromium/chromium", "path": "/third_party/rust/winapi/v0_3/crate/src/um/commoncontrols.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: SnoozeTime/spacegame path: /src/render/ui/text.rs use crate::core::colors::RgbaColor; use crate::core::window::WindowDim; use crate::render::ui::gui::{HorizontalAlign, VerticalAlign}; use crate::resources::Resources; use glyph_brush::rusttype::*; use glyph_brush::BrushError::TextureTooSmall; use...
code_fim
hard
{ "lang": "rust", "repo": "SnoozeTime/spacegame", "path": "/src/render/ui/text.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Self { texture: tex, tess: None, render_state, shader: new_shader(surface), } } pub fn prepare( &mut self, surface: &mut S, text_data: Vec<(Text, glam::Vec2)>, glyph_brush: &mut GlyphBrush<'static, Ins...
code_fim
hard
{ "lang": "rust", "repo": "SnoozeTime/spacegame", "path": "/src/render/ui/text.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn wrapping() { let inner = || format!("{} b {}", Paint::red("a"), Paint::green("c")); let inner2 = || format!("0 {} 1", Paint::magenta(&inner()).wrap()); assert_renders! { Paint::new("text/plain").wrap() => "text/plain", Paint::new(&inner()).wrap() => &inner(), ...
code_fim
hard
{ "lang": "rust", "repo": "mesalock-linux/crates-io", "path": "/vendor/yansi/src/tests.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mesalock-linux/crates-io path: /vendor/yansi/src/tests.rs extern crate parking_lot; use super::Color::*; use super::{Paint, Style}; use self::parking_lot::Mutex; static LOCK: Mutex<()> = Mutex::new(()); macro_rules! assert_renders { ($($input:expr => $expected:expr,)*) => { let _...
code_fim
hard
{ "lang": "rust", "repo": "mesalock-linux/crates-io", "path": "/vendor/yansi/src/tests.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>} impl <W: BlockWrite> TapeWrite for BlockedWriter<W> { fn write_all(&mut self, mut data: &[u8]) -> Result<bool, std::io::Error> { while !data.is_empty() { match self.write(data) { Ok(n) => data = &data[n..], Err(e) => return Err(e), } ...
code_fim
hard
{ "lang": "rust", "repo": "pimox/proxmox-backup", "path": "/src/tape/file_formats/blocked_writer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.bytes_written } /// flush last block, set END_OF_STREAM flag /// /// Note: This may write an empty block just including the /// END_OF_STREAM flag. fn finish(&mut self, incomplete: bool) -> Result<bool, std::io::Error> { vec::clear(&mut self.buffer.payload[sel...
code_fim
hard
{ "lang": "rust", "repo": "pimox/proxmox-backup", "path": "/src/tape/file_formats/blocked_writer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pimox/proxmox-backup path: /src/tape/file_formats/blocked_writer.rs use proxmox::tools::vec; use crate::tape::{ TapeWrite, BlockWrite, file_formats::{ BlockHeader, BlockHeaderFlags, }, }; /// Assemble and write blocks of data /// /// This type implement 'TapeWri...
code_fim
hard
{ "lang": "rust", "repo": "pimox/proxmox-backup", "path": "/src/tape/file_formats/blocked_writer.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fornix-rs/libfornix-neuralnetwork path: /tests/network.rs extern crate libfornix_neuralnetwork; extern crate libfornix; use libfornix_neuralnetwork::*; use libfornix::*; <|fim_suffix|> let mut rng = OsRandomNumberProvider::new().unwrap(); // create test network let mut testTarget =...
code_fim
medium
{ "lang": "rust", "repo": "fornix-rs/libfornix-neuralnetwork", "path": "/tests/network.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert!(testTarget.locate((10, 10)).is_none()); assert!(testTarget.locate_mut((10, 10)).is_none()); assert!(testTarget.locate((0, 0)).is_some()); assert!(testTarget.locate_mut((0, 0)).is_some()); }<|fim_prefix|>// repo: fornix-rs/libfornix-neuralnetwork path: /tests/network.rs extern crat...
code_fim
hard
{ "lang": "rust", "repo": "fornix-rs/libfornix-neuralnetwork", "path": "/tests/network.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: teyvat-dev/parser-rust path: /src/structs/raw/weapon_promote_excel_config_data.rs use crate::structs::raw::common::AddProp; use serde::Deserialize; <|fim_suffix|>#[derive(Deserialize)] #[serde(rename_all = "PascalCase")] pub struct Data { pub weapon_promote_id: usize, pub promote_level:...
code_fim
medium
{ "lang": "rust", "repo": "teyvat-dev/parser-rust", "path": "/src/structs/raw/weapon_promote_excel_config_data.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Deserialize)] #[serde(rename_all = "PascalCase")] pub struct Data { pub weapon_promote_id: usize, pub promote_level: Option<usize>, pub coin_cost: Option<usize>, pub cost_items: Vec<CostItem>, pub add_props: Vec<AddProp>, pub unlock_max_level: usize, pub required_playe...
code_fim
medium
{ "lang": "rust", "repo": "teyvat-dev/parser-rust", "path": "/src/structs/raw/weapon_promote_excel_config_data.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_check_common_substring() { let s1 = String::from("Hello world"); let s2 = String::from("Hello my boy"); let value = lcs(s1, s2); assert_eq!(value, "Hello "); } #[test] fn test_check_common_case_two() { let s1 = String::from("Hell...
code_fim
hard
{ "lang": "rust", "repo": "sourcepirate/crunch", "path": "/src/lcs.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sourcepirate/crunch path: /src/lcs.rs //! Implementation of LCS algorithm. //! Uses Dynamic programming to speed up. //! // runs a longest common substring algorithm pub fn lcs(seq_1: String, seq_2: String) -> String { let seq_vector_one: Vec<char> = seq_1.chars().collect(); let seq_vec...
code_fim
medium
{ "lang": "rust", "repo": "sourcepirate/crunch", "path": "/src/lcs.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/rust-bindgen path: /bindgen-tests/tests/expectations/tests/zero-size-array-align.rs #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] #[repr(C)] #[derive(Default)] pub struct __IncompleteArrayField<T>(::std::marker::PhantomData<T>, [T; 0]); impl<T> __In...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/rust-bindgen", "path": "/bindgen-tests/tests/expectations/tests/zero-size-array-align.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> const UNINIT: ::std::mem::MaybeUninit<dm_deps> = ::std::mem::MaybeUninit::uninit(); let ptr = UNINIT.as_ptr(); assert_eq!( ::std::mem::size_of::<dm_deps>(), 8usize, concat!("Size of: ", stringify!(dm_deps)), ); assert_eq!( ::std::mem::align_of::<dm_deps>...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/rust-bindgen", "path": "/bindgen-tests/tests/expectations/tests/zero-size-array-align.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>impl From<std::str::Utf8Error> for Error { fn from(err: std::str::Utf8Error) -> Self { Error::IOError(err.to_string()) } } impl From<serde_json::Error> for Error { fn from(err: serde_json::Error) -> Self { Error::QueryError(err.to_string()) } } pub type Result<T> = std::r...
code_fim
hard
{ "lang": "rust", "repo": "awesome-archive/Toshi", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: awesome-archive/Toshi path: /src/lib.rs use failure::Fail; use tantivy::query::QueryParserError; use tantivy::schema::DocParsingError; use tantivy::TantivyError; #[derive(Debug, Fail, Clone)] pub enum Error { #[fail(display = "IO Error: {}", _0)] IOError(String), #[fail(display = "U...
code_fim
hard
{ "lang": "rust", "repo": "awesome-archive/Toshi", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: shinomontaz/splitter path: /src/main.rs extern crate serde; #[macro_use] extern crate serde_derive; extern crate serde_json; use std::fs; extern crate hyper; extern crate iron; use std::collections::HashMap; use iron::prelude::*; use iron::Handler; use iron::StatusCode; <|fim_suffix|> fo...
code_fim
hard
{ "lang": "rust", "repo": "shinomontaz/splitter", "path": "/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let address = format!("127.0.0.1:{}", cfg.port); println!("\n{:?} \n\n-----------", address); let listener = TcpListener::bind(address).unwrap(); for stream in listener.incoming() { let stream = stream.unwrap(); println!("Connection established!"); } }<|fim_prefix|...
code_fim
hard
{ "lang": "rust", "repo": "shinomontaz/splitter", "path": "/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let listener = TcpListener::bind(address).unwrap(); for stream in listener.incoming() { let stream = stream.unwrap(); println!("Connection established!"); } }<|fim_prefix|>// repo: shinomontaz/splitter path: /src/main.rs extern crate serde; #[macro_use] extern crate serde_de...
code_fim
medium
{ "lang": "rust", "repo": "shinomontaz/splitter", "path": "/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: carlosmizabi/mandala path: /nodes/src/values/boolean_value.rs use std::collections::HashMap; use crate::nodes::{Node, Nodal, Valuable}; pub struct BooleanValue { value: bool, node: Node, } impl BooleanValue { pub fn new(value: bool, node: Node) -> BooleanValue { BooleanValu...
code_fim
medium
{ "lang": "rust", "repo": "carlosmizabi/mandala", "path": "/nodes/src/values/boolean_value.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let cases = hashmap! { true => BooleanValue::from_value(true), false => BooleanValue::from_value(false) }; for case in cases { assert_eq!(case.0, *case.1.get_value()) } } }<|fim_prefix|>// repo: carlosmizabi/mandala path: /nodes/src/...
code_fim
medium
{ "lang": "rust", "repo": "carlosmizabi/mandala", "path": "/nodes/src/values/boolean_value.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Narfinger/toggl-rs path: /toggl_rs/src/user.rs use crate::auth::InitResponse; use crate::workspace::Workspace; use std::rc::Rc; #[derive(Debug)] pub struct User { pub fullname: String, pub workspaces: Vec<Rc<Workspace>>, } <|fim_suffix|> User { fullname: i.data.fulln...
code_fim
medium
{ "lang": "rust", "repo": "Narfinger/toggl-rs", "path": "/toggl_rs/src/user.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl From<InitResponse> for User { fn from(i: InitResponse) -> User { User { fullname: i.data.fullname, workspaces: i.data.workspaces.into_iter().map(Rc::new).collect(), } } }<|fim_prefix|>// repo: Narfinger/toggl-rs path: /toggl_rs/src/user.rs use crate::a...
code_fim
medium
{ "lang": "rust", "repo": "Narfinger/toggl-rs", "path": "/toggl_rs/src/user.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dashscript/dashscript path: /core/src/runtime/core/builtin.rs r}; use super::date::{self, UNIX_EPOCH_DATE}; fn random_isize() -> isize { let mut random: isize = SystemTime::now() .duration_since(UNIX_EPOCH) .unwrap() .as_millis() as isize; let mut rand = || { ...
code_fim
hard
{ "lang": "rust", "repo": "dashscript/dashscript", "path": "/core/src/runtime/core/builtin.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dashscript/dashscript path: /core/src/runtime/core/builtin.rs temTime::now() .duration_since(UNIX_EPOCH) .unwrap() .as_millis() as isize; let mut rand = || { random ^= random << 13; random ^= random >> 17; random ^= random << 5; random...
code_fim
hard
{ "lang": "rust", "repo": "dashscript/dashscript", "path": "/core/src/runtime/core/builtin.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> instance.properties.insert(vm.constants.__date, (Value::Int(date::ymd_into_date(year, month, date)), false)); Ok(Value::Null) }, _ => Err(RuntimeError::new(vm, "[Date.setDate]: Expected (Date, int) arguments.")) } }); date.prototype_...
code_fim
hard
{ "lang": "rust", "repo": "dashscript/dashscript", "path": "/core/src/runtime/core/builtin.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Creates database tables pub fn create_tables(conn: &Connection) -> Result<(), Error> { let queries = ["CREATE TABLE crates ( id SERIAL PRIMARY KEY, name VARCHAR(255) UNIQUE NOT NULL, latest_version_id INT DEFAULT 0, ...
code_fim
hard
{ "lang": "rust", "repo": "vaidehijoshi/docs.rs", "path": "/src/db/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Creates database tables pub fn create_tables(conn: &Connection) -> Result<(), Error> { let queries = ["CREATE TABLE crates ( id SERIAL PRIMARY KEY, name VARCHAR(255) UNIQUE NOT NULL, latest_version_id INT DEFAULT 0, ...
code_fim
hard
{ "lang": "rust", "repo": "vaidehijoshi/docs.rs", "path": "/src/db/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vaidehijoshi/docs.rs path: /src/db/mod.rs //! Database operations pub use self::add_package::add_package_into_database; pub use self::add_package::add_build_into_database; pub use self::file::add_path_into_database; use postgres::{Connection, TlsMode}; use postgres::error::{Error, ConnectError...
code_fim
hard
{ "lang": "rust", "repo": "vaidehijoshi/docs.rs", "path": "/src/db/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: adambudziak/blisspaper path: /src/bliss.rs use log::{error, info, warn}; use std::fs::DirEntry; use crate::fetch::unsplash::{CollectionEndpoint, PhotoSource}; use crate::store::Store; use crate::wallpaper::WallpaperAndScreensaver; use reqwest::Url; pub struct Bliss { manager: Box<dyn Wallp...
code_fim
hard
{ "lang": "rust", "repo": "adambudziak/blisspaper", "path": "/src/bliss.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> PhotoSource::new(self.endpoint.clone().into_pages_iterator(client.clone())) .into_iter() .filter(move |url| !self.store.contains(&url)) } pub fn run(&mut self) { let sleep_duration = std::time::Duration::from_secs(self.changerate); let client = reqw...
code_fim
hard
{ "lang": "rust", "repo": "adambudziak/blisspaper", "path": "/src/bliss.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let log_names = rosrust::param("~log_names").unwrap().get().unwrap_or(false); rosrust::ros_info!("Starting tiger_car"); let steering = Arc::new(Mutex::new( DualSoftwarePwm::new( STEERING_PWM0, STEERING_PWM1, STEERING_PWM_FREQ, STEERING_...
code_fim
hard
{ "lang": "rust", "repo": "iCodeIN/tiger-car", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: iCodeIN/tiger-car path: /src/lib.rs /* Copyright (C) 2020 Dylan Staatz - All Rights Reserved. */ // `error_chain!` can recurse deeply #![recursion_limit = "1024"] #[macro_use] extern crate error_chain; mod errors; mod pwm; ///////////////////////////////////////////////////////////////////...
code_fim
hard
{ "lang": "rust", "repo": "iCodeIN/tiger-car", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut drivetrain = DualSoftwarePwm::new( DRIVETRAIN_PWM0, DRIVETRAIN_PWM1, DRIVETRAIN_PWM_FREQ, DRIVETRAIN_MIN_DUTY_CYCLE, false, ).unwrap(); for i in -5..6 { let val = 0.05 * i as f64; println!("Setting {:.2}", val); drivetrai...
code_fim
hard
{ "lang": "rust", "repo": "iCodeIN/tiger-car", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }