text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: zhaohaijun/rust-libp2p path: /identify/src/protobuf_structs/structs.rs // This file is generated by rust-protobuf 2.0.2. Do not edit // @generated // https://github.com/Manishearth/rust-clippy/issues/702 #![allow(unknown_lints)] #![allow(clippy)] #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(b...
code_fim
hard
{ "lang": "rust", "repo": "zhaohaijun/rust-libp2p", "path": "/identify/src/protobuf_structs/structs.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn clear_observedAddr(&mut self) { self.observedAddr.clear(); } pub fn has_observedAddr(&self) -> bool { self.observedAddr.is_some() } // Param is passed by value, moved pub fn set_observedAddr(&mut self, v: ::std::vec::Vec<u8>) { self.observedAddr = :...
code_fim
hard
{ "lang": "rust", "repo": "zhaohaijun/rust-libp2p", "path": "/identify/src/protobuf_structs/structs.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub(crate) unsafe fn memzero(to: usize, n: Words<u32>) { libc::memset(to as *mut _, 0, n.to_bytes().as_usize()); }<|fim_prefix|>// repo: dfinity/motoko path: /rts/motoko-rts/src/mem_utils.rs use crate::types::{Bytes, Words}; pub(crate) unsafe fn memcpy_words(to: usize, from: usize, n: Words<u32>) { ...
code_fim
medium
{ "lang": "rust", "repo": "dfinity/motoko", "path": "/rts/motoko-rts/src/mem_utils.rs", "mode": "spm", "license": "LLVM-exception", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dfinity/motoko path: /rts/motoko-rts/src/mem_utils.rs use crate::types::{Bytes, Words}; pub(crate) unsafe fn memcpy_words(to: usize, from: usize, n: Words<u32>) { libc::memcpy(to as *mut _, from as *const _, n.to_bytes().as_usize()); } <|fim_suffix|>pub(crate) unsafe fn memzero(to: usize, ...
code_fim
medium
{ "lang": "rust", "repo": "dfinity/motoko", "path": "/rts/motoko-rts/src/mem_utils.rs", "mode": "psm", "license": "LLVM-exception", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sultatos/shadow path: /src/test/environment/test_env.rs fn main() { let var_1 = std::env::var("TESTING_ENV_VAR_1") .expect("Environment variable 'TESTING_ENV_VAR_1' not set"); assert_eq!(var_1, "HELLO WORLD"); <|fim_suffix|> let ld_preload = std::env::var("LD_PRELOAD"...
code_fim
medium
{ "lang": "rust", "repo": "sultatos/shadow", "path": "/src/test/environment/test_env.rs", "mode": "psm", "license": "LicenseRef-scancode-public-domain", "source": "the-stack-v2" }
<|fim_suffix|> let ld_preload = std::env::var("LD_PRELOAD").expect("Environment variable 'LD_PRELOAD' not set"); let ld_preload = ld_preload.split(':'); assert!(ld_preload.last().unwrap() == "/my/custom/ld/preload/path.so"); }<|fim_prefix|>// repo: sultatos/shadow path: /src/test/environment/test_en...
code_fim
medium
{ "lang": "rust", "repo": "sultatos/shadow", "path": "/src/test/environment/test_env.rs", "mode": "spm", "license": "LicenseRef-scancode-public-domain", "source": "the-stack-v2" }
<|fim_suffix|>fn parse_int(input_str: &str) -> Result<u64, Box<dyn Error>> { Ok(input_str.parse()?) } #[cfg(test)] mod tests { use super::*; #[test] fn read_single_number() { let args: Vec<String> = vec![String::from("5")]; let config = Config::new(args).unwrap(); assert_eq!(co...
code_fim
hard
{ "lang": "rust", "repo": "splrk/visual-countdown", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: splrk/visual-countdown path: /src/lib.rs use std::string::String; use std::fs; use std::error::Error; use std::thread; use std::time::{SystemTime, Duration}; use std::io; use std::io::ErrorKind; pub fn run(config: Config) -> Result<(), Box<dyn Error>> { if let Some(filename) = config.filena...
code_fim
hard
{ "lang": "rust", "repo": "splrk/visual-countdown", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let result: Result<Config, Box<dyn Error>>; if let Some(path) = filename { let filename = Some(path.clone()); let time_str = fs::read_to_string(path)?; let seconds = parse_int(time_str.trim())?; result = Ok(Config { seconds, filename }) } else { result = ...
code_fim
hard
{ "lang": "rust", "repo": "splrk/visual-countdown", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> &mut self, heap: &mut Heap, call_site: HirId, callee: InlineObject, arguments: Vec<InlineObject>, responsible: HirId, ) { for_tuples!( #(Tuple.call_started(heap, call_site, callee, arguments.clone(), responsible);)* ); } fn call_ended(&mu...
code_fim
hard
{ "lang": "rust", "repo": "candy-lang/candy", "path": "/compiler/vm/src/tracer/tuple.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for_tuples!( ( #(Tuple.root_fiber_created()),* ) ); } #[allow(clippy::redundant_clone)] // PERF: Avoid clone for last tuple element fn root_fiber_ended(&mut self, ended: TracedFiberEnded<Self::ForFiber>) { for_tuples!( #(Tuple::root_fiber_ended( &mut...
code_fim
hard
{ "lang": "rust", "repo": "candy-lang/candy", "path": "/compiler/vm/src/tracer/tuple.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: candy-lang/candy path: /compiler/vm/src/tracer/tuple.rs use super::{FiberTracer, TracedFiberEnded, Tracer}; use crate::{ channel::ChannelId, fiber::FiberId, heap::{Function, Heap, HirId, InlineObject}, }; use impl_trait_for_tuples::impl_for_tuples; #[impl_for_tuples(2, 3)] impl Trac...
code_fim
hard
{ "lang": "rust", "repo": "candy-lang/candy", "path": "/compiler/vm/src/tracer/tuple.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let instructions = s .split("\n") .filter(|s| !s.is_empty()) .map(|s| match &s[0..=2] { "nop" => Instruction::NOP, "acc" => Instruction::ACC(s[4..].parse::<isize>().unwrap()), "jmp" => Instruction::JMP(s[4..].parse...
code_fim
hard
{ "lang": "rust", "repo": "Ophirr33/aoc-2020", "path": "/src/bin/day08.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Ophirr33/aoc-2020 path: /src/bin/day08.rs use std::mem::swap; fn main() -> () { let mut boot_code = BootCode::parse(INPUT); if let ExecuteResult::Looped { acc, looping_instruction, executed, } = boot_code.execute_until_loop_or_end() { println!( ...
code_fim
hard
{ "lang": "rust", "repo": "Ophirr33/aoc-2020", "path": "/src/bin/day08.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // compute the encryption key from public key 2 and loop size let key = transform_subject(p2, loop_size); println!("Encryption key: {}", key); }<|fim_prefix|>// repo: turingcompl33t/rust-playground path: /advent-2020/day25/puzzle1.rs // puzzle1.rs // // Advent of Code Day 25 Puzzle 1. use s...
code_fim
hard
{ "lang": "rust", "repo": "turingcompl33t/rust-playground", "path": "/advent-2020/day25/puzzle1.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: turingcompl33t/rust-playground path: /advent-2020/day25/puzzle1.rs // puzzle1.rs // // Advent of Code Day 25 Puzzle 1. use std::fs; const FILENAME: &str = "input.txt"; fn compute_loop_size(subject: u64, pkey: u64) -> usize { let mut val: u64 = 1; let mut loop_size = 0; loop { ...
code_fim
hard
{ "lang": "rust", "repo": "turingcompl33t/rust-playground", "path": "/advent-2020/day25/puzzle1.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // back out loop size from public key 1 let loop_size = compute_loop_size(7, p1); // compute the encryption key from public key 2 and loop size let key = transform_subject(p2, loop_size); println!("Encryption key: {}", key); }<|fim_prefix|>// repo: turingcompl33t/rust-playground pat...
code_fim
hard
{ "lang": "rust", "repo": "turingcompl33t/rust-playground", "path": "/advent-2020/day25/puzzle1.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: iBelieve/orgmode-rs path: /src/text.rs use itertools::Itertools; use std::fmt; use textwrap::fill; use utils::StringUtils; use LINE_LENGTH; #[derive(Default, Serialize, Deserialize)] pub struct Text { text: String, indent: usize, leading_blank_lines: usize, trailing_blank_lines:...
code_fim
medium
{ "lang": "rust", "repo": "iBelieve/orgmode-rs", "path": "/src/text.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> "\n".repeat(self.leading_blank_lines) + &" ".repeat(self.indent) + &text.split("\n").join(&line_prefix) + &"\n".repeat(self.trailing_blank_lines) } } impl fmt::Display for Text { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "...
code_fim
hard
{ "lang": "rust", "repo": "iBelieve/orgmode-rs", "path": "/src/text.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> async fn delete_record(&self, record_id: &str) -> Result<()> { let path = format!("/api/v1/records/{}", record_id); delete(&self.http_client, &self.config, &path, HashMap::new()).await } }<|fim_prefix|>// repo: peaceman/grosp-eas path: /src/hetzner_dns/records.rs use crate::hetzne...
code_fim
hard
{ "lang": "rust", "repo": "peaceman/grosp-eas", "path": "/src/hetzner_dns/records.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: peaceman/grosp-eas path: /src/hetzner_dns/records.rs use crate::hetzner_dns::request::{delete, get_list, post}; use crate::hetzner_dns::{Client, Result}; use async_trait::async_trait; use serde::{Deserialize, Serialize}; use std::collections::HashMap; #[derive(Clone, Debug, Serialize, Deseriali...
code_fim
hard
{ "lang": "rust", "repo": "peaceman/grosp-eas", "path": "/src/hetzner_dns/records.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[async_trait] impl Records for Client { async fn get_all_records(&self, zone_id: &str) -> Result<Vec<Record>> { let mut params = HashMap::new(); params.insert(String::from("zone_id"), String::from(zone_id)); let path = "/api/v1/records"; let (records, _pagination_meta...
code_fim
hard
{ "lang": "rust", "repo": "peaceman/grosp-eas", "path": "/src/hetzner_dns/records.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nikomatsakis/miri path: /src/librustc_mir/interpret/machine.rs //! This module contains everything needed to instantiate an interpreter. //! This separation exists to ensure that no fancy miri features like //! interpreting common C functions leak into CTFE. use super::{EvalResult, EvalContext,...
code_fim
hard
{ "lang": "rust", "repo": "nikomatsakis/miri", "path": "/src/librustc_mir/interpret/machine.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Called when trying to mark machine defined `MemoryKinds` as static fn mark_static_initialized(m: Self::MemoryKinds) -> EvalResult<'tcx>; /// Heap allocations via the `box` keyword /// /// Returns a pointer to the allocated memory fn box_alloc<'a>( ecx: &mut EvalContext...
code_fim
hard
{ "lang": "rust", "repo": "nikomatsakis/miri", "path": "/src/librustc_mir/interpret/machine.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> a.print(); let b = SPMatrix::from_dense(&a); println!("{:?}", b); b.to_dense().print(); let c = c!(1, 2, 3, 4, 5); let result = &b * &c; let compar = &a * &c; result.print(); compar.print(); }<|fim_prefix|>// repo: Axect/Rust path: /Library/sparse_ccs/src/bin/...
code_fim
medium
{ "lang": "rust", "repo": "Axect/Rust", "path": "/Library/sparse_ccs/src/bin/sp_test.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Axect/Rust path: /Library/sparse_ccs/src/bin/sp_test.rs extern crate sparse_ccs; extern crate peroxide; use peroxide::*; use sparse_ccs::*; fn main() { let a = ml_matrix(" 3 0 1 2 0; 0 4 0 0 0; 0 7 5 9 0; 0 0 0 0 0; 0 0 0 6 5 "); a.print(...
code_fim
medium
{ "lang": "rust", "repo": "Axect/Rust", "path": "/Library/sparse_ccs/src/bin/sp_test.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: brianp/libstrava-rs path: /src/models/lat_lng_stream.rs /* * Strava API v3 * * The [Swagger Playground](https://developers.strava.com/playground) is the easiest way to familiarize yourself with the Strava API by submitting HTTP requests and observing the responses before you write any client...
code_fim
hard
{ "lang": "rust", "repo": "brianp/libstrava-rs", "path": "/src/models/lat_lng_stream.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn resolution(&self) -> Option<&String> { self.resolution.as_ref() } pub fn reset_resolution(&mut self) { self.resolution = None; } pub fn set_series_type(&mut self, series_type: String) { self.series_type = Some(series_type); } pub fn with_series_type(mut self, series_typ...
code_fim
hard
{ "lang": "rust", "repo": "brianp/libstrava-rs", "path": "/src/models/lat_lng_stream.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn with_series_type(mut self, series_type: String) -> LatLngStream { self.series_type = Some(series_type); self } pub fn series_type(&self) -> Option<&String> { self.series_type.as_ref() } pub fn reset_series_type(&mut self) { self.series_type = None; } pub fn set_data...
code_fim
hard
{ "lang": "rust", "repo": "brianp/libstrava-rs", "path": "/src/models/lat_lng_stream.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: JoshiDhima/Bathbot path: /src/commands/songs/startagain.rs use crate::{BotResult, CommandData, Context}; use std::sync::Arc; #[command] #[short_desc("https://youtu.be/g7VNvg_QTMw&t=29")] #[bucket("songs")] #[no_typing()] async fn startagain(ctx: Arc<Context>, data: CommandData) -> BotResult<()...
code_fim
medium
{ "lang": "rust", "repo": "JoshiDhima/Bathbot", "path": "/src/commands/songs/startagain.rs", "mode": "psm", "license": "ISC", "source": "the-stack-v2" }
<|fim_suffix|>pub fn _startagain() -> (&'static [&'static str], u64) { let lyrics = &[ "I'm not always perfect, but I'm always myself.", "If you don't think I'm worth it - find someone eeeelse.", "I won't say I'm sorry, for being who I aaaaaam.", "Is the eeeend a chance to start agaa...
code_fim
medium
{ "lang": "rust", "repo": "JoshiDhima/Bathbot", "path": "/src/commands/songs/startagain.rs", "mode": "spm", "license": "ISC", "source": "the-stack-v2" }
<|fim_suffix|>fn parse(text: String) -> Input { text.trim().split('\n').enumerate().map(|(r, row)| { row.chars().enumerate().map(move |(c, chr)| (vec![c as isize, r as isize, 0], chr)) }).flatten().collect() } fn main() { assert_eq!(part1(&parse(".#.\n..#\n###".to_string())), 112); assert_eq!(p...
code_fim
hard
{ "lang": "rust", "repo": "ThomasZumsteg/adventofcode2020", "path": "/day17.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ThomasZumsteg/adventofcode2020 path: /day17.rs use common::get_input; use std::collections::{HashMap, HashSet}; use itertools::Itertools; type Point = Vec<isize>; type Input = HashMap<Point, char>; fn neighbors(p: &Point) -> Vec<Point> { (0..p.len()).map(|_| -1..2).multi_cartesian_product(...
code_fim
medium
{ "lang": "rust", "repo": "ThomasZumsteg/adventofcode2020", "path": "/day17.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>mod igg; mod megaup; mod drive; mod util; mod gui; mod support; fn main() { gui::show(); }<|fim_prefix|>// repo: schneki/igg_downloader path: /src/main.rs #![windows_subsystem = "windows"] extern crate select; extern crate hyper; extern crate futures; extern crate tokio_core; extern crate hyper_tls...
code_fim
medium
{ "lang": "rust", "repo": "schneki/igg_downloader", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: schneki/igg_downloader path: /src/main.rs #![windows_subsystem = "windows"] extern crate select; extern crate hyper; extern crate futures; extern crate tokio_core; extern crate hyper_tls; extern crate cookie; extern crate rand; <|fim_suffix|>mod igg; mod megaup; mod drive; mod util; mod gui; m...
code_fim
hard
{ "lang": "rust", "repo": "schneki/igg_downloader", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cburgdorf/rustful path: /src/lib.rs #![crate_id = "rustful#0.1-pre"] #![comment = "RESTful web framework"] #![license = "MIT"] #![crate_type = "rlib"] #![doc(html_root_url = "http://ogeon.github.io/rustful/doc/")] <|fim_suffix|>pub use router::Router; pub use server::Server; pub use request::...
code_fim
medium
{ "lang": "rust", "repo": "cburgdorf/rustful", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub use router::Router; pub use server::Server; pub use request::Request; pub use response::Response; pub mod router; pub mod server; pub mod request; pub mod response;<|fim_prefix|>// repo: cburgdorf/rustful path: /src/lib.rs #![crate_id = "rustful#0.1-pre"] #![comment = "RESTful web framework"] #![li...
code_fim
medium
{ "lang": "rust", "repo": "cburgdorf/rustful", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: reillysiemens/imagr path: /src/better_photos.rs use crate::photos; #[derive(Debug)] pub struct Post { pub id: u64, pub slug: String, pub photos: Vec<Photo>, } <|fim_suffix|>impl From<photos::PhotoContainer> for Photo { fn from(photo_container: photos::PhotoContainer) -> Photo {...
code_fim
medium
{ "lang": "rust", "repo": "reillysiemens/imagr", "path": "/src/better_photos.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let photos::Post { id, slug, photos } = post; let photos = photos .unwrap_or_else(|| Vec::new()) .into_iter() .map(Photo::from) .collect(); Post { id, slug, photos } } }<|fim_prefix|>// repo: reillysiemens/imagr path: /src/better...
code_fim
hard
{ "lang": "rust", "repo": "reillysiemens/imagr", "path": "/src/better_photos.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jonwolski/real-rs path: /src/lib.rs // TODO: Implement `from` or `parse` for other instantiations. //use std::marker::PhantomData; #[macro_export] macro_rules! r64 { (0) => {Zero(0.0)}; (-0) => {Zero(-0.0)}; (0.0) => {Zero(0.0)}; (-0.0) => {Zero(-0.0)}; (-$r:literal) => {Ne...
code_fim
hard
{ "lang": "rust", "repo": "jonwolski/real-rs", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn plus_negative() { let r0 = Real(-2.0); let r1 = r64!(-1.0); let expected = Real(-2.0 + -1.0); assert_eq!(r0 + r1, expected); } #[test] fn minus_zero() { let r0 = Real(-2.0); let r1 =...
code_fim
hard
{ "lang": "rust", "repo": "jonwolski/real-rs", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let r0 = Real(-1.0); let r1 = r64!(0.0); let expected = Real(-1.0 + 0.0); assert_eq!(r0 + r1, expected); } #[test] fn plus_negative() { let r0 = Real(-2.0); let r1 = r64!(-1.0); let expected = Real...
code_fim
hard
{ "lang": "rust", "repo": "jonwolski/real-rs", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[allow(dead_code)] fn find_contained_bag_count(bags: &HashMap<String, Vec<BagQuantity>>, start_bag: String, amount: usize) -> usize { let inner_bags = bags[&start_bag].clone(); inner_bags.into_iter().map(|x| find_contained_bag_count(bags, x.name, x.count)).sum::<usize>() * amount + amount } #[cf...
code_fim
hard
{ "lang": "rust", "repo": "FrederikNS/advent-of-code", "path": "/rust/2020/src/day7.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let inner_bags = bags[&start_bag].clone(); inner_bags.into_iter().map(|x| find_contained_bag_count(bags, x.name, x.count)).sum::<usize>() * amount + amount } #[cfg(test)] mod tests { use super::*; #[test] fn example1() { let input = read_file("day7_ex1.txt").unwrap(); ...
code_fim
hard
{ "lang": "rust", "repo": "FrederikNS/advent-of-code", "path": "/rust/2020/src/day7.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: FrederikNS/advent-of-code path: /rust/2020/src/day7.rs extern crate grok; use std::fs::File; use std::path::Path; use std::io::BufRead; use std::io::BufReader; use std::io::Error; use grok::Pattern; use grok::Grok; use std::collections::HashSet; use std::collections::HashMap; use std::collectio...
code_fim
hard
{ "lang": "rust", "repo": "FrederikNS/advent-of-code", "path": "/rust/2020/src/day7.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rpjohnst/dejavu path: /runner/src/world/draw.rs use gml::{self, vm}; use atlas::Image; use crate::{Context, Sprite, Background, Batch, batch}; #[derive(Default)] pub struct State { pub platform: crate::platform::Draw, pub graphics: Option<crate::graphics::Draw>, pub instances: vm::E...
code_fim
hard
{ "lang": "rust", "repo": "rpjohnst/dejavu", "path": "/runner/src/world/draw.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let (w, h) = (w * xscale, h * yscale); let (mut xstart, mut xend) = (x, x + w); if htiled { xstart = f32::rem_euclid(x, w); if xstart > 0.0 { xstart -= w; } xend = room_width as f32; } let (mut ysta...
code_fim
hard
{ "lang": "rust", "repo": "rpjohnst/dejavu", "path": "/runner/src/world/draw.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn draw_batch_image( cx: &mut Context, image: usize, position: batch::Rect, uv: batch::Rect ) { let Context { world, assets, .. } = cx; let crate::World { draw, .. } = world; let Image { texture, pos, size } = assets.images[image]; if draw.batch.texture != t...
code_fim
hard
{ "lang": "rust", "repo": "rpjohnst/dejavu", "path": "/runner/src/world/draw.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wingerse/quartz-rs path: /src/block/facing.rs #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum Facing { Down, Up, North, South, West, East, } <|fim_suffix|> pub fn from_i8(byte: i8) -> Option<Facing> { match byte { 0 => Some(Facing...
code_fim
medium
{ "lang": "rust", "repo": "wingerse/quartz-rs", "path": "/src/block/facing.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn from_i8(byte: i8) -> Option<Facing> { match byte { 0 => Some(Facing::Down), 1 => Some(Facing::Up), 2 => Some(Facing::North), 3 => Some(Facing::South), 4 => Some(Facing::West), 5 => Some(Facing::East), ...
code_fim
medium
{ "lang": "rust", "repo": "wingerse/quartz-rs", "path": "/src/block/facing.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[inline(always)] pub unsafe fn insl(port: u16, addr: u32, cnt: u32) { asm!("cld; rep insl %dx, (%edi)" : : "{ecx}"(cnt), "{dx}"(port), "{edi}"(addr) : "ecx", "edi", "memory", "cc" : "volatile"); } #[inline(always)] pub unsafe fn outb(port: u16, data: u8) { asm...
code_fim
hard
{ "lang": "rust", "repo": "sueken5/rabbit", "path": "/inc/src/x86.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sueken5/rabbit path: /inc/src/x86.rs #[inline(always)] pub unsafe fn inb(port: u16) -> u8 { let data: u8; asm!("inb %dx, %al" : "={ax}" (data) : "{dx}"(port) :: "volatile"); return data; } /* The implementation of insl (0412) is worth looking at more closely. Rep insl is actually a ...
code_fim
hard
{ "lang": "rust", "repo": "sueken5/rabbit", "path": "/inc/src/x86.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jiyilanzhou/chw path: /std_module/3_macro/macro_feature/src/1_macro_dsl.rs /* 0. DSL :Domain Specific Language 1. 宏根据模式进行匹配 */ // 声明宏 macro_rules! calculate { ( // 强制使用标识符 eval $e:expr ) => { let val:usize = $e; println!("{} = {}",stringify!($e), val)...
code_fim
hard
{ "lang": "rust", "repo": "jiyilanzhou/chw", "path": "/std_module/3_macro/macro_feature/src/1_macro_dsl.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // 若宏内声明" val => 表达式"故展开调用时须与宏声明一致 calculate!(eval 3); // Console:" 3 = 3 " calculate!(eval 3*6); // Console:" 3 * 6 = 18 " // calculate!(eval => 6*8); // 标识符不匹配则报错 // calculate!(val 6*8); // 标识符不匹配则报错 calculate!( eval 6*8, eval 3 ); /* console: ...
code_fim
medium
{ "lang": "rust", "repo": "jiyilanzhou/chw", "path": "/std_module/3_macro/macro_feature/src/1_macro_dsl.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: google/flatbuffers path: /tests/monster_test/my_game/example/any_ambiguous_aliases_generated.rs // automatically generated by the FlatBuffers compiler, do not modify // @generated extern crate alloc; extern crate flatbuffers; use alloc::boxed::Box; use alloc::string::{String, ToString}; use allo...
code_fim
hard
{ "lang": "rust", "repo": "google/flatbuffers", "path": "/tests/monster_test/my_game/example/any_ambiguous_aliases_generated.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Self::NONE } } impl AnyAmbiguousAliasesT { pub fn any_ambiguous_aliases_type(&self) -> AnyAmbiguousAliases { match self { Self::NONE => AnyAmbiguousAliases::NONE, Self::M1(_) => AnyAmbiguousAliases::M1, Self::M2(_) => AnyAmbiguousAliases::M2, Self::M3(_) => AnyAmbiguous...
code_fim
hard
{ "lang": "rust", "repo": "google/flatbuffers", "path": "/tests/monster_test/my_game/example/any_ambiguous_aliases_generated.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ukd1/toucHNews path: /src/main.rs #![allow(non_snake_case)] extern crate rubrail; use rubrail::Touchbar; use rubrail::TTouchbar; use rubrail::SpacerType; use rubrail::SwipeState; extern crate fruitbasket; extern crate hn; use hn::HackerNews; extern crate open; #[cfg(feature = "log")] #[macro...
code_fim
hard
{ "lang": "rust", "repo": "ukd1/toucHNews", "path": "/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let idx = *self.headline_idx.read().unwrap(); if let Some(item) = self.hn.into_iter().nth(idx) { let url = item.url(); let _ = open::that(&url); } } fn hide(&mut self) { let idx = *self.headline_idx.read().unwrap(); if let Some(item) ...
code_fim
hard
{ "lang": "rust", "repo": "ukd1/toucHNews", "path": "/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> TouchbarUI { touchbar: touchbar, hn: hn, headline_label: headline_label, idx_label: idx_label, headline_idx: headline_idx, entries: vec![], rx: rx, } } fn update(&mut self) { self.entries = ...
code_fim
hard
{ "lang": "rust", "repo": "ukd1/toucHNews", "path": "/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let set = vec!(2, 3, 4, 6, 9, 10, 12, 14, 15).into_iter().collect::<BTreeSet<_>>(); let expected = vec!(6, 12).into_iter().collect::<BTreeSet<_>>(); assert_eq!(strip_sequences(&set), expected); } #[test] fn parse_file() { assert!(parse_data().len() > 0); } ...
code_fim
hard
{ "lang": "rust", "repo": "dimo414/advent-2020", "path": "/src/aoc05.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dimo414/advent-2020 path: /src/aoc05.rs use std::cmp::max; use std::collections::BTreeSet; pub fn advent() { let seats = parse_data(); let mut highest = 0; for seat in seats.iter() { highest = max(highest, make_id(parse(seat))); } println!("Highest seat ID: {}", highes...
code_fim
hard
{ "lang": "rust", "repo": "dimo414/advent-2020", "path": "/src/aoc05.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: szdytom/ssandbox-rs path: /src/container/error.rs use std::fmt; #[derive(Debug)] pub enum Error { ForkFailed(nix::Error), AlreadyStarted, EntryError(EntryError), } #[derive(Debug)] pub struct EntryError { error_code: u8, additional_info: String, } impl EntryError { pub...
code_fim
medium
{ "lang": "rust", "repo": "szdytom/ssandbox-rs", "path": "/src/container/error.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> write!(f, "{:?}", self) } } impl std::error::Error for Error {}<|fim_prefix|>// repo: szdytom/ssandbox-rs path: /src/container/error.rs use std::fmt; #[derive(Debug)] pub enum Error { ForkFailed(nix::Error), AlreadyStarted, EntryError(EntryError), } <|fim_middle|>#[derive(Debug...
code_fim
hard
{ "lang": "rust", "repo": "szdytom/ssandbox-rs", "path": "/src/container/error.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Error::EntryError(self) } } impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{:?}", self) } } impl std::error::Error for Error {}<|fim_prefix|>// repo: szdytom/ssandbox-rs path: /src/container/error.rs use std::fmt; #[deriv...
code_fim
hard
{ "lang": "rust", "repo": "szdytom/ssandbox-rs", "path": "/src/container/error.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dragonrider7225/RustOS path: /src/io/mod.rs use core::fmt::{Arguments, Write}; use spin::MutexGuard; /// Various tools for writing to the serial port. #[macro_use] pub mod serial; /// Various tools for writing in VGA text mode. #[macro_use] pub mod vga_text; #[cfg(not(test))] #[macro_use] mo...
code_fim
hard
{ "lang": "rust", "repo": "dragonrider7225/RustOS", "path": "/src/io/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub use _impl::stdout; /// Write a formatted string to an output stream named `name`. #[doc(hidden)] pub fn print_to(out: &mut dyn Write, args: Arguments, name: &str) { out.write_fmt(args) .unwrap_or_else(|_| panic!("Failed to write to {}: {}", name, args)); } /// Write a formatted string to...
code_fim
hard
{ "lang": "rust", "repo": "dragonrider7225/RustOS", "path": "/src/io/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(first_invalid_number(&mut [0; 5], &input), 127); } #[test] fn long_test_input_part_one() { let input = " 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 21 22 23 24 25 45 65 "; let input: Vec<_> = parse_ints(input.trim()).collect(); assert_eq!(f...
code_fim
hard
{ "lang": "rust", "repo": "sgrowe/advent-of-code-2020", "path": "/src/day_nine.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sgrowe/advent-of-code-2020 path: /src/day_nine.rs use super::pairs::Pairs; use super::utils::{parse_ints, start_day}; use std::cmp::Ordering; pub fn main() { let input = start_day("nine"); let ints: Vec<u64> = parse_ints(&input).collect(); println!("Part one: {}", first_invalid_nu...
code_fim
hard
{ "lang": "rust", "repo": "sgrowe/advent-of-code-2020", "path": "/src/day_nine.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dimforge/nalgebra path: /src/geometry/scale_construction.rs #[cfg(feature = "arbitrary")] use crate::base::storage::Owned; #[cfg(feature = "arbitrary")] use quickcheck::{Arbitrary, Gen}; use num::One; #[cfg(feature = "rand-no-std")] use rand::{ distributions::{Distribution, Standard}, R...
code_fim
hard
{ "lang": "rust", "repo": "dimforge/nalgebra", "path": "/src/geometry/scale_construction.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Self::identity() } } #[cfg(feature = "rand-no-std")] impl<T: Scalar, const D: usize> Distribution<Scale<T, D>> for Standard where Standard: Distribution<T>, { /// Generate an arbitrary random variate for testing purposes. #[inline] fn sample<G: Rng + ?Sized>(&self, rng: &mut G...
code_fim
hard
{ "lang": "rust", "repo": "dimforge/nalgebra", "path": "/src/geometry/scale_construction.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(feature = "arbitrary")] impl<T: Scalar + Arbitrary + Send, const D: usize> Arbitrary for Scale<T, D> where Owned<T, crate::Const<D>>: Send, { #[inline] fn arbitrary(rng: &mut Gen) -> Self { let v: SVector<T, D> = Arbitrary::arbitrary(rng); Self::from(v) } } /* * * ...
code_fim
hard
{ "lang": "rust", "repo": "dimforge/nalgebra", "path": "/src/geometry/scale_construction.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn parameter_func(x: i32) { println!("parameter x: {}", x) } fn parameter_func2(x: i32, y: i32) -> i32 { x + y }<|fim_prefix|>// repo: xoumi/Childhood path: /Rust/functions/src/main.rs fn main() { println!("in main"); func2(); parameter_func(10); println!("{}", parameter_func2(10, 20)); let ...
code_fim
easy
{ "lang": "rust", "repo": "xoumi/Childhood", "path": "/Rust/functions/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn parameter_func(x: i32) { println!("parameter x: {}", x) } fn parameter_func2(x: i32, y: i32) -> i32 { x + y }<|fim_prefix|>// repo: xoumi/Childhood path: /Rust/functions/src/main.rs fn main() { println!("in main"); func2(); parameter_func(10); println!("{}", parameter_func2(10, 20)); let...
code_fim
easy
{ "lang": "rust", "repo": "xoumi/Childhood", "path": "/Rust/functions/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xoumi/Childhood path: /Rust/functions/src/main.rs fn main() { println!("in main"); func2(); parameter_func(10); println!("{}", parameter_func2(10, 20)); let n = true; if n { println!("true") } } fn func2() { println!("in func2") } <|fim_suffix|>fn parameter_func2(x: i32, y: i32) -> ...
code_fim
medium
{ "lang": "rust", "repo": "xoumi/Childhood", "path": "/Rust/functions/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Collidable { pub fn new(bounds: Vec<Point2<f32>>) -> Self { let line_points: Vec<(f32, f32)> = bounds.iter().map(|p| (p.x, p.y)).collect(); Collidable { bounds: Polygon::new(LineString::from(line_points), vec![]), } } } impl Component for Collidable { fn as_any(&self) -> &dyn...
code_fim
medium
{ "lang": "rust", "repo": "wedgex/super-shape-battle", "path": "/src/components/collidable.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub type CollisionBounds = Polygon<f32>; #[derive(Clone)] pub struct Collidable { pub bounds: CollisionBounds, } impl Collidable { pub fn new(bounds: Vec<Point2<f32>>) -> Self { let line_points: Vec<(f32, f32)> = bounds.iter().map(|p| (p.x, p.y)).collect(); Collidable { bounds: Polygon...
code_fim
medium
{ "lang": "rust", "repo": "wedgex/super-shape-battle", "path": "/src/components/collidable.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wedgex/super-shape-battle path: /src/components/collidable.rs use geo::{LineString, Polygon}; use ggez::nalgebra::Point2; use std::any::Any; use super::Component; pub type CollisionBounds = Polygon<f32>; #[derive(Clone)] pub struct Collidable { pub bounds: CollisionBounds, } impl Collidabl...
code_fim
medium
{ "lang": "rust", "repo": "wedgex/super-shape-battle", "path": "/src/components/collidable.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: c00t/rust_playground path: /rust4rustaceans_example/ch6-single/src/main.rs fn main() { //println!("Hello, world!"); // test cfg! macro if cfg!(feature = "derive") { <|fim_suffix|>ture = "derive")] struct Helper{ x:i32, y:i32, }<|fim_middle|> println!("feature derive e...
code_fim
easy
{ "lang": "rust", "repo": "c00t/rust_playground", "path": "/rust4rustaceans_example/ch6-single/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("feature derive enabled!"); } } #[cfg(feature = "derive")] struct Helper{ x:i32, y:i32, }<|fim_prefix|>// repo: c00t/rust_playground path: /rust4rustaceans_example/ch6-single/src/main.rs fn main() { //println!("Hello, world!"); // te<|fim_middle|>st cfg! macro if cfg!(f...
code_fim
easy
{ "lang": "rust", "repo": "c00t/rust_playground", "path": "/rust4rustaceans_example/ch6-single/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Clazex/rust-timer path: /src/banner.rs use terminal_size::{terminal_size, Width}; <|fim_suffix|>pub fn gen_banner() -> String { let mut len = 80usize; if let Some((Width(width), _)) = terminal_size() { len = width as usize; } String::from(BANNER_CHAR).repeat(len) }<|fim_middle|>const BAN...
code_fim
easy
{ "lang": "rust", "repo": "Clazex/rust-timer", "path": "/src/banner.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> String::from(BANNER_CHAR).repeat(len) }<|fim_prefix|>// repo: Clazex/rust-timer path: /src/banner.rs use terminal_size::{terminal_size, Width}; const BANNER_CHAR: char = '='; <|fim_middle|>pub fn gen_banner() -> String { let mut len = 80usize; if let Some((Width(width), _)) = terminal_size() { len...
code_fim
medium
{ "lang": "rust", "repo": "Clazex/rust-timer", "path": "/src/banner.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Clazex/rust-timer path: /src/banner.rs use terminal_size::{terminal_size, Width}; const BANNER_CHAR: char = '='; <|fim_suffix|> String::from(BANNER_CHAR).repeat(len) }<|fim_middle|>pub fn gen_banner() -> String { let mut len = 80usize; if let Some((Width(width), _)) = terminal_size() { len...
code_fim
medium
{ "lang": "rust", "repo": "Clazex/rust-timer", "path": "/src/banner.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let r = Regex::new(pattern).map_err(FatalError::from)?; let result = r.replace_all(&data, replacer); if !dry_run { save_to_file(&Path::new(file), &result)?; } } } } Ok(true) }<|fim_prefix|>// r...
code_fim
hard
{ "lang": "rust", "repo": "antifuchs/cargo-release", "path": "/src/replace.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: antifuchs/cargo-release path: /src/replace.rs use std::collections::HashMap; use std::fs::File; use std::io; use std::io::prelude::*; use std::path::Path; use error::FatalError; use regex::Regex; use toml::Value; fn load_from_file(path: &Path) -> io::Result<String> { let mut file = try!(Fi...
code_fim
hard
{ "lang": "rust", "repo": "antifuchs/cargo-release", "path": "/src/replace.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: HarrisonMc555/adventofcode path: /2016/src/days/day23.rs use crate::days::{Day, Debug, Example, Part}; use lazy_static::lazy_static; use regex::{Captures, Regex}; use std::collections::HashMap; pub struct Day23; const DEBUG: bool = false; const NUM_EGGS_PART1: Value = 7; const NUM_EGGS_PART2:...
code_fim
hard
{ "lang": "rust", "repo": "HarrisonMc555/adventofcode", "path": "/2016/src/days/day23.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn debug_print(&self) { debug_println!("Instructions:"); for (index, instruction) in self.instructions.iter().enumerate() { let prefix = if self.index as usize == index { "* " } else { " " }; debug_println...
code_fim
hard
{ "lang": "rust", "repo": "HarrisonMc555/adventofcode", "path": "/2016/src/days/day23.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: FreeMasen/resast path: /src/expr.rs use crate::pat::Pat; use crate::{AssignOp, BinaryOp, LogicalOp, PropKind, UnaryOp, UpdateOp}; use crate::{Class, Func, FuncArg, FuncBody, Ident}; use std::borrow::Cow; /// A slightly more granular program part that a statement #[derive(Debug, Clone, Parti...
code_fim
hard
{ "lang": "rust", "repo": "FreeMasen/resast", "path": "/src/expr.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// pretty much just `new.target` /// ```js /// function Thing(one, two) { /// if (!new.target) { /// return new Thing(one, two); /// } /// this.one = one; /// this.two = two; /// } /// ``` #[derive(PartialEq, Debug, Clone)] #[cfg_attr(all(feature = "serialization"), der...
code_fim
hard
{ "lang": "rust", "repo": "FreeMasen/resast", "path": "/src/expr.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// A template string literal /// ```js /// `I own ${0} birds`; /// ``` #[derive(Debug, Clone, PartialEq)] #[cfg_attr( all(feature = "serde", not(feature = "esprima")), derive(Deserialize, Serialize) )] #[cfg_attr(all(feature = "serde", feature = "esprima"), derive(Deserialize))] pub str...
code_fim
hard
{ "lang": "rust", "repo": "FreeMasen/resast", "path": "/src/expr.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// Run the the parser on the file `path` rendering the data in `format` /// to `stdout`. pub fn run(path: &Path, format: Format) -> Result<()> { // TODO Get repo from context? Artifact::from_file(None, path) .map(|a| a.logical_units.iter().cloned().collect()) .and_then(|units| for...
code_fim
medium
{ "lang": "rust", "repo": "informalsystems/themis-tracer", "path": "/src/cmd/parse.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: informalsystems/themis-tracer path: /src/cmd/parse.rs //! This module implements the `parse` subcommand //! //! The `parse` subcommand parses a single file or string into a vector of //! [`LogicalUnit`]s and then renders those in the specified //! serialization [`Format`]. //! //! [`LogicalUnit`...
code_fim
medium
{ "lang": "rust", "repo": "informalsystems/themis-tracer", "path": "/src/cmd/parse.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> ///Appends a value to the end of the StaticVec without asserting that ///its current length is less than `N`. #[inline(always)] pub unsafe fn push_unchecked(&mut self, value: T) { self.data.get_unchecked_mut(self.length).write(value); self.length += 1; } ///Pops a value from the end o...
code_fim
hard
{ "lang": "rust", "repo": "jswrenn/staticvec", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jswrenn/staticvec path: /src/lib.rs #![no_std] #![feature(core_intrinsics)] #![feature(const_fn)] #![feature(const_generics)] #![feature(maybe_uninit_ref)] #![feature(maybe_uninit_extra)] #![feature(exact_size_is_empty)] use crate::{iterators::*, utils::*}; use core::cmp::{Ord, PartialEq}; use ...
code_fim
hard
{ "lang": "rust", "repo": "jswrenn/staticvec", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> ///Copies and appends all elements, if any, in a slice to the StaticVec. ///Unlike the implementation of this function for [Vec](alloc::vec::Vec), no iterator is used, ///just a single pointer-copy call. ///Locally requires that `T` implements [Copy](core::marker::Copy) to avoid soundness issues. ...
code_fim
hard
{ "lang": "rust", "repo": "jswrenn/staticvec", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rsfetch/rsfetch path: /src/hostname.rs use crate::*; use std::fs; use std::process::Command; pub struct Hostname { name: String, } impl Hostname { pub fn new() -> Hostname { Hostname { name: String::new(), } } <|fim_suffix|> Ok(()) } // ...
code_fim
hard
{ "lang": "rust", "repo": "rsfetch/rsfetch", "path": "/src/hostname.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.name = hostname; } Ok(()) } // format it pub fn format(&self) -> String { self.name.clone() } }<|fim_prefix|>// repo: rsfetch/rsfetch path: /src/hostname.rs use crate::*; use std::fs; use std::process::Command; pub struct Hostname { name: St...
code_fim
hard
{ "lang": "rust", "repo": "rsfetch/rsfetch", "path": "/src/hostname.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let sol_usdc_swap_pool_token_mint = Keypair::from_base58_string(&env::var("sol_usdc_swap_pool_token_mint")?); let ftt_usdc_swap_pool_token_mint = Keypair::from_base58_string(&env::var("ftt_usdc_swap_pool_token_mint")?); let ren_usdc_swap_pool_token_mint = Keypair::from_base58_string(&env::var(...
code_fim
hard
{ "lang": "rust", "repo": "enzoampil/Non-custodial-DEX-Traded-Funds", "path": "/programs/fund-tests/src/bin/rebalance.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for (i, asset) in pool_state.assets.iter().enumerate() { let asset_balance = client.get_token_account_balance(&asset.vault_address)?; println!("{} asset_balance: {:?}", i, asset_balance.ui_amount); } let asset_balance = client.get_token_account_balance(&fun...
code_fim
hard
{ "lang": "rust", "repo": "enzoampil/Non-custodial-DEX-Traded-Funds", "path": "/programs/fund-tests/src/bin/rebalance.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: enzoampil/Non-custodial-DEX-Traded-Funds path: /programs/fund-tests/src/bin/rebalance.rs use std::{env, str::FromStr}; use anyhow::{anyhow, Result}; use borsh::ser::BorshSerialize; use fund::instruction::{FundInstructionInner, FundRequest, FundRequestTag}; use fund_tests::client::{Client, FundC...
code_fim
hard
{ "lang": "rust", "repo": "enzoampil/Non-custodial-DEX-Traded-Funds", "path": "/programs/fund-tests/src/bin/rebalance.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PacktPublishing/Rust-High-Performance path: /Chapter06/example3/src/lib.rs //! This library gives a function to calculate Fibonacci numbers. <|fim_suffix|>// Faster version, to check benchmarks. // pub fn fibonacci(n: u32) -> u32 { // if n == 0 || n == 1 { // n // } else { // ...
code_fim
medium
{ "lang": "rust", "repo": "PacktPublishing/Rust-High-Performance", "path": "/Chapter06/example3/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }