text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> let (draw_width, draw_height) = graphics::drawable_size(ctx); self.imgui.io_mut().display_size = [draw_width, draw_height]; self.imgui.io_mut().display_framebuffer_scale = [1.0, 1.0]; self.imgui.io_mut().delta_time = delta_s; let ui = self.imgui.frame(); let default_font_handle = ...
code_fim
hard
{ "lang": "rust", "repo": "MovingtoMars/liams_4x", "path": "/src/client/imgui_wrapper.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pyfisch/boguin path: /examples/boguin.rs extern crate boguin; extern crate clap; extern crate env_logger; extern crate http_with_url as http; #[macro_use] extern crate log; use std::error::Error; use std::io::{self, Read, Write}; use boguin::Client; use clap::{App, Arg, ArgMatches}; use http::...
code_fim
hard
{ "lang": "rust", "repo": "pyfisch/boguin", "path": "/examples/boguin.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> return request.body(Vec::new()).map_err(|e| e.to_string()); } fn print_response(response: &Response<Vec<u8>>) { // Note: Writes to stderr always succeed. let mut stderr = io::stderr(); writeln!(stderr, "{:?} {}", response.version(), response.status()).unwrap(); for (key, value) in res...
code_fim
hard
{ "lang": "rust", "repo": "pyfisch/boguin", "path": "/examples/boguin.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn program_entry_size(&self) -> usize { self.program_header_entry_size as usize } pub fn program_entries(&self) -> usize { self.program_header_entries as usize } }<|fim_prefix|>// repo: Ocean-git-hub/MonorsOS path: /libs/elf/src/file_header.rs use super::{Identificati...
code_fim
medium
{ "lang": "rust", "repo": "Ocean-git-hub/MonorsOS", "path": "/libs/elf/src/file_header.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Ocean-git-hub/MonorsOS path: /libs/elf/src/file_header.rs use super::{Identification, FileType}; #[repr(C)] #[derive(Debug)] pub struct FileHeader64 { ident: Identification, file_type: FileType, machine: u16, version: u32, entry: u64, program_header_offset: u64, sect...
code_fim
medium
{ "lang": "rust", "repo": "Ocean-git-hub/MonorsOS", "path": "/libs/elf/src/file_header.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified-and-comments-removed path: /third_party/rust/tokio/src/runtime/metrics/runtime.rs use crate : : runtime : : Handle ; use std : : sync : : atomic : : Ordering : : Relaxed ; use std : : time : : Duration ; # [ derive ( Clone Debug ) ] pub struct RuntimeMetrics { handle ...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified-and-comments-removed", "path": "/third_party/rust/tokio/src/runtime/metrics/runtime.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>. spawner . worker_metrics ( worker ) . local_schedule_count . load ( Relaxed ) } pub fn worker_overflow_count ( & self worker : usize ) - > u64 { self . handle . spawner . worker_metrics ( worker ) . overflow_count . load ( Relaxed ) } pub fn injection_queue_depth ( & self ) - > usize { self . handle . s...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified-and-comments-removed", "path": "/third_party/rust/tokio/src/runtime/metrics/runtime.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mattbanister/hackerrank path: /rust/array_sum.rs use std::io; fn main() { let mut reader = io::stdin(); let mut input_text = String::new(); reader.read_line(&mut input_text).ok().expect("failed t<|fim_suffix|>xt_slice .trim() .split(' ') .map(|x: &str| -> u3...
code_fim
hard
{ "lang": "rust", "repo": "mattbanister/hackerrank", "path": "/rust/array_sum.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>xt_slice .trim() .split(' ') .map(|x: &str| -> u32 {x.parse().unwrap()}) .fold(0, |acc, el| el + acc); println!("{}", sum); }<|fim_prefix|>// repo: mattbanister/hackerrank path: /rust/array_sum.rs use std::io; fn main() { let mut reader = io::stdin(); let mut...
code_fim
hard
{ "lang": "rust", "repo": "mattbanister/hackerrank", "path": "/rust/array_sum.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ritchie46/lsh-rs path: /examples/neural-network/src/test.rs #![cfg(test)] use crate::activations::Activation; use crate::network::Network; use ndarray::prelude::*; fn get_model(output_size: usize, lr: f32) -> Network { let dim = vec![2, 3, output_size]; let act = vec![Activation::ReLU, ...
code_fim
hard
{ "lang": "rust", "repo": "ritchie46/lsh-rs", "path": "/examples/neural-network/src/test.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> m.backprop(&mut neurons, &[0, 1]); // j a y δ (y - a) // 0 2.5 0 2.5 // 1 1.2 1 0.2 let layer_1 = &neurons[0]; let layer_2 = &neurons[1]; for n in layer_2 { match n.j { 0 => assert_eq!(n.delta, 2.5), 1 => assert_eq!...
code_fim
hard
{ "lang": "rust", "repo": "ritchie46/lsh-rs", "path": "/examples/neural-network/src/test.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub use poison::{PoisonError, LockResult, TryLockError, TryLockResult}; pub use rwlock::{RwLock, RwLockReadGuard, RwLockWriteGuard}; pub use mutex::{Mutex, MutexGuard}; pub use condvar::{Condvar, WaitTimeoutResult};<|fim_prefix|>// repo: reem/rust-rwlock2 path: /src/lib.rs #![cfg_attr(test, deny(warnings...
code_fim
medium
{ "lang": "rust", "repo": "reem/rust-rwlock2", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: reem/rust-rwlock2 path: /src/lib.rs #![cfg_attr(test, deny(warnings))] #![deny(missing_docs)] //! # rwlock2 //! //! A temporary fork of the RwLock type from std, supplying `map` methods //! on the Read and Write guard types. //! //! When these methods land in std, this crate will be obsolete. /...
code_fim
medium
{ "lang": "rust", "repo": "reem/rust-rwlock2", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[quickcheck] fn number_days_from_sunday_roundtrip(w: Weekday) -> bool { Sunday.nth_next(w.number_days_from_sunday()) == w } #[quickcheck] fn weekday_supports_arbitrary(w: Weekday) -> bool { (1..=7).contains(&w.number_from_monday()) } #[quickcheck] fn weekday_can_shrink(w: Weekday) -> bool { ...
code_fim
hard
{ "lang": "rust", "repo": "time-rs/time", "path": "/tests/quickcheck.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: time-rs/time path: /tests/quickcheck.rs use quickcheck::{Arbitrary, TestResult}; use quickcheck_macros::quickcheck; use time::Weekday::*; use time::{Date, Duration, Month, OffsetDateTime, PrimitiveDateTime, Time, UtcOffset, Weekday}; macro_rules! test_shrink { ($type:ty, $fn_name:ident...
code_fim
hard
{ "lang": "rust", "repo": "time-rs/time", "path": "/tests/quickcheck.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pdt.replace_year(year) == Date::from_calendar_date(year, pdt.month(), pdt.day()) .map(|date| date.with_time(pdt.time())) } #[quickcheck] fn pdt_replace_month(pdt: PrimitiveDateTime, month: Month) -> bool { pdt.replace_month(month) == Date::from_calendar_date(pdt.year()...
code_fim
hard
{ "lang": "rust", "repo": "time-rs/time", "path": "/tests/quickcheck.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut count = 0; for steps in 1..1001 { let ratio = cont_fraction(steps, true); /*if steps < 10 { println!("{}", ratio); }*/ if ratio.numer().to_string().len() > ratio.denom().to_string().len() { count += 1; } } println!("{}", count); }<|fim_prefix|>// repo: Emerentius/ProjectEuler ...
code_fim
hard
{ "lang": "rust", "repo": "Emerentius/ProjectEuler", "path": "/p057_square_root_convergents/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Emerentius/ProjectEuler path: /p057_square_root_convergents/src/main.rs extern crate num; use num::rational; use num::rational::BigRational; use num::{BigInt, One, Zero}; fn cont_fraction ( iter : u64, first : bool ) -> BigRational { <|fim_suffix|>fn main() { let mut count = 0; for steps in 1...
code_fim
hard
{ "lang": "rust", "repo": "Emerentius/ProjectEuler", "path": "/p057_square_root_convergents/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Michael-F-Bryan/lishp path: /src/types.rs //! The base data-type used in Lishp. // TODO: When we start doing Objects, this will simplify down to either // a List or an Object. Should primitives be distinct from Objects? /// An enum containing all the possible data types that can be used in Lis...
code_fim
medium
{ "lang": "rust", "repo": "Michael-F-Bryan/lishp", "path": "/src/types.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// A symbol. Symbol(String), /// A boolean value. Boolean(bool), /// Nothing... Nil, }<|fim_prefix|>// repo: Michael-F-Bryan/lishp path: /src/types.rs //! The base data-type used in Lishp. // TODO: When we start doing Objects, this will simplify down to either // a List or an ...
code_fim
hard
{ "lang": "rust", "repo": "Michael-F-Bryan/lishp", "path": "/src/types.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>mp::min(n, a.len())) { if cards[i] > a[i] { break; } else { cards[i] = a[i]; } } println!("{}", cards.iter().sum::<usize>()); }<|fim_prefix|>// repo: mah-shee/abc127 path: /src/bin/d.rs #[allow(unused_imports)] use proconio::marker::{Bytes, Chars, U...
code_fim
medium
{ "lang": "rust", "repo": "mah-shee/abc127", "path": "/src/bin/d.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mah-shee/abc127 path: /src/bin/d.rs #[allow(unused_imports)] use proconio::marker::{Bytes, Chars, Usize1}; use proconio::{fastout, input}; #[fastout] fn main() { input! { n: usize, m: usize, mut cards: [usize; n], mut cond: [(usize, usize); m], } cards...
code_fim
medium
{ "lang": "rust", "repo": "mah-shee/abc127", "path": "/src/bin/d.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.list.push_back(new_elem); //Pushing tuple (position_in_text, character) to the queue if self.list.len() > self.max_size { //If queue overfilled, pop and return the oldest character return self.list.pop_front(); } None //Returning None if ...
code_fim
hard
{ "lang": "rust", "repo": "keleset/tt_str_fil", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: keleset/tt_str_fil path: /src/lib.rs use std::collections::VecDeque; struct StreakList { //Represents queue of characters list: VecDeque<(usize, usize, char)>, //byte_pos, char_pos, char max_size: usize, //Max size of the queue } impl StreakList { ...
code_fim
hard
{ "lang": "rust", "repo": "keleset/tt_str_fil", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> //Checking input string: if strg.len() <= base_len { return &strg[..]; } //Storing length and starting point for max and current streak: let mut max_byte_len: usize = 0; let mut max_char_len: usize = 0; let mut max_byte_start: usize = 0; let mut streak_byt...
code_fim
hard
{ "lang": "rust", "repo": "keleset/tt_str_fil", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut r = Handlebars::new(); r.register_template_string( "t1", r#"{{#each routes}} import { default as {{this.handler}} } from '{{this.file_path}}' {{/each}} addEventListener('fetch', (event) => { event.respondWith(handleEvent(event)) })"#, ) .unwrap(); r.registe...
code_fim
hard
{ "lang": "rust", "repo": "sunng87/handlebars-rust", "path": "/tests/helper_with_space.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sunng87/handlebars-rust path: /tests/helper_with_space.rs use handlebars::*; use serde_json::json; fn dump<'reg, 'rc>( h: &Helper<'rc>, _: &'reg Handlebars, _: &Context, _: &mut RenderContext, out: &mut dyn Output, ) -> Result<(), RenderError> { assert_eq!(2, h.params()....
code_fim
hard
{ "lang": "rust", "repo": "sunng87/handlebars-rust", "path": "/tests/helper_with_space.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let data = json!({"routes": [{"handler": "__hello_handler", "file_path": "./hello.js"}, {"handler": "__world_index_handler", "file_path": "./world/index.js"}, {"handler": "__index_handler", "file_path": "./index.js"}]}); let exp1 =...
code_fim
hard
{ "lang": "rust", "repo": "sunng87/handlebars-rust", "path": "/tests/helper_with_space.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mmai/khnum path: /src/khnum/wiring.rs use diesel::prelude::{Connection, PgConnection, SqliteConnection}; use diesel::r2d2; use num_cpus; use futures::future::Future; use crate::khnum::errors::ServiceError; // #[cfg(not(any(feature = "sqlite", feature = "postgres")))] // compile_error!("Either f...
code_fim
hard
{ "lang": "rust", "repo": "mmai/khnum", "path": "/src/khnum/wiring.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg_attr(tarpaulin, skip)] pub fn db_init(db_url: String) -> DbPool { let manager = r2d2::ConnectionManager::<MyConnection>::new(db_url); r2d2::Pool::builder().max_size(5).build(manager).expect("Failed to create pool.") } // ================== Test database initialization // #[cfg(feature = "sq...
code_fim
medium
{ "lang": "rust", "repo": "mmai/khnum", "path": "/src/khnum/wiring.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stm32-rs/stm32-rs-nightlies path: /stm32mp1/src/stm32mp153/gpiok.rs 6 (LCKK). The value of bits \\[15:0\\] is used to lock the configuration of the GPIO. During the write sequence, the value of LCKR\\[15:0\\] must not change. When the LOCK sequence has been applied on a port bit, the value of th...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32mp1/src/stm32mp153/gpiok.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>and get [`gpiok_hwcfgr8::R`]. See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [`gpiok_hwcfgr8`] module"] pub type GPIOK_HWCFGR8 = crate::Reg<gpiok_hwcfgr8::GPIOK_HWCFGR8_SPEC>; #[doc = "For GPIOA, B, C, D, E, F, G, H, I, and GPIOJ: For GPIOK and...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32mp1/src/stm32mp153/gpiok.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>is allowed during this locking sequence. Each lock bit freezes a specific configuration register (control and alternate function registers).\n\nYou can [`read`](crate::generic::Reg::read) this register and get [`gpiok_lckr::R`]. You can [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32mp1/src/stm32mp153/gpiok.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn arguments_description<T: Into<String>>( mut self, descritpion: T, ) -> Self { self.argument_descriptoin = descritpion.into(); self } pub fn add_completion<T: Into<String>>(mut self, completion: T) -> Self { self.completion.push(completion.int...
code_fim
hard
{ "lang": "rust", "repo": "dkasak/rust-weechat", "path": "/weechat-rs/src/hooks/commands.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dkasak/rust-weechat path: /weechat-rs/src/hooks/commands.rs use libc::{c_char, c_int}; use std::borrow::Cow; use std::ffi::CStr; use std::os::raw::c_void; use std::ptr; use weechat_sys::{t_gui_buffer, t_weechat_plugin, WEECHAT_RC_OK}; use crate::buffer::Buffer; use crate::{ArgsWeechat, LossyCS...
code_fim
hard
{ "lang": "rust", "repo": "dkasak/rust-weechat", "path": "/weechat-rs/src/hooks/commands.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nix-rust/nix path: /src/macros.rs // Thanks to Tokio for this macro macro_rules! feature { ( #![$meta:meta] $($item:item)* ) => { $( #[cfg($meta)] #[cfg_attr(docsrs, doc(cfg($meta)))] $item )* } } /// The `libc_bitf...
code_fim
hard
{ "lang": "rust", "repo": "nix-rust/nix", "path": "/src/macros.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Munch an ident and cast it to the given type; covers terminating comma. (@accumulate_entries name: $BitFlags:ident, $prefix:tt, [$($entries:tt)*], [$($try_froms:tt)*]; $entry:ident as $ty:ty, $($tail:tt)* ) => { libc_enum! { ...
code_fim
hard
{ "lang": "rust", "repo": "nix-rust/nix", "path": "/src/macros.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[no_mangle] pub fn main() -> i32 { for _ in 0..NUM { let pid = fork(); if pid == 0 { let current_time = get_time(); let sleep_length = (current_time as i32 as isize) * (current_time as i32 as isize) % 1000 + 1000; println!("pid {} sleep for {} ms", ...
code_fim
medium
{ "lang": "rust", "repo": "RainaX/rCore-v3", "path": "/user/src/bin/forktest2.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: RainaX/rCore-v3 path: /user/src/bin/forktest2.rs #![no_std] #![no_main] #[macro_use] extern crate user_lib; use user_lib::{fork, wait, getpid, exit, sleep, get_time}; <|fim_suffix|> let mut exit_code: i32 = 0; for _ in 0..NUM { assert!(wait(&mut exit_code) > 0); assert_...
code_fim
hard
{ "lang": "rust", "repo": "RainaX/rCore-v3", "path": "/user/src/bin/forktest2.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: shorsher/git-req path: /src/main.rs ///! GIT REQ! mod git; mod remotes; use clap::{crate_authors, crate_version, App, Arg, ArgGroup}; use git2::ErrorCode; use log::{debug, error, info, trace}; use std::io::{self, Write}; use std::{env, process}; use tabwriter::TabWriter; /// Get the `origin` r...
code_fim
hard
{ "lang": "rust", "repo": "shorsher/git-req", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Set the project ID fn set_project_id(new_id: &str) { trace!("Setting project ID: {}", new_id); git::set_config("projectid", new_id); eprintln!("New project ID set!"); } /// Print the open requests fn list_open_requests() { info!("Getting open requests"); let mut remote = get_remot...
code_fim
hard
{ "lang": "rust", "repo": "shorsher/git-req", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if genotype.len() == self.genotype.len() { break; } } Specimen::new(genotype) } } impl <'a> CanBeEvaluated for Specimen<'a, City> { fn fitness(&self) -> f64 { let mut fitness: f64 = 0.0; for i in 0..self.genotype.len() - 1 { ...
code_fim
hard
{ "lang": "rust", "repo": "Eragra3/GA", "path": "/src/specimen.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Eragra3/GA path: /src/specimen.rs use rand::{self, Rng}; use std::fs::File; use std::path::Path; use std::io::Write; use std::clone::Clone; use std::cmp; use evo_params::EvolutionParams; use city::City; #[derive(Debug, PartialEq)] pub struct Specimen<'a, T: 'a> { pub genotype: Vec<&'a T>, ...
code_fim
hard
{ "lang": "rust", "repo": "Eragra3/GA", "path": "/src/specimen.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn swap_neighbour<T>(mutable_vector: &mut [T], index: usize) { let vec_len = mutable_vector.len(); if index == 0 { mutable_vector.swap(0, 1); return; } if index == vec_len - 1 { mutable_vector.swap(index, 0); return; } mutable_vector.swap(index, ind...
code_fim
hard
{ "lang": "rust", "repo": "Eragra3/GA", "path": "/src/specimen.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> sum = if curr_fib % 2 == 0 { sum + curr_fib } else { sum }; n += 1; } println!("{}", sum); }<|fim_prefix|>// repo: julienthoma/rust-euler path: /src/e2.rs fn fibonacci(n: u32) -> u32 { match n { 0..=1 => 1, _ => fibonacci(n - 1) + fibonacci(n - 2), } } fn main() { let mut sum ...
code_fim
easy
{ "lang": "rust", "repo": "julienthoma/rust-euler", "path": "/src/e2.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: julienthoma/rust-euler path: /src/e2.rs fn fibonacci(n: u32) -> u32 { match n { 0..=1 => 1, _ => fibonacci(n - 1) + fibonacci(n - 2), } } <|fim_suffix|> if curr_fib > 4_000_000 { break; } sum = if curr_fib % 2 == 0 { sum + curr_fib } else { sum }; n += 1; } ...
code_fim
medium
{ "lang": "rust", "repo": "julienthoma/rust-euler", "path": "/src/e2.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let ts: Instant = Instant::now(); for x in 1..100000000 { let i = Instant::now(); } let ending: Instant = Instant::now(); println!("{:?}", seconds_between(ts,ending)); }<|fim_prefix|>// repo: CodyKochmann/rust-goodies path: /seconds_between.rs use std::time::Instant; fn seconds_between(s...
code_fim
easy
{ "lang": "rust", "repo": "CodyKochmann/rust-goodies", "path": "/seconds_between.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: CodyKochmann/rust-goodies path: /seconds_between.rs use std::time::Instant; fn seconds_between(start: Instant, finish: Instant) -> f32 { <|fim_suffix|> let ts: Instant = Instant::now(); for x in 1..100000000 { let i = Instant::now(); } let ending: Instant = Instant::now(); printl...
code_fim
medium
{ "lang": "rust", "repo": "CodyKochmann/rust-goodies", "path": "/seconds_between.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cedric-h/hypermine path: /common/src/proto.rs use serde::{Deserialize, Serialize}; use crate::{dodeca, graph::NodeId, EntityId, Step}; #[derive(Debug, Serialize, Deserialize)] pub struct ClientHello { pub name: String, } #[derive(Debug, Serialize, Deserialize)] pub struct ServerHello { ...
code_fim
hard
{ "lang": "rust", "repo": "cedric-h/hypermine", "path": "/common/src/proto.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug, Serialize, Deserialize)] pub struct Command { pub step: Step, /// The node that `orientation` and `velocity` are relative to pub node: NodeId, pub orientation: na::UnitQuaternion<f32>, /// Relative to the character's current position pub velocity: na::Vector3<f32>, ...
code_fim
medium
{ "lang": "rust", "repo": "cedric-h/hypermine", "path": "/common/src/proto.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug, Serialize, Deserialize)] pub enum Component { Character(Character), Position(Position), } #[derive(Debug, Serialize, Deserialize)] pub struct FreshNode { /// The side joining the new node to `parent` pub side: dodeca::Side, pub parent: NodeId, } #[derive(Debug, Serial...
code_fim
hard
{ "lang": "rust", "repo": "cedric-h/hypermine", "path": "/common/src/proto.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> example_fn(); }<|fim_prefix|>// repo: upenn-cis198/lecture9 path: /examples/example1.rs /* Inside binaries, you can use library functions */ <|fim_middle|>// use <name of crate>::<name of module>::... use lecture9::lecture9_example::example_fn; fn main() {
code_fim
medium
{ "lang": "rust", "repo": "upenn-cis198/lecture9", "path": "/examples/example1.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: upenn-cis198/lecture9 path: /examples/example1.rs /* Inside binaries, you can use library functions */ // use <name of crate>::<name of module>::... use lecture9::lecture9_example::example_fn; <|fim_suffix|> example_fn(); }<|fim_middle|>fn main() {
code_fim
easy
{ "lang": "rust", "repo": "upenn-cis198/lecture9", "path": "/examples/example1.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>ahb_podf_5(self) -> &'a mut W { self.variant(AHB_PODFW::AHB_PODF_5) } #[doc = "divide by 7"] #[inline] pub fn ahb_podf_6(self) -> &'a mut W { self.variant(AHB_PODFW::AHB_PODF_6) } #[doc = "divide by 8"] #[inline] pub fn ahb_podf_7(self) -> &'a mut W { ...
code_fim
hard
{ "lang": "rust", "repo": "ferrous-systems/imxrt1052", "path": "/src/ccm/cbcdr/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>PH_CLK_SEL_1, } impl PERIPH_CLK_SELW { #[allow(missing_docs)] #[doc(hidden)] #[inline] pub fn _bits(&self) -> bool { match *self { PERIPH_CLK_SELW::PERIPH_CLK_SEL_0 => false, PERIPH_CLK_SELW::PERIPH_CLK_SEL_1 => true, } } } #[doc = r" Proxy"] pub...
code_fim
hard
{ "lang": "rust", "repo": "ferrous-systems/imxrt1052", "path": "/src/ccm/cbcdr/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ferrous-systems/imxrt1052 path: /src/ccm/cbcdr/mod.rs PERIPH_CLK2_PODF_3, #[doc = "divide by 5"] PERIPH_CLK2_PODF_4, #[doc = "divide by 6"] PERIPH_CLK2_PODF_5, #[doc = "divide by 7"] PERIPH_CLK2_PODF_6, #[doc = "divide by 8"] PERIPH_CLK2_PODF_7, } impl PERIPH...
code_fim
hard
{ "lang": "rust", "repo": "ferrous-systems/imxrt1052", "path": "/src/ccm/cbcdr/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let duration_str = format!("{} : {}s", "Duration", time); r = [ 0.0, win_w + margin_top + 1.0 * 35.0, win_w, win_w + margin_top + 2.0 * 35.0, ]; gl.draw_text( &duration_str, ...
code_fim
hard
{ "lang": "rust", "repo": "nicolasvienot/n-puzzle", "path": "/src/visual/visu.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nicolasvienot/n-puzzle path: /src/visual/visu.rs extern crate find_folder; extern crate opengl_graphics; extern crate piston_window; use crate::board::utils::fdtos; use crate::visual::text::{DrawText, TextAlignment, TextVerticalAlignment}; use opengl_graphics::{GlGraphics, GlyphCache}; use pist...
code_fim
hard
{ "lang": "rust", "repo": "nicolasvienot/n-puzzle", "path": "/src/visual/visu.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: holochain/holochain-tracing path: /crates/tracing/src/structured.rs use tracing::{Event, Subscriber}; use tracing_core::field::Field; use tracing_serde::AsSerde; use tracing_subscriber::fmt::{time::ChronoUtc, FmtContext, FormatFields}; use tracing_subscriber::{field::Visit, filter::EnvFilter, re...
code_fim
hard
{ "lang": "rust", "repo": "holochain/holochain-tracing", "path": "/crates/tracing/src/structured.rs", "mode": "psm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|>/// This checks RUST_LOG for a filter but doesn't complain if there is none or it doesn't parse. /// It then checks for CUSTOM_FILTER which if set will output an error if it doesn't parse. pub fn init_fmt(output: Output, jaeger: Option<String>) -> Result<(), String> { let mut filter = EnvFilter::from_...
code_fim
hard
{ "lang": "rust", "repo": "holochain/holochain-tracing", "path": "/crates/tracing/src/structured.rs", "mode": "spm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dgreid/crosvm path: /common/cros_asyncv2/src/unix/seqpacket.rs .await .map(Arc::new) .context("failed to accept connection")?; io_driver::prepare(&*fd).context(PrepareSocket)?; Ok(SeqPacket { fd }) } /// Gets the path that this listener is...
code_fim
hard
{ "lang": "rust", "repo": "dgreid/crosvm", "path": "/common/cros_asyncv2/src/unix/seqpacket.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dgreid/crosvm path: /common/cros_asyncv2/src/unix/seqpacket.rs an intermediate buffer before it is copied into /// `buf` and so this function is best suited for reading small amounts of data. Callers that /// want to avoid the intermediate buffer should use `recv_iobuf` instead. pub...
code_fim
hard
{ "lang": "rust", "repo": "dgreid/crosvm", "path": "/common/cros_asyncv2/src/unix/seqpacket.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn sockaddr_un_len_check() { let (_addr, len) = sockaddr_un(Path::new(&"a".repeat(50))).expect("sockaddr_un failed"); assert_eq!( len, (offset_of!(libc::sockaddr_un, sun_path) + 50 + 1) as u32 ); } #[test] fn sockaddr_un_pass() {...
code_fim
hard
{ "lang": "rust", "repo": "dgreid/crosvm", "path": "/common/cros_asyncv2/src/unix/seqpacket.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> loop { let tok = l.next_token(); if tok.token_type == TokenType::Eof { break; } else { // TODO format string w/o using println!, mostly as an exercise println!("Literal: {:?}, Type: {:?}", tok.literal, tok.token_ty...
code_fim
medium
{ "lang": "rust", "repo": "UnicodeSnowman/writing_an_interpreter_in_rust", "path": "/src/repl.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: UnicodeSnowman/writing_an_interpreter_in_rust path: /src/repl.rs use std::io; use std::io::Write; use std::process::exit; use lexer::{Lexer}; use token::{TokenType}; const PROMPT: &str = ">> "; <|fim_suffix|> if line == "exit" { stdout.write("Goodbye!".as_bytes()).expect("F...
code_fim
hard
{ "lang": "rust", "repo": "UnicodeSnowman/writing_an_interpreter_in_rust", "path": "/src/repl.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // use web::block to offload blocking Diesel code without blocking server thread let response: Option<Video> = web::block(move || video_actions::add_video(video, options, &conn)) .await .map_err(|e| { eprintln!("{}", e); HttpResponse:...
code_fim
hard
{ "lang": "rust", "repo": "Stefan99353/tube-rs", "path": "/tube-rs-daemon/src/videos.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Stefan99353/tube-rs path: /tube-rs-daemon/src/videos.rs use crate::db_models::{Video, VideoOption}; use crate::models::QueryIdString; use crate::video_actions; use actix_web::{delete, get, post, put, web, Error, HttpResponse}; use diesel::prelude::*; use diesel::r2d2::ConnectionManager; type Db...
code_fim
hard
{ "lang": "rust", "repo": "Stefan99353/tube-rs", "path": "/tube-rs-daemon/src/videos.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: itinycheng/rust-learning path: /src/concurrent/rw_lock.rs #![allow(dead_code)] use once_cell::sync::Lazy; use parking_lot::RwLock; use std::{borrow::Borrow, collections::HashMap, hash::Hash, sync::Arc}; pub static SYNC_MAP: Lazy<SyncMap<u32, String>> = Lazy::new(|| { let map = SyncMap::new...
code_fim
hard
{ "lang": "rust", "repo": "itinycheng/rust-learning", "path": "/src/concurrent/rw_lock.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_deref() { #[derive(Clone, Copy)] struct Te; #[derive(Clone, Copy)] struct Se; impl Se { fn test_self(self) { println!("Se"); } fn test_ref(&self) { println!("&Se"); ...
code_fim
hard
{ "lang": "rust", "repo": "itinycheng/rust-learning", "path": "/src/concurrent/rw_lock.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(all(test, feature = "std"))] mod tests { use super::*; use crate::util::{Result, *}; use pretty_assertions::assert_eq; use static_assertions::*; assert_eq_size!(RawHeader, [u8; HEADER_SIZE as usize]); #[test] fn round_trip() -> Result { let raw = data()?; ...
code_fim
hard
{ "lang": "rust", "repo": "00mjk/parts", "path": "/src/gpt/header.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Header { /// Read the GPT Header from a byte slice /// /// # Errors /// /// - The GPT is invalid. /// - [`Error::NotEnough`] if `source` is not `block_size` bytes pub fn from_bytes(source: &[u8], block_size: BlockSize) -> Result<Self> { if source.len() < mem::size_...
code_fim
hard
{ "lang": "rust", "repo": "00mjk/parts", "path": "/src/gpt/header.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 00mjk/parts path: /src/gpt/header.rs //! Handle GPT header use super::error::*; use crate::types::*; use core::{mem, slice}; use crc::{crc32, Hasher32}; use uuid::Uuid; /// A minimum of 16,384 bytes are reserved for the partition array. /// /// With current GPT Partition entry sizes this means ...
code_fim
hard
{ "lang": "rust", "repo": "00mjk/parts", "path": "/src/gpt/header.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<T> Receiver<T> { fn new(receiver: UnboundedReceiver<T>, error_state: ErrorState) -> Self { Self { receiver, error_state, } } /// Channel the given error to the `Sender` side. /// This will only work once, further calls of this function will jus...
code_fim
hard
{ "lang": "rust", "repo": "dvdplm/picoquic-rs", "path": "/src/unbounded_with_error.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dvdplm/picoquic-rs path: /src/unbounded_with_error.rs use error::*; use futures::{ sync::mpsc::{self, unbounded, UnboundedReceiver, UnboundedSender}, Poll, Sink, StartSend, Stream, }; use std::{fmt, sync::Arc}; use parking_lot::RwLock; /// A state for storing a shared error. #[derive...
code_fim
hard
{ "lang": "rust", "repo": "dvdplm/picoquic-rs", "path": "/src/unbounded_with_error.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn check_for_error(&mut self) -> Option<Error> { // If `sender` is closed, check if we got an error to propagate if self.sender.is_closed() { self.error_state.error() } else { None } } pub fn unbounded_send(&mut self, data: T) -> Result<...
code_fim
hard
{ "lang": "rust", "repo": "dvdplm/picoquic-rs", "path": "/src/unbounded_with_error.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Danue1/Danuel path: /platform-web/src/lib.rs use engine::{Build, CoreEngine, CoreEngineBuilder, Version, WorldBuilder}; use wasm_bindgen::prelude::*; <|fim_suffix|>#[wasm_bindgen] pub fn builder() { let mut engine: CoreEngine<Image> = CoreEngineBuilder::new() .version(Version::new(0...
code_fim
medium
{ "lang": "rust", "repo": "Danue1/Danuel", "path": "/platform-web/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[wasm_bindgen] pub fn builder() { let mut engine: CoreEngine<Image> = CoreEngineBuilder::new() .version(Version::new(0, 1, 0)) .world( WorldBuilder::new() .width(256) .height(256) .name("Danuel".to_owned()) .b...
code_fim
medium
{ "lang": "rust", "repo": "Danue1/Danuel", "path": "/platform-web/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: muon-data/muon-rs path: /src/lines.rs // lines.rs // // Copyright (c) 2019-2020 Douglas Lau // use crate::common::{Define, Separator}; use crate::error::ParseError; use crate::schema::Schema; /// Line parsing states enum State { /// Error state Error(ParseError), /// Start state ...
code_fim
hard
{ "lang": "rust", "repo": "muon-data/muon-rs", "path": "/src/lines.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut spaces = key.chars().take_while(|c| *c == ' ').count(); let mut indent = 0; if let Some(indent_spaces) = self.indent_spaces { assert!(indent_spaces > 0); while spaces >= indent_spaces { spaces -= indent_spaces; indent ...
code_fim
hard
{ "lang": "rust", "repo": "muon-data/muon-rs", "path": "/src/lines.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Get key indent, if any fn key_indent(key: &str) -> Option<usize> { let i = key.chars().take_while(|c| *c == ' ').count(); if i > 0 && i < key.chars().count() { Some(i) } else { None } } impl<'a> DefIter<'a> { /// Create a new definition iterator pub fn new(inpu...
code_fim
hard
{ "lang": "rust", "repo": "muon-data/muon-rs", "path": "/src/lines.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match s { RawState::Unknown => State::StateUnknown, RawState::Charging => State::StateCharging, RawState::Discharging => State::StateDischarging, RawState::Empty => State::StateEmpty, RawState::Full => State::StateFull, _ => S...
code_fim
medium
{ "lang": "rust", "repo": "svartalf/rust-battery", "path": "/battery-ffi/src/state.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: svartalf/rust-battery path: /battery-ffi/src/state.rs use battery::State as RawState; /// Possible battery states. /// /// Enum members are prefixed here in order to not have "redeclaration of enumerator" error in C. #[repr(u8)] pub enum State { // DO NOT RE-ORDER VALUES IN THIS ENUM, IT WI...
code_fim
medium
{ "lang": "rust", "repo": "svartalf/rust-battery", "path": "/battery-ffi/src/state.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> fn div(self, rhs: T) -> Fraction { debug_assert!(!self.ud); let r = rhs.into(); debug_assert!(!r.ud); if self.ud || r.ud { return self; } Fraction::new(self.num * r.den, self.den * r.num) } } impl<T: Into<Fraction> + From<Fraction>> DivA...
code_fim
hard
{ "lang": "rust", "repo": "AuroransSolis/fractions_and_matrices", "path": "/src/fractions/operator_overloads.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AuroransSolis/fractions_and_matrices path: /src/fractions/operator_overloads.rs use std::ops::{Add, AddAssign, Sub, SubAssign, Mul, MulAssign, Div, DivAssign, Rem, RemAssign, Neg}; use fractions::base::{Fraction, get_lcm}; impl Neg for Fraction { type Output = Fraction; fn neg(self) -...
code_fim
hard
{ "lang": "rust", "repo": "AuroransSolis/fractions_and_matrices", "path": "/src/fractions/operator_overloads.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mkawalec/scylla-rust-driver path: /scylla-macros/src/value_list.rs use proc_macro::TokenStream; use quote::quote; /// #[derive(ValueList)] allows to parse a struct as a list of values, /// which can be fed to the query directly. /// Works only on simple structs without generics etc pub fn value...
code_fim
hard
{ "lang": "rust", "repo": "mkawalec/scylla-rust-driver", "path": "/scylla-macros/src/value_list.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Ok(std::borrow::Cow::Owned(result)) } } }; TokenStream::from(generated) }<|fim_prefix|>// repo: mkawalec/scylla-rust-driver path: /scylla-macros/src/value_list.rs use proc_macro::TokenStream; use quote::quote; /// #[derive(ValueList)] allows to parse a struct...
code_fim
hard
{ "lang": "rust", "repo": "mkawalec/scylla-rust-driver", "path": "/scylla-macros/src/value_list.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: NBonaparte/vibrant-rs path: /src/bin/primary.rs extern crate image; extern crate vibrant; <|fim_suffix|> let source = env::args().skip(1).next().expect("No source image given."); let img = image::open(&Path::new(&source)) .ok() .expect(&format!("Could ...
code_fim
medium
{ "lang": "rust", "repo": "NBonaparte/vibrant-rs", "path": "/src/bin/primary.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> println!("{}", Palette::new(&img, 10, 10).sort_by_frequency()); }<|fim_prefix|>// repo: NBonaparte/vibrant-rs path: /src/bin/primary.rs extern crate image; extern crate vibrant; use std::env; use std::path::Path; use vibrant::Palette; <|fim_middle|>fn main() { let source = env::args().skip(1)....
code_fim
hard
{ "lang": "rust", "repo": "NBonaparte/vibrant-rs", "path": "/src/bin/primary.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jameswhang/Rust_Programs path: /webserver/src/http.rs #[doc=" "] /// Struct to hold parsed data from HTTP Request /// Status codes here are used to hold status. Status is in progress until a response is generated /// Used instead of Result with error because bad requests should /// still be s...
code_fim
hard
{ "lang": "rust", "repo": "jameswhang/Rust_Programs", "path": "/webserver/src/http.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> "test".to_string(), HttpResponse { method: "GET".to_string(), protocol: "HTTP/1.0".to_string(), status: OK, content_type : "text/html".to_string(), payload : "test".to_string(), content...
code_fim
hard
{ "lang": "rust", "repo": "jameswhang/Rust_Programs", "path": "/webserver/src/http.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn parse_bitmask(&mut self, attrs: &[OwnedAttribute]) { loop { use XmlEvent::*; match self.reader.next().expect("failed to parse XML") { StartElement { name, .. } => { match &name.local_name[..] { "name" => { ...
code_fim
hard
{ "lang": "rust", "repo": "Ralith/openxrs", "path": "/generator/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> loop { use XmlEvent::*; match self.reader.next().expect("failed to parse XML") { StartElement { name, .. } => { match &name.local_name[..] { "name" => { let name = self.parse_characters(...
code_fim
hard
{ "lang": "rust", "repo": "Ralith/openxrs", "path": "/generator/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Ralith/openxrs path: /generator/src/main.rs * #(#handles)* #(#structs)* /// Function pointer prototypes pub mod pfn { use super::*; pub type VoidFunction = unsafe extern "system" fn(); pub type Debu...
code_fim
hard
{ "lang": "rust", "repo": "Ralith/openxrs", "path": "/generator/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl SubFileInfo { /// the last entry in `paths` is the actual file name #[inline] pub fn file_name(&self) -> Option<&str> { self.paths.last().map(String::as_str) } /// returns the complete Path of the file including its parent directories, /// but without the root directo...
code_fim
hard
{ "lang": "rust", "repo": "onurzdg/libp2p-bittorrent-protocol", "path": "/src/torrent/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: onurzdg/libp2p-bittorrent-protocol path: /src/torrent/mod.rs fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "MetaInfo {{ annouce: {:?}, announce_list: {:?}, encoding: {:?}, comment: {:?}, created by: {:?}, creation date: {:?}, httpseeds: {:?}, webseeds: {:?}, info: {...
code_fim
hard
{ "lang": "rust", "repo": "onurzdg/libp2p-bittorrent-protocol", "path": "/src/torrent/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: onurzdg/libp2p-bittorrent-protocol path: /src/torrent/mod.rs } pub fn write_torrent_file<T: AsRef<Path>>(&self, path: T) -> Result<Vec<u8>> { let data = self.to_bencode()?; let mut buffer = File::create(path)?; buffer.write_all(&data)?; Ok(data) } ...
code_fim
hard
{ "lang": "rust", "repo": "onurzdg/libp2p-bittorrent-protocol", "path": "/src/torrent/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> svg.set_style(Layer::Building, "building", "fill:#fff; stroke:none;"); svg.set_style( Layer::ParkBuilding, "park-building", "fill:#777; stroke:none;", ); svg.set_style( Layer::ParkPath, "park-path", "fill:none; stroke:#777; stroke-width:0.0...
code_fim
hard
{ "lang": "rust", "repo": "TyOverby/mapfun", "path": "/src/theme.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> svg.set_style( Layer::ParkPath, "park-path", "fill:none; stroke:#777; stroke-width:0.01px", ); svg.set_style( Layer::Subway, "subway", "fill:none; stroke:#ff0000; stroke-width:0.3%; stroke-linecap:round", ); svg.set_style(Layer::Coastli...
code_fim
medium
{ "lang": "rust", "repo": "TyOverby/mapfun", "path": "/src/theme.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TyOverby/mapfun path: /src/theme.rs use crate::svg_exporter::*; use crate::*; pub fn puke_theme(svg: &mut Svg<Layer>) { svg.set_background_color("#1f2345"); svg.set_style( Layer::Road, "road", "fill:none; stroke:#8b8ca9; stroke-width:0.07%; stroke-linecap:round"...
code_fim
hard
{ "lang": "rust", "repo": "TyOverby/mapfun", "path": "/src/theme.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: smithhmark/splendiforust path: /src/main.rs fn greeting() -> &'static str { <|fim_suffix|>#[cfg(test)] mod tests { use super::*; #[test] fn correct_greeting() { assert_eq!(greeting(), "Hello, world"); } }<|fim_middle|> "Hello, world" } fn main() { println!("{}", ...
code_fim
medium
{ "lang": "rust", "repo": "smithhmark/splendiforust", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }