text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: WieslawRotter/AoC2019 path: /day1/src/main.rs fn main() { let puzzle = [ 66016, 85415, 51706, 96238, 62503, 61186, 119728, 69237, 54386, 137211, 65936, 129665, 104711, 121892, 54525, 124849, 69572, 105755, 101883, 62077, 50281, 50495, 95260, 132134, 70793, 73917, 8949...
code_fim
hard
{ "lang": "rust", "repo": "WieslawRotter/AoC2019", "path": "/day1/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn fuel_count(mass: i32) -> i32 { let base_fuel = mass / 3 - 2; let fuel = if base_fuel <= 0 { 0 } else { base_fuel + fuel_count(base_fuel) }; return fuel; }<|fim_prefix|>// repo: WieslawRotter/AoC2019 path: /day1/src/main.rs fn main() { let puzzle = [ 6601...
code_fim
medium
{ "lang": "rust", "repo": "WieslawRotter/AoC2019", "path": "/day1/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[cfg(debug_assertions)] { env::set_var("RUST_LOG", "actix_web=debug"); env::set_var("RUST_BACKTRACE", "0"); env_logger::init(); } let sys = actix::System::new("ultimate"); let _addr = server::new(|| app::create_app()) .bind("127.0.0.1:8000") .expec...
code_fim
medium
{ "lang": "rust", "repo": "koshkin-kna/actix-web-learn", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: koshkin-kna/actix-web-learn path: /src/main.rs extern crate actix; extern crate actix_web; extern crate actix_web_ult; extern crate env_logger; extern crate regex; #[macro_use] extern crate tera; use actix_web::server; <|fim_suffix|>pub mod app; pub mod urls; pub mod views; fn main() { #...
code_fim
medium
{ "lang": "rust", "repo": "koshkin-kna/actix-web-learn", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub mod app; pub mod urls; pub mod views; fn main() { #[cfg(debug_assertions)] { env::set_var("RUST_LOG", "actix_web=debug"); env::set_var("RUST_BACKTRACE", "0"); env_logger::init(); } let sys = actix::System::new("ultimate"); let _addr = server::new(|| app::creat...
code_fim
medium
{ "lang": "rust", "repo": "koshkin-kna/actix-web-learn", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> &self.0 } } #[doc = "Field `lo_vco_freq_cw_2424` writer - "] pub struct LO_VCO_FREQ_CW_2424_W<'a> { w: &'a mut W, } impl<'a> LO_VCO_FREQ_CW_2424_W<'a> { #[doc = r"Writes raw bits to the field"] #[inline(always)] pub unsafe fn bits(self, value: u8) -> &'a mut W { self.w....
code_fim
hard
{ "lang": "rust", "repo": "username223/bl602-pac", "path": "/src/rf/lo_cal_ctrl_hw3.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> &self.0 } } #[doc = "Field `lo_vco_idac_cw_2420` writer - "] pub struct LO_VCO_IDAC_CW_2420_W<'a> { w: &'a mut W, } impl<'a> LO_VCO_IDAC_CW_2420_W<'a> { #[doc = r"Writes raw bits to the field"] #[inline(always)] pub unsafe fn bits(self, value: u8) -> &'a mut W { self.w....
code_fim
hard
{ "lang": "rust", "repo": "username223/bl602-pac", "path": "/src/rf/lo_cal_ctrl_hw3.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: username223/bl602-pac path: /src/rf/lo_cal_ctrl_hw3.rs #[doc = "Register `lo_cal_ctrl_hw3` reader"] pub struct R(crate::R<LO_CAL_CTRL_HW3_SPEC>); impl core::ops::Deref for R { type Target = crate::R<LO_CAL_CTRL_HW3_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Target { &...
code_fim
hard
{ "lang": "rust", "repo": "username223/bl602-pac", "path": "/src/rf/lo_cal_ctrl_hw3.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>/// Output solution for part 2. fn part2() { let start = Instant::now(); let rules = Rules::read_from_file("input/input.txt").unwrap(); let gen_time = start.elapsed(); let count = rules.contained_by("shiny gold"); let run_time = start.elapsed() - gen_time; println!("Day 7 - Part 2 ...
code_fim
hard
{ "lang": "rust", "repo": "bjnord/coding_practice", "path": "/advent-2020/day-07/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bjnord/coding_practice path: /advent-2020/day-07/src/main.rs use day_07::Rules; use std::time::Instant; fn main() { part1(); part2(); } /// Output solution for part 1. fn part1() { <|fim_suffix|> let start = Instant::now(); let rules = Rules::read_from_file("input/input.txt").un...
code_fim
hard
{ "lang": "rust", "repo": "bjnord/coding_practice", "path": "/advent-2020/day-07/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn partition(nums: &mut [i32], offset: usize) -> (usize, usize) { let target = nums[0]; let mut begin = 0; // The begin of eq. let mut end = 1; // The end of eq. for idx in 1..nums.len() { if nums[idx] == target { nums.swap(idx, end); end += 1; } else if n...
code_fim
hard
{ "lang": "rust", "repo": "pourplusquoi/learn-rust", "path": "/leetcode/215.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pourplusquoi/learn-rust path: /leetcode/215.rs impl Solution_QuickSelect_TwoWay { pub fn find_kth_largest(mut nums: Vec<i32>, k: i32) -> i32 { let mut lo = 0; let mut hi = nums.len(); let mut idx = (k - 1) as usize; while (lo < hi) { let pivot = lo + Self::partition(&mut ...
code_fim
hard
{ "lang": "rust", "repo": "pourplusquoi/learn-rust", "path": "/leetcode/215.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let target = nums[0]; let mut begin = 0; // The begin of eq. let mut end = 1; // The end of eq. for idx in 1..nums.len() { if nums[idx] == target { nums.swap(idx, end); end += 1; } else if nums[idx] > target { nums.swap(idx, begin); nums.swap...
code_fim
hard
{ "lang": "rust", "repo": "pourplusquoi/learn-rust", "path": "/leetcode/215.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-onig/rust-onig path: /onig/examples/sql.rs use onig::*; fn main() { let mut syntax = Syntax::default().clone(); syntax.set_operators(SyntaxOperator::SYNTAX_OPERATOR_VARIABLE_META_CHARACTERS); syntax.set_behavior(SyntaxBehavior::empty()); syntax.set_options(RegexOptions::RE...
code_fim
medium
{ "lang": "rust", "repo": "rust-onig/rust-onig", "path": "/onig/examples/sql.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match reg.captures("a_abcabcabc\\ppzz") { Some(caps) => { println!("match at {}", caps.offset()); for (i, cap) in caps.iter_pos().enumerate() { match cap { Some(pos) => println!("{}: {:?}", i, pos), None => println...
code_fim
medium
{ "lang": "rust", "repo": "rust-onig/rust-onig", "path": "/onig/examples/sql.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mgottschlag/rp2040-pac path: /src/usbctrl_dpram/ep_buffer_control.rs 3 << 27)) | ((value as u32 & 0x03) << 27); self.w } } #[doc = "Field `AVAILABLE_1` reader - Buffer 1 is available. This bit is set to indicate the buffer can be used by the controller. The controller clears the avai...
code_fim
hard
{ "lang": "rust", "repo": "mgottschlag/rp2040-pac", "path": "/src/usbctrl_dpram/ep_buffer_control.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mgottschlag/rp2040-pac path: /src/usbctrl_dpram/ep_buffer_control.rs for PID_1_R { type Target = crate::FieldReader<bool, bool>; #[inline(always)] fn deref(&self) -> &Self::Target { &self.0 } } #[doc = "Field `PID_1` writer - The data pid of buffer 1."] pub struct PID_1_...
code_fim
hard
{ "lang": "rust", "repo": "mgottschlag/rp2040-pac", "path": "/src/usbctrl_dpram/ep_buffer_control.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> &self.0 } } #[doc = "Field `LAST_0` writer - Buffer 0 is the last buffer of the transfer."] pub struct LAST_0_W<'a> { w: &'a mut W, } impl<'a> LAST_0_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[...
code_fim
hard
{ "lang": "rust", "repo": "mgottschlag/rp2040-pac", "path": "/src/usbctrl_dpram/ep_buffer_control.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: saschazar21/wasm-rav1e path: /src/alpha.rs use rgb::{ RGB, RGBA }; pub fn fill_alp<|fim_suffix|>ap(|p| p.alpha(255)) .collect(); }<|fim_middle|>ha(pixels: &[RGB<u8>]) -> Vec<RGBA<u8>> { return pixels .iter() .m
code_fim
medium
{ "lang": "rust", "repo": "saschazar21/wasm-rav1e", "path": "/src/alpha.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>ap(|p| p.alpha(255)) .collect(); }<|fim_prefix|>// repo: saschazar21/wasm-rav1e path: /src/alpha.rs use rgb::{ RGB, RGBA }; pub fn fill_alp<|fim_middle|>ha(pixels: &[RGB<u8>]) -> Vec<RGBA<u8>> { return pixels .iter() .m
code_fim
medium
{ "lang": "rust", "repo": "saschazar21/wasm-rav1e", "path": "/src/alpha.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: arash-hacker/pt-rs path: /src/matrix.rs use crate::bbox::*; use crate::vector::*; use crate::ray::*; use crate::bbox::*; use crate::shape::*; use crate::material::*; use crate::sdf::*; use crate::hit::*; use crate::vector::*; use crate::triangle::*; use crate::tree::*; use crate::axis::*; use cr...
code_fim
hard
{ "lang": "rust", "repo": "arash-hacker/pt-rs", "path": "/src/matrix.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn Transpose(&self)-> Matrix { return Matrix{ x00:self.x00,x01: self.x10,x02: self.x20,x03: self.x30, x10:self.x01,x11: self.x11,x12: self.x21,x13: self.x31, x20:self.x02,x21: self.x12,x22: self.x22,x23: self.x32, x30:self.x03,x31: self.x13,x32: self.x23,x33: self.x33} } pub fn Dete...
code_fim
hard
{ "lang": "rust", "repo": "arash-hacker/pt-rs", "path": "/src/matrix.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> //right wall scene.triangles.push(Triangle { base: Vector{x: 1f32, y: 1f32, z: 2f32}, v1: Vector{x: 0f32, y: 0f32, z: -2f32}, v2: Vector{x: 0f32, y: -2f32, z: 0f32}, material: Material { diffuse_color: Color { r: 0f32, g: 0f32, b: 0.9f32, }, }, }); scene.triangles....
code_fim
hard
{ "lang": "rust", "repo": "Koen-de-Mare/Raytracer", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Koen-de-Mare/Raytracer path: /src/main.rs // om te checken; C-c C-c (twee keer caps-lock + c) // voor andere rust commands; M-x met rust-check, rust-compile, rust-test, rust-run extern crate image; extern crate rand; mod vector; mod color; mod triangle; mod surface_element; mod sphere; mod cam...
code_fim
hard
{ "lang": "rust", "repo": "Koen-de-Mare/Raytracer", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gamsb/nettu-scheduler path: /scheduler/clients/rust/src/base.rs use reqwest::{Client, Method, RequestBuilder, Response, StatusCode}; use serde::{Deserialize, Serialize}; pub(crate) struct BaseClient { address: String, api_key: Option<String>, } #[derive(Debug)] pub enum APIErrorVariant...
code_fim
hard
{ "lang": "rust", "repo": "gamsb/nettu-scheduler", "path": "/scheduler/clients/rust/src/base.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub async fn delete<T: for<'de> Deserialize<'de>>( &self, path: String, expected_status_code: StatusCode, ) -> APIResponse<T> { let res = match self.get_client(Method::DELETE, path).send().await { Ok(res) => res, Err(_) => return Err(self.net...
code_fim
hard
{ "lang": "rust", "repo": "gamsb/nettu-scheduler", "path": "/scheduler/clients/rust/src/base.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: brayniac/pelikan path: /src/proxy/momento/src/protocol/resp/set.rs // Copyright 2022 Twitter, Inc. // Licensed under the Apache License, Version 2.0 // http://www.apache.org/licenses/LICENSE-2.0 use std::time::Duration; use momento::SimpleCacheClient; use protocol_memcache::{SET, SET_EX, SET_S...
code_fim
hard
{ "lang": "rust", "repo": "brayniac/pelikan", "path": "/src/proxy/momento/src/protocol/resp/set.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub async fn set( client: &mut SimpleCacheClient, cache_name: &str, response_buf: &mut Vec<u8>, req: &Set, ) -> ProxyResult { update_method_metrics(&SET, &SET_EX, async move { let ttl = match req.expire_time() { Some(protocol_resp::ExpireTime::Seconds(v)) => Some(Du...
code_fim
hard
{ "lang": "rust", "repo": "brayniac/pelikan", "path": "/src/proxy/momento/src/protocol/resp/set.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let _response = match tokio::time::timeout( Duration::from_millis(200), client.set(cache_name, req.key(), req.value(), ttl), ) .await { Ok(Ok(r)) => r, Ok(Err(e)) => { klog_set( &req.key(), ...
code_fim
hard
{ "lang": "rust", "repo": "brayniac/pelikan", "path": "/src/proxy/momento/src/protocol/resp/set.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: JonShort/rust-exercises path: /integer-list-information/src/main.rs extern crate rand; use std::collections::HashMap; use rand::Rng; use std::time::{Instant}; fn main() { let now = Instant::now(); let mut rng = rand::thread_rng(); // populate a Vec with random numbers let amo...
code_fim
hard
{ "lang": "rust", "repo": "JonShort/rust-exercises", "path": "/integer-list-information/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> numbers.iter().for_each(|num| { let count = map.entry(num).or_insert(0); *count += 1; }); let most_frequent_number = map .into_iter() .max_by_key(|&(_, count)| count) .map(|(value, _)| *value) .unwrap(); most_frequent_number }<|fim_prefix|>...
code_fim
hard
{ "lang": "rust", "repo": "JonShort/rust-exercises", "path": "/integer-list-information/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn view(&self) -> Html { return html! { <div> <ul> { for self.todos.iter().enumerate().map(|e| self.view_todo(e)) } </ul> </div> }; } fn rendered(&mut self, _first_render: bool) { if _first_ren...
code_fim
hard
{ "lang": "rust", "repo": "torounit/rust-todo-app", "path": "/frontend/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> return html! { <div> <ul> { for self.todos.iter().enumerate().map(|e| self.view_todo(e)) } </ul> </div> }; } fn rendered(&mut self, _first_render: bool) { if _first_render { self.update...
code_fim
hard
{ "lang": "rust", "repo": "torounit/rust-todo-app", "path": "/frontend/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: torounit/rust-todo-app path: /frontend/src/main.rs use serde::Deserialize; use yew::{ format::{Json, Nothing}, prelude::*, services::fetch::{FetchService, FetchTask, Request, Response}, }; use Msg::*; #[derive(Deserialize, Debug, Clone)] pub struct Todo { pub id: i32, pub co...
code_fim
hard
{ "lang": "rust", "repo": "torounit/rust-todo-app", "path": "/frontend/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> use super::*; #[test] fn test_serialize_and_deserialize_item() { let item = Item::new(String::from("k"), String::from("v")); assert_eq!(item.key(), &String::from("k")); assert_eq!(item.val(), &String::from("v")); let decoded: Item = Item::from_json(&item.to_js...
code_fim
hard
{ "lang": "rust", "repo": "boingram/fortinbras", "path": "/src/model/item.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: boingram/fortinbras path: /src/model/item.rs include!(concat!(env!("OUT_DIR"), "/serde_types.rs")); use serde_json; use serde_json::de; use serde_json::ser; /// Implements the Item struct defined in src/serde_types.in.rs /// (thanks serde youre the best) impl Item { /// Constructs a new it...
code_fim
hard
{ "lang": "rust", "repo": "boingram/fortinbras", "path": "/src/model/item.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wcpannell/SKEAZN642 path: /src/ftmrh.rs #[doc = r"Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - Flash Clock Divider Register"] pub fclkdiv: crate::Reg<fclkdiv::FCLKDIV_SPEC>, #[doc = "0x01 - Flash Security Register"] pub fsec: crate::Reg<fsec::FSEC_SPEC>,...
code_fim
hard
{ "lang": "rust", "repo": "wcpannell/SKEAZN642", "path": "/src/ftmrh.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>EC>`"] pub type FCCOBIX = crate::Reg<fccobix::FCCOBIX_SPEC>; #[doc = "Flash CCOB Index Register"] pub mod fccobix; #[doc = "FCNFG register accessor: an alias for `Reg<FCNFG_SPEC>`"] pub type FCNFG = crate::Reg<fcnfg::FCNFG_SPEC>; #[doc = "Flash Configuration Register"] pub mod fcnfg; #[doc = "FERCNFG regi...
code_fim
hard
{ "lang": "rust", "repo": "wcpannell/SKEAZN642", "path": "/src/ftmrh.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: christopherwebb/rust_ray_tracer path: /src/main.rs use std::f32; use std::io::{self, Read}; use std::sync::{Arc, mpsc}; use std::thread; use std::time::Instant; use rand::thread_rng; use rand::Rng; use clap::{Arg, App}; use indicatif::{HumanDuration, ProgressBar, ProgressStyle}; use console::s...
code_fim
hard
{ "lang": "rust", "repo": "christopherwebb/rust_ray_tracer", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let n_x : u32 = matches.value_of("width").unwrap().parse::<u32>().unwrap(); let n_y : u32 = matches.value_of("height").unwrap().parse::<u32>().unwrap(); // eprintln!( // "{} Parsing scene...", // style("[1/2]").bold().dim(), // ); // let mut buffer = String::new(); ...
code_fim
hard
{ "lang": "rust", "repo": "christopherwebb/rust_ray_tracer", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let cur_row_w = rows.last().unwrap().w ; let cur_row_h = rows.last().unwrap().h; let cur_row_vertical = rows.last().unwrap().vertical; if cur_row_vertical { // create new horizontal row new_row_x += cur_row_w; ...
code_fim
hard
{ "lang": "rust", "repo": "DRiKE/zesplot", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn push(&mut self, mut area: Area) -> () { if self.vertical { area.x = self.x; } else { area.y = self.y; } &self.areas.push(area); self.reflow(); } fn area(&self) -> f64 { self.areas.iter().fold(0.0, |mut s, a| {s += a.s...
code_fim
hard
{ "lang": "rust", "repo": "DRiKE/zesplot", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DRiKE/zesplot path: /src/main.rs #![feature(i128, i128_type)] extern crate svg; extern crate ipnetwork; extern crate rand; #[macro_use] extern crate clap; use clap::{Arg, App}; use svg::*; use svg::node::Text as Tekst; use svg::node::element::{Rectangle, Circle, Text, Group}; use ipnetwork::...
code_fim
hard
{ "lang": "rust", "repo": "DRiKE/zesplot", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn download_input(day: u8) -> AdventResult<String> { let url = &format!("https://adventofcode.com/2019/day/{:02}/input", day); let input = reqwest::blocking::Client::new() .get(url) .header("cookie", "session=[SESSION_ID]") .send()? .text() .map_err(Adve...
code_fim
hard
{ "lang": "rust", "repo": "WhoisDavid/advent2019", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: WhoisDavid/advent2019 path: /src/lib.rs pub mod intcode; use std::{error, fmt, fs, num, str::FromStr}; #[derive(Debug)] pub enum AdventError { Request(reqwest::Error), Parse(std::num::ParseIntError), InvalidValue, Infallible(std::convert::Infallible), IoError(std::io::Error...
code_fim
hard
{ "lang": "rust", "repo": "WhoisDavid/advent2019", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: minalear/mingen path: /src/theme/mod.rs use std::fs; use std::path::Path; use std::io::Write; pub struct Theme { name: String, css: String } impl Theme { pub fn default() -> Result<Theme, Box<dyn std::error::Error>> { Ok(Theme { name: String::from("default"), css: String...
code_fim
hard
{ "lang": "rust", "repo": "minalear/mingen", "path": "/src/theme/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for dir in directories.iter() { fs::create_dir(dir)?; } let mut css = fs::File::create(theme_dir.join("styles/theme.css"))?; css.write(self.css.as_bytes())?; Ok(()) } }<|fim_prefix|>// repo: minalear/mingen path: /src/theme/mod.rs use std::fs; use std::path::Path; use std::i...
code_fim
hard
{ "lang": "rust", "repo": "minalear/mingen", "path": "/src/theme/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ShoshinX/RayTracing path: /src/main.rs // Question:What does this mean? use std::io::{self,Write}; use std::ops; mod vec3; mod color; mod ray; mod hittable; mod sphere; mod hittable_list; mod rtweekend; mod camera; mod material; fn random_scene() -> hittable_list::hittable_list { let mut wo...
code_fim
hard
{ "lang": "rust", "repo": "ShoshinX/RayTracing", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // World let mut world = random_scene(); // Camera let lookfrom = vec3::point3{e:[13.0,2.0,3.0]}; let lookat = vec3::point3{e:[0.0,0.0,0.0]}; let vup = vec3::vec3{e:[0.0,1.0,0.0]}; let dist_to_focus = 10.0; let aperture = 0.1; let cam = camera::camera::new(lookfrom,lo...
code_fim
hard
{ "lang": "rust", "repo": "ShoshinX/RayTracing", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ce8so9/embly path: /embly-rs/src/lib.rs //! Embly is a serverless webassembly runtime. It runs small isolated functions. //! Functions can do a handful of things: //! //! - Receive bytes //! - Send bytes //! - Spawn a new function //! //! This library is used to access embly functionality from w...
code_fim
hard
{ "lang": "rust", "repo": "ce8so9/embly", "path": "/embly-rs/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Check for available events if we've never polled before, block // indefinitely if we have let timeout = if self.polled { None } else { self.polled = true; Some(time::Duration::new(0, 0)) }; let ids = events(timeout).exp...
code_fim
hard
{ "lang": "rust", "repo": "ce8so9/embly", "path": "/embly-rs/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(not(target_arch = "wasm32"))] unsafe fn _spawn(_name: *const u8, _name_len: u32, id: *mut i32) -> u16 { // lie and say the spawn id is 1 *id = 1; 0 } fn read(id: i32, payload: &mut [u8]) -> io::Result<usize> { let mut ln: i32 = 0; let ln_ptr: *mut i32 = &mut ln; error::wasi_...
code_fim
hard
{ "lang": "rust", "repo": "ce8so9/embly", "path": "/embly-rs/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> (0..n).map(|_| None).collect() } fn main() { let _ = (foo(10), foo(32)); }<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/issues/issue-34427.rs // run-pass // Issue #34427: On ARM, the code in `foo` at one time was generating // a machine code instruction of the form: `...
code_fim
medium
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/issues/issue-34427.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/issues/issue-34427.rs // run-pass // Issue #34427: On ARM, the code in `foo` at one time was generating // a machine code instruction of the form: `str r0, [r0, rN]!` (for // some N), which is not legal because the source register and base // re...
code_fim
medium
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/issues/issue-34427.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>puts contain toCKB cell"); verify_since_by_value(SINCE_WITHDRAW_PLEDGE)?; verify_capacity_with_value(input_toCKB_data, PLEDGE) }<|fim_prefix|>// repo: D-DLTEO/force-bridge-btc path: /contracts/toCKB-typescript/src/switch/withdraw_pledge/mod.rs use crate::switch::ToCKBCellDataTuple; use crate::uti...
code_fim
hard
{ "lang": "rust", "repo": "D-DLTEO/force-bridge-btc", "path": "/contracts/toCKB-typescript/src/switch/withdraw_pledge/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: D-DLTEO/force-bridge-btc path: /contracts/toCKB-typescript/src/switch/withdraw_pledge/mod.rs use crate::switch::ToCKBCellDataTuple; use crate::utils::config::{PLEDGE, SINCE_WITHDRAW_PLEDGE}; use crate::utils::types::Error; use crate::utils::verifier::{verify_capacity_with_value, verify_since_by_...
code_fim
medium
{ "lang": "rust", "repo": "D-DLTEO/force-bridge-btc", "path": "/contracts/toCKB-typescript/src/switch/withdraw_pledge/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>ToCKBCellDataTuple) -> Result<(), Error> { let input_toCKB_data = toCKB_data_tuple .0 .as_ref() .expect("inputs contain toCKB cell"); verify_since_by_value(SINCE_WITHDRAW_PLEDGE)?; verify_capacity_with_value(input_toCKB_data, PLEDGE) }<|fim_prefix|>// repo: D-DLTEO/forc...
code_fim
medium
{ "lang": "rust", "repo": "D-DLTEO/force-bridge-btc", "path": "/contracts/toCKB-typescript/src/switch/withdraw_pledge/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mincheolsung/libhermit-rs path: /src/drivers/net/uhyve.rs // Copyright (c) 2019 Stefan Lankes, RWTH Aachen University // // Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or // http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or // http://opensource.org/li...
code_fim
hard
{ "lang": "rust", "repo": "mincheolsung/libhermit-rs", "path": "/src/drivers/net/uhyve.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> irq::enable(); Ok(nic) } #[cfg(target_arch = "x86_64")] extern "x86-interrupt" fn uhyve_irqhandler(_stack_frame: &mut ExceptionStackFrame) { debug!("Receive network interrupt from uhyve"); crate::drivers::net::uhyve_set_polling(true); apic::eoi(); core_scheduler().scheduler(); }<|fim_prefix|>// re...
code_fim
hard
{ "lang": "rust", "repo": "mincheolsung/libhermit-rs", "path": "/src/drivers/net/uhyve.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Install interrupt handler irq_install_handler(UHYVE_IRQ_NET, uhyve_irqhandler as usize); irq::enable(); Ok(nic) } #[cfg(target_arch = "x86_64")] extern "x86-interrupt" fn uhyve_irqhandler(_stack_frame: &mut ExceptionStackFrame) { debug!("Receive network interrupt from uhyve"); crate::drivers::...
code_fim
hard
{ "lang": "rust", "repo": "mincheolsung/libhermit-rs", "path": "/src/drivers/net/uhyve.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let mut guess = String::new(); stdin().read_line(&mut guess).expect("Failed to read line"); let guess: u32 = match guess.trim().parse() { Ok(num) => num, Err(_) => { println!("[ERROR] Please input a number"); continue; ...
code_fim
hard
{ "lang": "rust", "repo": "WillHalloward/rust_learning", "path": "/Rust Learning/guess_number/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: WillHalloward/rust_learning path: /Rust Learning/guess_number/src/main.rs use rand::Rng; use std::cmp::Ordering; use std::io::stdin; use std::fs; fn main() { println!("Guess the number!"); const MIN: u32 = 1; const MAX: u32 = 101; let data = fs::read_to_string("C:\\Users\\Turb...
code_fim
hard
{ "lang": "rust", "repo": "WillHalloward/rust_learning", "path": "/Rust Learning/guess_number/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.entities.offset(place_value) } } #[inline(always)] fn insert_if_zero_key( &mut self, key: &Key, hash_value: u64, inserted: &mut bool, ) -> Option<*mut Entity> { if key.is_zero() { return match self.zero_entity { ...
code_fim
hard
{ "lang": "rust", "repo": "r-asou/databend", "path": "/query/src/common/hashtable/hash_table.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: r-asou/databend path: /query/src/common/hashtable/hash_table.rs // Copyright 2020 Datafuse Labs. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://w...
code_fim
hard
{ "lang": "rust", "repo": "r-asou/databend", "path": "/query/src/common/hashtable/hash_table.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Realloc memory if new_grower.max_size() > self.grower.max_size() { let new_size = (new_grower.max_size() as usize) * std::mem::size_of::<Entity>(); let layout = Layout::from_size_align_unchecked(new_size, std::mem::align_of::<Entity>()); ...
code_fim
hard
{ "lang": "rust", "repo": "r-asou/databend", "path": "/query/src/common/hashtable/hash_table.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-rosetta/rust-rosetta path: /tasks/string-length/src/main.rs fn main() { let name = String::fro<|fim_suffix|>{}", name.len()); println!("character count: {}", name.chars().count()); }<|fim_middle|>m("møøse"); println!("bytes count:
code_fim
easy
{ "lang": "rust", "repo": "rust-rosetta/rust-rosetta", "path": "/tasks/string-length/src/main.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|>er count: {}", name.chars().count()); }<|fim_prefix|>// repo: rust-rosetta/rust-rosetta path: /tasks/string-length/src/main.rs fn main() { let name = String::from("møøse"); println!("bytes count: <|fim_middle|>{}", name.len()); println!("charact
code_fim
easy
{ "lang": "rust", "repo": "rust-rosetta/rust-rosetta", "path": "/tasks/string-length/src/main.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|>{refresh, RefreshError, ValidationError as RefreshValidationError}; pub use sign_out::{sign_out, SignOutError, ValidationError as SignOutValidationError};<|fim_prefix|>// repo: Divoolej/mapy-nageografiepl-be path: /app/src/services/teachers/sessions/mod.rs pub mod sign_in; pub mod refresh; pub mod sign_o...
code_fim
medium
{ "lang": "rust", "repo": "Divoolej/mapy-nageografiepl-be", "path": "/app/src/services/teachers/sessions/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Divoolej/mapy-nageografiepl-be path: /app/src/services/teachers/sessions/mod.rs pub mod sign_in; pub mod refresh; pub mod sign_out; pub use sign_in::{sign_<|fim_suffix|>{refresh, RefreshError, ValidationError as RefreshValidationError}; pub use sign_out::{sign_out, SignOutError, ValidationError...
code_fim
medium
{ "lang": "rust", "repo": "Divoolej/mapy-nageografiepl-be", "path": "/app/src/services/teachers/sessions/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>ign_out::{sign_out, SignOutError, ValidationError as SignOutValidationError};<|fim_prefix|>// repo: Divoolej/mapy-nageografiepl-be path: /app/src/services/teachers/sessions/mod.rs pub mod sign_in; pub mod refresh; pub mod sign_out; pub use sign_in::{sign_in, SignInError, ValidationError as SignInValidat...
code_fim
medium
{ "lang": "rust", "repo": "Divoolej/mapy-nageografiepl-be", "path": "/app/src/services/teachers/sessions/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(ConjureDeserialize, ConjureSerialize, Debug, Clone, PartialEq, Eq)] pub struct SetType { pub item_type: Box<Type>, } #[derive(ConjureDeserialize, ConjureSerialize, Debug, Clone, PartialEq, Eq)] pub struct MapType { pub key_type: Box<Type>, pub value_type: Box<Type>, } #[derive(Conju...
code_fim
hard
{ "lang": "rust", "repo": "palantir/conjure-verification", "path": "/verification-common/src/conjure/ir.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: palantir/conjure-verification path: /verification-common/src/conjure/ir.rs // (c) Copyright 2018 Palantir Technologies Inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may ob...
code_fim
hard
{ "lang": "rust", "repo": "palantir/conjure-verification", "path": "/verification-common/src/conjure/ir.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TisuOS/image-maker path: /src/maker.rs #![allow(dead_code)] use std::{fs, path::Path}; use easy_fs::File; use crate::require::MakeSystem; pub struct Maker<T: MakeSystem> { pub root_path : String, pub target_path : String, pub format : T, pub file : File, } impl<T: M...
code_fim
hard
{ "lang": "rust", "repo": "TisuOS/image-maker", "path": "/src/maker.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn make(&mut self) { self.format.init_block_map(&mut self.file); self.format.make_super_block(&mut self.file); self.trace(&self.root_path.clone()); } fn trace(&mut self, dir : &String) { for file in self.get_files(dir).iter() { self.form...
code_fim
hard
{ "lang": "rust", "repo": "TisuOS/image-maker", "path": "/src/maker.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ZipDriver/sparksdr-websocket-demo path: /src/audio.rs use web_sys::{AudioContext, GainNode}; use yew::services::{ConsoleService}; use wasm_bindgen::JsCast; use wasm_bindgen_futures::{spawn_local}; use wasm_bindgen_futures::JsFuture; use web_sys::{AudioBuffer}; pub struct AudioProvider { // ...
code_fim
hard
{ "lang": "rust", "repo": "ZipDriver/sparksdr-websocket-demo", "path": "/src/audio.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn audio_ctx(&self) -> Option<AudioContext> { match &self.audio_ctx { Some(audio_ctx) => Some(audio_ctx.clone()), None => None, } } pub fn gain(&self) -> Option<GainNode> { match &self.gain { Some(gain) => Some(gain.clone()), ...
code_fim
hard
{ "lang": "rust", "repo": "ZipDriver/sparksdr-websocket-demo", "path": "/src/audio.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn import_audio_data(&mut self, data: js_sys::ArrayBuffer) { match (self.audio_ctx(), self.gain()) { (Some(audio_ctx), Some(gain)) => { if self.audio_pos == 0 { self.audio_start_time = audio_ctx.current_time(); } ...
code_fim
hard
{ "lang": "rust", "repo": "ZipDriver/sparksdr-websocket-demo", "path": "/src/audio.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>g(feature = "macros")] //! use qip_macros::*; //! # #[cfg(feature = "macros")] //! # fn main() -> CircuitResult<()> { //! //! use qip::inverter::Invertable; //! // Make gamma and its inverse: gamma_inv //! #[invert(gamma_inv, skip)] //! fn gamma<B>(b: &mut B, skip: bool, ra: B::Register, rb: B::Register) ...
code_fim
hard
{ "lang": "rust", "repo": "Renmusxd/RustQIP", "path": "/qip/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Renmusxd/RustQIP path: /qip/src/lib.rs #![forbid(unsafe_code)] #![deny( unreachable_pub, missing_debug_implementations, missing_copy_implementations, trivial_casts, trivial_numeric_casts, unstable_features, unused_import_braces, unused_qualifications, missing_...
code_fim
hard
{ "lang": "rust", "repo": "Renmusxd/RustQIP", "path": "/qip/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: douglasduteil/learnrust path: /src/main.rs extern crate includedir; extern crate phf; extern crate workshopper; use workshopper::{Workshopper, WorkshopperOptions}; include!(concat!(env!("OUT_DIR"), "/exercises.rs")); fn main() { <|fim_suffix|> file_names.map(|x| String::from(x)) .collect...
code_fim
hard
{ "lang": "rust", "repo": "douglasduteil/learnrust", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn includedir_filenames_to_vec_string(file_names: includedir::FileNames) -> Vec<String> { file_names.map(|x| String::from(x)) .collect::<Vec<String>>() // HACK(douglasduteil): revert includedir file_names result // includedir::FileNames seems to be inversed compared to the original file ...
code_fim
medium
{ "lang": "rust", "repo": "douglasduteil/learnrust", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let look_from = Vec3::new(12.0, 1.0, 3.0); let look_at = Vec3::new(1.0, 0.7, -1.0); let apperture = 0.0; let dist_to_focus = 10.0; let camera = Camera::new( look_from, look_at, Vec3::new(0.0, 1.0, 0.0), 20.0, WIDTH as f32 / HEIGHT as f32, ...
code_fim
hard
{ "lang": "rust", "repo": "AlexEne/raytracing-rs", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AlexEne/raytracing-rs path: /src/main.rs extern crate minifb; extern crate rand; extern crate rayon; use rayon::prelude::*; mod camera; mod hittable; mod material; mod ray; mod sphere; mod vec3; mod world; use camera::Camera; use hittable::{HitRecord, Hittable}; use material::Material; use min...
code_fim
hard
{ "lang": "rust", "repo": "AlexEne/raytracing-rs", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: slionx/rocket-demo path: /src/middleware/counter.rs use std::io::Cursor; use std::sync::atomic::{AtomicUsize, Ordering, AtomicBool}; use rocket::{Request, Data, Response}; use rocket::fairing::{Fairing, Info, Kind}; use rocket::http::{Method, ContentType, Status}; #[derive(Debug)] pub struct C...
code_fim
hard
{ "lang": "rust", "repo": "slionx/rocket-demo", "path": "/src/middleware/counter.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Fairing for Counter { // This is a request and response fairing named "GET/POST Counter". fn info(&self) -> Info { Info { name: "GET/POST Counter", kind: Kind::Request | Kind::Response } } // Increment the counter for `GET` and `POST` requests....
code_fim
medium
{ "lang": "rust", "repo": "slionx/rocket-demo", "path": "/src/middleware/counter.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Type for TyKind { fn apply(&mut self, s: &Substitution) { match self { Self::Infer(i) => if let Some(t) = s.get(i) { *self = t.kind.clone() } Self::Tuple(xs) => xs.iter_mut().for_each(|t| t.apply(s)), Self::Arrow(box l, box r) => { l.apply(s); r.apply(s...
code_fim
hard
{ "lang": "rust", "repo": "andyyu2004/rust-parser-typechecker", "path": "/src/typechecking/typing.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: andyyu2004/rust-parser-typechecker path: /src/typechecking/typing.rs use std::fmt::{self, Display, Formatter, Debug}; use super::{Type, Substitution, TyScheme, Env}; use std::collections::HashSet; use crate::set; use crate::parsing::Span; #[derive(Clone, Debug, Eq)] pub struct Ty { pub span...
code_fim
hard
{ "lang": "rust", "repo": "andyyu2004/rust-parser-typechecker", "path": "/src/typechecking/typing.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match self { Self::Infer(i) => write!(f, "τ{}", i), Self::I64 => write!(f, "i64"), Self::F64 => write!(f, "f64"), Self::Bool => write!(f, "bool"), Self::Tuple(xs) => write!(f, "({})", xs.iter().map(|x| x.t...
code_fim
hard
{ "lang": "rust", "repo": "andyyu2004/rust-parser-typechecker", "path": "/src/typechecking/typing.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: galderz/rust-lightning path: /lightning-persister/src/lib.rs annelKeys; use lightning::chain::transaction::OutPoint; use lightning::util::ser::Writeable; use std::fs; use std::io::Error; use std::path::{Path, PathBuf}; #[cfg(test)] use { lightning::chain::keysinterface::KeysInterface, lightni...
code_fim
hard
{ "lang": "rust", "repo": "galderz/rust-lightning", "path": "/lightning-persister/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Create the nodes, giving them FilesystemPersisters for data persisters. let persister_0 = FilesystemPersister::new("test_filesystem_persister_0".to_string()); let persister_1 = FilesystemPersister::new("test_filesystem_persister_1".to_string()); let chanmon_cfgs = create_chanmon_cfgs(2); let ...
code_fim
hard
{ "lang": "rust", "repo": "galderz/rust-lightning", "path": "/lightning-persister/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: galderz/rust-lightning path: /lightning-persister/src/lib.rs can only guarantee that the data is passed to the drive. It is up to the /// drive manufacturers to do the actual persistence properly, which they often /// don't (especially on consumer-grade hardware). Therefore, it is up to the ///...
code_fim
hard
{ "lang": "rust", "repo": "galderz/rust-lightning", "path": "/lightning-persister/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn update(&mut self) { let t = std::time::SystemTime::now(); let date = httpdate::HttpDate::from(t); write!(self, "{date}").unwrap(); } } impl fmt::Write for Date { fn write_str(&mut self, s: &str) -> fmt::Result { self.bytes.copy_from_slice(s.as_bytes()); ...
code_fim
medium
{ "lang": "rust", "repo": "Xudong-Huang/may_minihttp", "path": "/src/date.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Xudong-Huang/may_minihttp path: /src/date.rs use std::cell::UnsafeCell; use std::fmt::{self, Write}; use std::sync::Arc; use bytes::BytesMut; use once_cell::sync::Lazy; // "Sun, 06 Nov 1994 08:49:37 GMT".len() const DATE_VALUE_LENGTH: usize = 29; static CURRENT_DATE: Lazy<Arc<DataWrap>> = Laz...
code_fim
hard
{ "lang": "rust", "repo": "Xudong-Huang/may_minihttp", "path": "/src/date.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> variant as u8 != 0 } } impl WRERR_R { #[doc = "Get enumerated values variant"] #[inline(always)] pub fn variant(&self) -> WRERR_A { match self.bits { false => WRERR_A::NoError, true => WRERR_A::Error, } } #[doc = "Write error not dete...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32wl/src/stm32wl5x_cm4/aes/sr.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stm32-rs/stm32-rs-nightlies path: /stm32wl/src/stm32wl5x_cm4/aes/sr.rs #[doc = "Register `SR` reader"] pub type R = crate::R<SR_SPEC>; #[doc = "Field `CCF` reader - Computation complete flag"] pub type CCF_R = crate::BitReader<CCF_A>; #[doc = "Computation complete flag\n\nValue on reset: 0"] #[d...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32wl/src/stm32wl5x_cm4/aes/sr.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> variant as u8 != 0 } } impl BUSY_R { #[doc = "Get enumerated values variant"] #[inline(always)] pub fn variant(&self) -> BUSY_A { match self.bits { false => BUSY_A::Idle, true => BUSY_A::Busy, } } #[doc = "Idle"] #[inline(always)]...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32wl/src/stm32wl5x_cm4/aes/sr.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chromium/chromium path: /third_party/rust/winapi/v0_3/crate/src/um/dcommon.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. // All file...
code_fim
hard
{ "lang": "rust", "repo": "chromium/chromium", "path": "/third_party/rust/winapi/v0_3/crate/src/um/dcommon.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>, bottom: UINT32, }} pub type D2D_RECT_L = RECT; STRUCT!{struct D2D_SIZE_F { width: FLOAT, height: FLOAT, }} STRUCT!{struct D2D_SIZE_U { width: UINT32, height: UINT32, }} STRUCT!{struct D2D_MATRIX_3X2_F { matrix: [[FLOAT; 2]; 3], }} STRUCT!{struct D2D_MATRIX_4X3_F { matrix: [[F...
code_fim
hard
{ "lang": "rust", "repo": "chromium/chromium", "path": "/third_party/rust/winapi/v0_3/crate/src/um/dcommon.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> .arg(Arg::with_name("COLORTYPE") .help("Set color type") .short("c") .long("color-type") .aliases(&["color", "type"]) .default_value("lab") .possible_values(&["lab", "lch", "xyz"])) }<|fim_prefix|>// repo: ryanobeirne/deltae path...
code_fim
hard
{ "lang": "rust", "repo": "ryanobeirne/deltae", "path": "/examples/deltae/cli.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ryanobeirne/deltae path: /examples/deltae/cli.rs use clap::{App, Arg, crate_version, crate_description, crate_authors}; pub fn app() -> App<'static, 'static> { App::new("deltae") .version(crate_version!()) .about(crate_description!()) .author(crate_authors!()) ...
code_fim
hard
{ "lang": "rust", "repo": "ryanobeirne/deltae", "path": "/examples/deltae/cli.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }