text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> // called with the full syntax let s = WrappedService::wrap_outgoing(s, foo); let s = WrappedService::wrap_outgoing(s, foo); let s = WrappedService::wrap_outgoing(s, foo); let s = WrappedService::wrap_outgoing(s, foo); let s = WrappedService::wrap_outgoing(s...
code_fim
hard
{ "lang": "rust", "repo": "KristianWahlroos/interledger-rs", "path": "/crates/interledger-service/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// A service that wraps another one with a function that will be called /// on every request. /// /// This enables wrapping services without the boilerplate of defining a /// new struct and implementing IncomingService and/or OutgoingService /// every time. #[derive(Clone)] pub struct WrappedService<F, I...
code_fim
hard
{ "lang": "rust", "repo": "KristianWahlroos/interledger-rs", "path": "/crates/interledger-service/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!( ::std::mem::size_of::<FunctionDefinition>(), 40usize, concat!("Size of: ", stringify!(FunctionDefinition)) ); assert_eq!( ::std::mem::align_of::<FunctionDefinition>(), 8usize, concat!("Alignment of ", stringify!(FunctionDefinition)) ...
code_fim
hard
{ "lang": "rust", "repo": "zeyonaut/mun", "path": "/crates/mun_abi/src/autogen.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!( ::std::mem::size_of::<FunctionPrototype>(), 32usize, concat!("Size of: ", stringify!(FunctionPrototype)) ); assert_eq!( ::std::mem::align_of::<FunctionPrototype>(), 8usize, concat!("Alignment of ", stringify!(FunctionPrototype)) )...
code_fim
hard
{ "lang": "rust", "repo": "zeyonaut/mun", "path": "/crates/mun_abi/src/autogen.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zeyonaut/mun path: /crates/mun_abi/src/autogen.rs dit by hand, see `crate/ra_tools/src/codegen` /* automatically generated by rust-bindgen 0.54.1 */ #![allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] use crate::{StructMemoryKind, TypeGroup}; #[doc = " Represents a globall...
code_fim
hard
{ "lang": "rust", "repo": "zeyonaut/mun", "path": "/crates/mun_abi/src/autogen.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>} impl To<Option<AccessLevelBefore>> for *mut c_void { #[inline(always)] unsafe fn to(self) -> Option<AccessLevelBefore> { NonNull::new(self).map(AccessLevelBefore) } } #[repr(transparent)] #[derive(Debug)] pub struct Restriction(pub NonNull<c_void>); #[repr(transparent)] #[derive(Debug, Clone, Cop...
code_fim
hard
{ "lang": "rust", "repo": "LyricZhao/plant", "path": "/isl-rs/src/flow.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: LyricZhao/plant path: /isl-rs/src/flow.rs -> Option<CtxRef>; pub fn isl_union_flow_copy(flow: UnionFlowRef) -> Option<UnionFlow>; pub fn isl_union_flow_get_must_dependence(flow: UnionFlowRef) -> Option<UnionMap>; pub fn isl_union_flow_get_may_dependence(flow: UnionFlowRef) -> Option<Union...
code_fim
hard
{ "lang": "rust", "repo": "LyricZhao/plant", "path": "/isl-rs/src/flow.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: LyricZhao/plant path: /isl-rs/src/flow.rs -> Option<UnionMap>; pub fn isl_union_flow_get_must_no_source(flow: UnionFlowRef) -> Option<UnionMap>; pub fn isl_union_flow_get_may_no_source(flow: UnionFlowRef) -> Option<UnionMap>; pub fn isl_union_flow_free(flow: UnionFlow) -> *mut c_void; p...
code_fim
hard
{ "lang": "rust", "repo": "LyricZhao/plant", "path": "/isl-rs/src/flow.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// Convert rocket::Data into String /// I hope 2 MiB will be enough for everything. pub async fn data_to_string(data: rocket::Data<'_>) -> String { data.open(2.mebibytes()) .into_string() .await .unwrap() .into_inner() }<|fim_prefix|>// repo: SmartBeansGoe/smartbeans-b...
code_fim
medium
{ "lang": "rust", "repo": "SmartBeansGoe/smartbeans-backend", "path": "/src/tools.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: SmartBeansGoe/smartbeans-backend path: /src/tools.rs use rocket::data::ToByteUnit; use std::time::{SystemTime, UNIX_EPOCH}; <|fim_suffix|>/// Convert rocket::Data into String /// I hope 2 MiB will be enough for everything. pub async fn data_to_string(data: rocket::Data<'_>) -> String { data...
code_fim
medium
{ "lang": "rust", "repo": "SmartBeansGoe/smartbeans-backend", "path": "/src/tools.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let claim_set = ClaimsSet { registered: { RegisteredClaims { audience: Some(SingleOrMultiple::Single("foo".to_string())), ..Default::default() } }, private: Value::default(), }; ...
code_fim
hard
{ "lang": "rust", "repo": "mozilla-iam/dino-park-oidc", "path": "/src/provider.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mozilla-iam/dino-park-oidc path: /src/provider.rs use crate::error::OidcError; use crate::keys::RemoteKeys; use crate::keys::RemoteKeysProvider; use biscuit::jwa; use biscuit::jwk::AlgorithmParameters; use biscuit::jws; use biscuit::Empty; use biscuit::ValidationOptions; use futures::future::Box...
code_fim
hard
{ "lang": "rust", "repo": "mozilla-iam/dino-park-oidc", "path": "/src/provider.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ciaran2/feo3boy path: /feo3boy-opcodes/src/compiler/args.rs //! Provides utilities for working with args to the microcode. use std::any::{Any, TypeId}; use std::fmt; use proc_macro2::TokenStream; use quote::{quote, ToTokens}; /// Function type used to look up crate names for literal values. p...
code_fim
hard
{ "lang": "rust", "repo": "ciaran2/feo3boy", "path": "/feo3boy-opcodes/src/compiler/args.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> proc_macro2::Literal::usize_suffixed(*self).into_token_stream() } } impl Literal for bool { fn constant_value(&self, _crates: CrateFetcher) -> TokenStream { if *self { quote! { true } } else { quote! { false } } } } /// A literal with o...
code_fim
hard
{ "lang": "rust", "repo": "ciaran2/feo3boy", "path": "/feo3boy-opcodes/src/compiler/args.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if *self { quote! { true } } else { quote! { false } } } } /// A literal with object-safe clone-ability. pub struct DynLiteral { literal: Box<dyn Literal>, clone: fn(&dyn Literal) -> Box<dyn Literal>, } impl DynLiteral { pub fn new<L: Liter...
code_fim
hard
{ "lang": "rust", "repo": "ciaran2/feo3boy", "path": "/feo3boy-opcodes/src/compiler/args.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match self.source.prune(&shifted) { None => None, Some(pruned) => { if *self.source == pruned { Some(Tracer::TranslatingT(self.clone())) } else { let source = pruned; let shift = sel...
code_fim
hard
{ "lang": "rust", "repo": "drbrain/unicornify.rs", "path": "/src/render/translating_tracer.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> TranslatingTracer { source, shift, bounds, world_view, } } pub fn prune(&self, rendering_parameters: &RenderingParameters) -> Option<Tracer> { let shifted = rendering_parameters.translated(self.shift.x, self.shift.y); ...
code_fim
hard
{ "lang": "rust", "repo": "drbrain/unicornify.rs", "path": "/src/render/translating_tracer.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: drbrain/unicornify.rs path: /src/render/translating_tracer.rs use crate::geometry::Point; use crate::geometry::Vector; use crate::render::Bounds; use crate::render::RenderingParameters; use crate::render::TraceResult; use crate::render::Tracer; use crate::render::WorldView; #[derive(Clone, Debu...
code_fim
hard
{ "lang": "rust", "repo": "drbrain/unicornify.rs", "path": "/src/render/translating_tracer.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: CycloneDX/cyclonedx-rust-cargo path: /cyclonedx-bom/src/utilities.rs /// Convert an optional list of a type /// /// Used to translate between a common structure in the data model for going between the model version and the specification version pub(crate) fn convert_optional_vec<A, B: From<A>>(v...
code_fim
medium
{ "lang": "rust", "repo": "CycloneDX/cyclonedx-rust-cargo", "path": "/cyclonedx-bom/src/utilities.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub(crate) fn convert_vec<A, B: From<A>>(value: Vec<A>) -> Vec<B> { value.into_iter().map(std::convert::Into::into).collect() }<|fim_prefix|>// repo: CycloneDX/cyclonedx-rust-cargo path: /cyclonedx-bom/src/utilities.rs /// Convert an optional list of a type /// /// Used to translate between a common ...
code_fim
medium
{ "lang": "rust", "repo": "CycloneDX/cyclonedx-rust-cargo", "path": "/cyclonedx-bom/src/utilities.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub fn is_news_letter<L: Letter>(c: L) -> bool { match c.byte() { b'E' | b'N' | b'S' | b'W' => true, _ => false } } pub fn is_roman_numeral_letter<L: Letter>(c: L) -> bool { match c.byte() { b'I' | b'V' | b'X' | b'L' | b'C' | b'D' | b'M' => true, _ => false ...
code_fim
hard
{ "lang": "rust", "repo": "dgulotta/puzzletools", "path": "/src/letter.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dgulotta/puzzletools path: /src/letter.rs //! Tests for commonly used properties of individual letters. /// A byte or a character. Functions in the `puzzletools` crate use /// this trait in order to accept either bytes or characters. /// ``` /// use puzzletools::letter::is_dna_letter; /// asse...
code_fim
hard
{ "lang": "rust", "repo": "dgulotta/puzzletools", "path": "/src/letter.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn is_descender<L: Letter>(c: L) -> bool { match c.byte() { b'G' | b'J' | b'P' | b'Q' | b'Y' => true, _ => false } } pub fn scrabble_value<L: Letter>(c: L) -> u32 { match c.byte() { b'A' | b'E' | b'I' | b'O' | b'U' | b'L' | b'N' | b'S' | b'T' | b'R' => 1, b...
code_fim
hard
{ "lang": "rust", "repo": "dgulotta/puzzletools", "path": "/src/letter.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> ltr } pub fn render_stave(elems: &Vec<StaveEntity>) -> layout::Node { let stave_callback = layout::Callbacks { draw_background: callbacks::draw_stave, }; let barline_callback = layout::Callbacks { draw_background: callbacks::draw_barline, }; let double_barline_ca...
code_fim
hard
{ "lang": "rust", "repo": "afandian/layout-experiment", "path": "/src/music_typeset.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: afandian/layout-experiment path: /src/music_typeset.rs use layout; /// Position on a stave relative to the centre line. type StavePosition = i16; // Spacing between lines on the stave. A notehead is also this height. const LINE_SPACING: f32 = 10.0; // Height of a position on the stave. const ...
code_fim
hard
{ "lang": "rust", "repo": "afandian/layout-experiment", "path": "/src/music_typeset.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let notehead_style = layout::LayoutSpec::none() .with_dimensions(LINE_SPACING * 1.75, LINE_SPACING) .with_margin(0.0, 10.0, 0.0, 10.0); let barline_style = layout::LayoutSpec::none() .with_dimensions(1.0, STAVE_HEIGHT) .with_offset(0.0, -STAVE_HEIGHT / 2.0); l...
code_fim
hard
{ "lang": "rust", "repo": "afandian/layout-experiment", "path": "/src/music_typeset.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: melted/aoc2017 path: /src/bin/day3.rs use std::collections::HashMap; fn generate_neighbours((x,y) : (i32, i32)) -> Vec<(i32, i32)> { let mut out = Vec::new(); for i in x-1..x+2 { for j in y-1..y+2 { out.push((i,j)); } } out } fn change_dir((x,y) : (i...
code_fim
medium
{ "lang": "rust", "repo": "melted/aoc2017", "path": "/src/bin/day3.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if x > 0 && y < 0 { return x == i32::abs(y) + 1; } i32::abs(x) == i32::abs(y) } fn main() { let mut vals : HashMap<(i32, i32), i32> = HashMap::new(); let mut pos = (1, 0); let dirs = [(1, 0), (0,1), (-1,0), (0, -1)]; let mut dir = 1; let target = 347991; vals....
code_fim
medium
{ "lang": "rust", "repo": "melted/aoc2017", "path": "/src/bin/day3.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut vals : HashMap<(i32, i32), i32> = HashMap::new(); let mut pos = (1, 0); let dirs = [(1, 0), (0,1), (-1,0), (0, -1)]; let mut dir = 1; let target = 347991; vals.insert((0,0), 1); loop { let v = generate_neighbours(pos); let mut value = 0; for p in...
code_fim
medium
{ "lang": "rust", "repo": "melted/aoc2017", "path": "/src/bin/day3.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Colorizable for NationalGDP { fn color(&self) -> Color { let value = ints::linearscale(self.in_local_currency); Color { red : value, blue : value, green : value, alpha: 255} } }<|fim_prefix|>// repo: gianlo/first_explore path: /...
code_fim
medium
{ "lang": "rust", "repo": "gianlo/first_explore", "path": "/src/models/gdp.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gianlo/first_explore path: /src/models/gdp.rs use super::super::utils::ints; use super::super::typeclasses::{Colorizable, Color}; <|fim_suffix|>impl Colorizable for NationalGDP { fn color(&self) -> Color { let value = ints::linearscale(self.in_local_currency); Color { ...
code_fim
medium
{ "lang": "rust", "repo": "gianlo/first_explore", "path": "/src/models/gdp.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let value = ints::linearscale(self.in_local_currency); Color { red : value, blue : value, green : value, alpha: 255} } }<|fim_prefix|>// repo: gianlo/first_explore path: /src/models/gdp.rs use super::super::utils::ints; use super::super:...
code_fim
medium
{ "lang": "rust", "repo": "gianlo/first_explore", "path": "/src/models/gdp.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Python::with_gil(|py| { const LEN: usize = 100_000; let set = PySet::new(py, &(0..LEN).collect::<Vec<_>>()).unwrap(); b.iter(|| hashbrown::HashSet::<u64>::extract(set)); }); } fn criterion_benchmark(c: &mut Criterion) { c.bench_function("iter_set", iter_set); c.ben...
code_fim
hard
{ "lang": "rust", "repo": "dalcde/pyo3", "path": "/benches/bench_set.rs", "mode": "spm", "license": "Python-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dalcde/pyo3 path: /benches/bench_set.rs use criterion::{criterion_group, criterion_main, Bencher, Criterion}; use pyo3::prelude::*; use pyo3::types::PySet; use std::collections::{BTreeSet, HashSet}; fn iter_set(b: &mut Bencher<'_>) { Python::with_gil(|py| { const LEN: usize = 100_0...
code_fim
hard
{ "lang": "rust", "repo": "dalcde/pyo3", "path": "/benches/bench_set.rs", "mode": "psm", "license": "Python-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: resslerruntime1983/cut path: /cut-be/src/app/constants.rs #![allow(dead_code)] pub const VARIANT_SNIPPET: &str = "snippet"; pub const VARIANT_URL: &str = "url"; pub const VARIANT_FILE: &str = "file"; <|fim_suffix|>pub const HASH_LENGTH: usize = 8;<|fim_middle|>pub const MAX_SIZE_SNIPPET: usize...
code_fim
medium
{ "lang": "rust", "repo": "resslerruntime1983/cut", "path": "/cut-be/src/app/constants.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub const HASH_LENGTH: usize = 8;<|fim_prefix|>// repo: resslerruntime1983/cut path: /cut-be/src/app/constants.rs #![allow(dead_code)] pub const VARIANT_SNIPPET: &str = "snippet"; pub const VARIANT_URL: &str = "url"; pub const VARIANT_FILE: &str = "file"; <|fim_middle|>pub const MAX_SIZE_SNIPPET: usize...
code_fim
medium
{ "lang": "rust", "repo": "resslerruntime1983/cut", "path": "/cut-be/src/app/constants.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let packet = packet(&frame.payload).unwrap(); if addresses.read().unwrap().contains(&packet.dest_ipv4) { let frame = ether::Frame { dest: packet.src_ether, src: src_ether, ethertype: ether::Type::Arp, ...
code_fim
hard
{ "lang": "rust", "repo": "pianohacker/fakenet", "path": "/src/protocols/arp.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pianohacker/fakenet path: /src/protocols/arp.rs use anyhow::{anyhow, Result as AHResult}; use crossbeam::channel; use nom::{ combinator::{map_res, verify}, number::complete::{be_u16, be_u8}, }; use std::collections::HashSet; use std::convert::TryFrom; use std::sync::{Arc, RwLock}; use st...
code_fim
hard
{ "lang": "rust", "repo": "pianohacker/fakenet", "path": "/src/protocols/arp.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lenscas/arena_keeper_quick path: /src/help_states/buyable_char_info.rs use crate::{ assets::loaded::{Fonts, Images}, mergui_wrapper::success_button, structs::{BuyableCharacter, FullContext}, }; use quicksilver::{ geom::Rectangle, graphics::{Color, FontStyle}, prelude::{Im...
code_fim
hard
{ "lang": "rust", "repo": "lenscas/arena_keeper_quick", "path": "/src/help_states/buyable_char_info.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Transform::IDENTITY, z, ); let z = context.simple_context.get_z(); context.simple_context.window.draw_ex( &self.name.0, Img(&self.name.1), Transform::IDENTITY, z, ); let z = context.simple_context.g...
code_fim
hard
{ "lang": "rust", "repo": "lenscas/arena_keeper_quick", "path": "/src/help_states/buyable_char_info.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: WolverinDEV/rust-webrtc path: /src/utils/rtcp/packets/receiver_report.rs use crate::utils::rtcp::{RtcpReportBlock, read_profile_data, profile_data_length, RtcpPacketType, write_profile_data}; use std::io::{Cursor, Result, ErrorKind, Error}; use byteorder::{ReadBytesExt, BigEndian, WriteBytesExt}...
code_fim
hard
{ "lang": "rust", "repo": "WolverinDEV/rust-webrtc", "path": "/src/utils/rtcp/packets/receiver_report.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Ok(report) } pub fn byte_size(&self) -> usize { 8 + self.reports.iter().map(|e| e.1.byte_size() + 4).sum::<usize>() + profile_data_length(&self.profile_data) } pub fn write(&self, writer: &mut Cursor<&mut [u8]>) -> Result<()> { if self.reports.len() > 15 { ...
code_fim
hard
{ "lang": "rust", "repo": "WolverinDEV/rust-webrtc", "path": "/src/utils/rtcp/packets/receiver_report.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let start = PreciseTime::now(); let s = solve(); println!("60 non-reapeating terms: {} ({})", s, start.to(PreciseTime::now())); } #[cfg(test)] mod tests { use super::*; use test::{Bencher, black_box}; #[test] fn test_sieve_074() { let s = solve(); assert_eq!(4...
code_fim
hard
{ "lang": "rust", "repo": "palacaze/euler-rs", "path": "/src/bin/euler-074.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: palacaze/euler-rs path: /src/bin/euler-074.rs // Digit factorial chains Problem 74 // // The number 145 is well known for the property that the sum of the factorial of its digits is // equal to 145: // // 1! + 4! + 5! = 1 + 24 + 120 = 145 // // Perhaps less well known is 169, in that it produces...
code_fim
hard
{ "lang": "rust", "repo": "palacaze/euler-rs", "path": "/src/bin/euler-074.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DanielleB-R/http-from-scratch path: /src/request.rs use http::{request::Builder, Request}; use lazy_static::lazy_static; use regex::Regex; <|fim_suffix|>pub fn parse_request_line(line: &str) -> Result<Builder, ()> { let captures = REQUEST_REGEX.captures(line).ok_or(())?; Ok(Request::bu...
code_fim
medium
{ "lang": "rust", "repo": "DanielleB-R/http-from-scratch", "path": "/src/request.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Ok(Request::builder() .method(captures.get(1).unwrap().as_str()) .uri(captures.get(2).unwrap().as_str())) }<|fim_prefix|>// repo: DanielleB-R/http-from-scratch path: /src/request.rs use http::{request::Builder, Request}; use lazy_static::lazy_static; use regex::Regex; <|fim_middle|>l...
code_fim
hard
{ "lang": "rust", "repo": "DanielleB-R/http-from-scratch", "path": "/src/request.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mqp/advent-2019 path: /day6/src/main.rs use std::error::Error; use std::io::{self, Read}; use std::collections::HashMap; fn parse_orbit(s: &str) -> Result<(&str, &str), Box<dyn Error>> { let mut parts = s.split(")"); let inner = parts.next().ok_or("Invalid orbit.")?; let outer = par...
code_fim
hard
{ "lang": "rust", "repo": "mqp/advent-2019", "path": "/day6/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn parse_graph(input: &str) -> Result<HashMap<&str, &str>, Box<dyn Error>> { let mut graph = HashMap::new(); for orbit in input.split_whitespace().map(parse_orbit) { let (inner, outer) = orbit?; graph.insert(outer, inner); } Ok(graph) } fn get_ancestors<'a>(graph: &'a Hash...
code_fim
medium
{ "lang": "rust", "repo": "mqp/advent-2019", "path": "/day6/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[derive(Debug)] pub struct Sync { pub poset: Arc<Mutex<AllegroPoset>>, } impl Sync { /// Creates a new `Sync` instance. /// # Examples /// ``` /// use einsteindb::causetq::sync::new_sync; /// use einsteindb::causetq::sync::Sync; /// let poset = new_sync(); /// let sync = ...
code_fim
hard
{ "lang": "rust", "repo": "YosiSF/EinsteinDB", "path": "/causet/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub struct PosetNodeDataSync { pub data: PosetNodeData, pub version: u64, pub timestamp: u64, } #[derive(Debug)] pub struct Sync { pub poset: Arc<Mutex<AllegroPoset>>, } impl Sync { /// Creates a new `Sync` instance. /// # Examples /// ``` /// use einsteindb::causetq::...
code_fim
hard
{ "lang": "rust", "repo": "YosiSF/EinsteinDB", "path": "/causet/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: YosiSF/EinsteinDB path: /causet/src/lib.rs use std::iter::Iterator; use std::iter::Peekable; use std::iter::Rev; use std::ops::Index; use std::ops::IndexMut; use std::ops::Range; use std::ops::Deref; use std::ops::DerefMut; use std::collections::HashMap; use std::collections::HashSet; use ...
code_fim
hard
{ "lang": "rust", "repo": "YosiSF/EinsteinDB", "path": "/causet/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let sum = filter_and_sum(100, 2); assert_eq!(2450, sum); }<|fim_prefix|>// repo: JohanLarsson/rust_test_box path: /src/lib.rs pub fn filter_and_sum(n: i32, m: i32) -> i32{ (0..n).filter(|x| x % m == 0) .fold(0, |sum, x| sum + x) } <|fim_middle|>#[test] fn filter_and_sum_test_inline() {
code_fim
easy
{ "lang": "rust", "repo": "JohanLarsson/rust_test_box", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: JohanLarsson/rust_test_box path: /src/lib.rs pub fn filter_and_sum(n: i32, m: i32) -> i32{ (0..n).filter(|x| x % m == 0) .fold(0, |sum, x| sum + x) } <|fim_suffix|> let sum = filter_and_sum(100, 2); assert_eq!(2450, sum); }<|fim_middle|>#[test] fn filter_and_sum_test_inline() {
code_fim
easy
{ "lang": "rust", "repo": "JohanLarsson/rust_test_box", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>// MODs pub mod common; pub mod simple_api; pub mod simple_http; #[cfg(feature = "for_hyper")] pub mod bind_hyper; #[cfg(feature = "for_ureq")] pub mod bind_ureq;<|fim_prefix|>// repo: TeaEntityLab/httpAPIService path: /src/lib.rs // Crates extern crate bytes; extern crate futures; extern crate http;...
code_fim
hard
{ "lang": "rust", "repo": "TeaEntityLab/httpAPIService", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TeaEntityLab/httpAPIService path: /src/lib.rs // Crates extern crate bytes; extern crate futures; extern crate http; extern crate url; #[cfg(feature = "for_hyper")] extern crate hyper; #[cfg(feature = "for_hyper")] extern crate tokio; <|fim_suffix|>#[cfg(feature = "for_hyper")] pub mod bind_h...
code_fim
hard
{ "lang": "rust", "repo": "TeaEntityLab/httpAPIService", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(feature = "for_ureq")] extern crate fp_rust; #[cfg(feature = "multipart")] extern crate formdata; #[cfg(feature = "multipart")] extern crate mime; #[cfg(feature = "multipart")] extern crate multer; #[cfg(feature = "for_serde")] extern crate serde; #[cfg(feature = "for_serde")] extern crate serde_j...
code_fim
medium
{ "lang": "rust", "repo": "TeaEntityLab/httpAPIService", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IreneKnapp/2020-advent-of-code path: /13/src/main.rs use advent_lib::prelude::*; use std::convert::TryFrom; fn main() -> Result<()> { let mut args = std::env::args(); if args.len() != 2 { eprintln!("Usage: advent input"); } let _ = args.next(); let filename = args.next().unwrap(...
code_fim
hard
{ "lang": "rust", "repo": "IreneKnapp/2020-advent-of-code", "path": "/13/src/main.rs", "mode": "psm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|> let timestamp = input[0].parse::<i64>()?; let mut busses: Vec<Option<i64>> = Vec::new(); for word in input[1].split(',') { if word == "x" { busses.push(None); } else { busses.push(Some(word.parse::<i64>().unwrap())); } } let mut best_bus = 0; let mut best_delay = time...
code_fim
hard
{ "lang": "rust", "repo": "IreneKnapp/2020-advent-of-code", "path": "/13/src/main.rs", "mode": "spm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yopox/LD49 path: /src/ui/drag_and_drop.rs use bevy::app::{AppBuilder, EventWriter, Plugin}; use bevy::ecs::prelude::*; use bevy::input::Input; use bevy::input::mouse::MouseButton; use bevy::math::{Vec2, Vec4Swizzles}; use bevy::prelude::Transform; use bevy::window::Windows; use crate::MainCamera...
code_fim
hard
{ "lang": "rust", "repo": "yopox/LD49", "path": "/src/ui/drag_and_drop.rs", "mode": "psm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_suffix|>fn drop_update( mut commands: Commands, mut ev_dropped: EventWriter<Dropped>, btn: Res<Input<MouseButton>>, dragged: Query<Entity, With<Dragged>>, ) { if btn.just_released(MouseButton::Left) { for e in dragged.iter() { commands.entity(e) .remove::<Dr...
code_fim
hard
{ "lang": "rust", "repo": "yopox/LD49", "path": "/src/ui/drag_and_drop.rs", "mode": "spm", "license": "CC0-1.0", "source": "the-stack-v2" }
<|fim_suffix|>pub fn mk_cli_matches<'a, 'b>() -> App<'a, 'b> where 'a: 'b, { App::new("Async example") .version(option_env!("CARGO_PKG_VERSION").unwrap_or("")) .about("Asynchronous computation example") .arg( Arg::with_name("jq_expression") .short("j") ...
code_fim
hard
{ "lang": "rust", "repo": "aaronlevin/kafka-jq", "path": "/src/cli/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aaronlevin/kafka-jq path: /src/cli/mod.rs extern crate clap; use self::clap::{App, Arg}; pub enum SerializationType { JSON, BSON, } pub struct TopicMetadata<'a> { pub name: &'a str, pub serialization: SerializationType, } pub enum SinkMetadata<'a> { StdOut, SinkTopic ...
code_fim
hard
{ "lang": "rust", "repo": "aaronlevin/kafka-jq", "path": "/src/cli/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MALIKMUHAMMADWAQAR/rust path: /variables.rs fn main() { let temperature = 23; println!("{}",temperature); <|fim_suffix|> let mut humidity = 54; println!("{}",humidity); //now i can change value of humidity as i insert mut keyword humidity = 34; println!("{}",humidi...
code_fim
easy
{ "lang": "rust", "repo": "MALIKMUHAMMADWAQAR/rust", "path": "/variables.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut humidity = 54; println!("{}",humidity); //now i can change value of humidity as i insert mut keyword humidity = 34; println!("{}",humidity); }<|fim_prefix|>// repo: MALIKMUHAMMADWAQAR/rust path: /variables.rs fn main() { let temperature = 23; println!("{}",temperatu...
code_fim
easy
{ "lang": "rust", "repo": "MALIKMUHAMMADWAQAR/rust", "path": "/variables.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/tracing/benches/span_no_fields.rs use criterion : : { criterion_group criterion_main Criterion } ; use tracing : : { span Level } ; mod shared ; fn bench ( c : & mut Criterion ) { shared : : for_all_recording ( & mu<|fim_suffix|>E " span " ) ) ...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/tracing/benches/span_no_fields.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>t c . benchmark_group ( " span_no_fields " ) | b | { b . iter ( | | span ! ( Level : : TRACE " span " ) ) } ) ; } criterion_group ! ( benches bench ) ; criterion_main ! ( benches ) ;<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/tracing/benches/span_no_fields.rs use criterion ...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/tracing/benches/span_no_fields.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> schema.to_owned() } // "Creating an item with an id field of type String with nanoid+length default" #[connector_test(schema(schema_nanoid_length))] async fn create_nanoid_id_with_length_should_work(runner: Runner) -> TestResult<()> { let res = run_query_json!( ...
code_fim
hard
{ "lang": "rust", "repo": "prisma/prisma-engines", "path": "/query-engine/connector-test-kit-rs/query-engine-tests/tests/writes/ids/nanoid.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let nanoid = match &res["data"]["createOneTodo"]["id"] { serde_json::Value::String(str) => str, _ => unreachable!(), }; assert_eq!(nanoid.len(), 21); Ok(()) } fn schema_nanoid_length() -> String { let schema = indoc! { ...
code_fim
hard
{ "lang": "rust", "repo": "prisma/prisma-engines", "path": "/query-engine/connector-test-kit-rs/query-engine-tests/tests/writes/ids/nanoid.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub struct OwnedRepr<T> { ptr: *mut T, } impl<T> OwnedRepr<T> { pub fn new(len: usize) -> Result<OwnedRepr<T>> { let mut ptr = ptr::null_mut(); unsafe { try_call!(cuda_sys::cudaMalloc(&mut ptr, mem::size_of::<T>() * len)) } Ok(OwnedRepr { ptr: ptr as *mut T }) } } imp...
code_fim
medium
{ "lang": "rust", "repo": "Hakuyume/rust-cuda", "path": "/cuda/src/memory/owned_repr.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl<T> Repr for OwnedRepr<T> { type Type = T; fn as_ptr(&self) -> *const T { self.ptr } } impl<T> ReprMut for OwnedRepr<T> { fn as_mut_ptr(&mut self) -> *mut T { self.ptr } }<|fim_prefix|>// repo: Hakuyume/rust-cuda path: /cuda/src/memory/owned_repr.rs use std::mem; ...
code_fim
medium
{ "lang": "rust", "repo": "Hakuyume/rust-cuda", "path": "/cuda/src/memory/owned_repr.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Hakuyume/rust-cuda path: /cuda/src/memory/owned_repr.rs use std::mem; use std::os::raw::c_void; use std::ptr; use cuda_sys; use Result; use super::{Repr, ReprMut}; <|fim_suffix|> self.ptr } } impl<T> ReprMut for OwnedRepr<T> { fn as_mut_ptr(&mut self) -> *mut T { self...
code_fim
hard
{ "lang": "rust", "repo": "Hakuyume/rust-cuda", "path": "/cuda/src/memory/owned_repr.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> foo.y = b.z //~^ ERROR } fn main() {}<|fim_prefix|>// repo: aatxe/oxide-test-suite path: /nll/issue-52742.rs #![feature(in_band_lifetimes)] struct Foo<'a, 'b> { x: &'a u32, y: &'b u32, } struct Bar<'b> { z: &'b u32, } <|fim_middle|>fn take_bar<'a, 'b, 'c>(foo: Foo<'a, 'b>, b: Bar<...
code_fim
easy
{ "lang": "rust", "repo": "aatxe/oxide-test-suite", "path": "/nll/issue-52742.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aatxe/oxide-test-suite path: /nll/issue-52742.rs #![feature(in_band_lifetimes)] <|fim_suffix|>fn take_bar<'a, 'b, 'c>(foo: Foo<'a, 'b>, b: Bar<'c>) { foo.y = b.z //~^ ERROR } fn main() {}<|fim_middle|>struct Foo<'a, 'b> { x: &'a u32, y: &'b u32, } struct Bar<'b> { z: &'b u...
code_fim
medium
{ "lang": "rust", "repo": "aatxe/oxide-test-suite", "path": "/nll/issue-52742.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: virtuoushub/Theseus path: /kernel/nano_core/src/interrupts/time_tools.rs use interrupts::pit_clock::TICKS; use core::sync::atomic::{AtomicUsize, Ordering}; //simply returns the tick count at the time it is called pub fn get_ticks() -> usize{ <|fim_suffix|>//could be used to test how many...
code_fim
hard
{ "lang": "rust", "repo": "virtuoushub/Theseus", "path": "/kernel/nano_core/src/interrupts/time_tools.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>//could be used to test how many PIC ticks a function takes to complete, initiate with ticks at start, set end ticks after function, and subtract //not properly tested: unsure what functions are running other than heartbeat function, which this can't be used on pub struct TimeKeeping{ pub start_time: ...
code_fim
hard
{ "lang": "rust", "repo": "virtuoushub/Theseus", "path": "/kernel/nano_core/src/interrupts/time_tools.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Traverse entire grid (we could start and the center and go out but this is fast enough) for i in 0..grid.len() { for j in 0..grid[0].len() { // Calculate distances for grid spaces that had both wires on them and aren't the center, record the minimum if (i != cent...
code_fim
hard
{ "lang": "rust", "repo": "heydabop/advent_of_code2019", "path": "/day03/part1/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: heydabop/advent_of_code2019 path: /day03/part1/src/main.rs enum Direction { Left(usize), Right(usize), Up(usize), Down(usize), } #[allow(clippy::cast_possible_truncation)] #[allow(clippy::cast_sign_loss)] fn main() { let input = match std::fs::read_to_string("../input") { ...
code_fim
hard
{ "lang": "rust", "repo": "heydabop/advent_of_code2019", "path": "/day03/part1/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut wire = 1; for line in input.lines() { // Record each wire in vector, starting at center port let mut x = center_x; let mut y = center_y; for seg in line.split(',') { match parse_direction(seg) { // A grid space will be either 0, 1...
code_fim
hard
{ "lang": "rust", "repo": "heydabop/advent_of_code2019", "path": "/day03/part1/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fujiehuang/leetcode-rust path: /189.rotate-array.rs /* * @lc app=leetcode id=189 lang=rust * * [189] Rotate Array */ // @lc code=start impl Solution { pub fn rotate(nums: &mut Vec<i32>, k: i32) { let mut ans = vec![0; nums.len()]; <|fim_suffix|> ans } } // @lc code=e...
code_fim
medium
{ "lang": "rust", "repo": "fujiehuang/leetcode-rust", "path": "/189.rotate-array.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> ans } } // @lc code=end<|fim_prefix|>// repo: fujiehuang/leetcode-rust path: /189.rotate-array.rs /* * @lc app=leetcode id=189 lang=rust * * [189] Rotate Array */ <|fim_middle|>// @lc code=start impl Solution { pub fn rotate(nums: &mut Vec<i32>, k: i32) { let mut ans = vec![0...
code_fim
hard
{ "lang": "rust", "repo": "fujiehuang/leetcode-rust", "path": "/189.rotate-array.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bonsairobo/nocturne path: /src/bin/cli.rs use nocturne::{ list_midi_input_ports, play_all_midi_tracks, play_midi_device, wave_table, MidiBytes, }; use std::path::PathBuf; use structopt::StructOpt; use time_calc::Bpm; use tokio::{select, signal}; #[derive(StructOpt, Debug)] #[structopt(name...
code_fim
hard
{ "lang": "rust", "repo": "bonsairobo/nocturne", "path": "/src/bin/cli.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[structopt(short = "b", long = "bpm")] bpm: u32, #[structopt(short = "r", long = "recording", parse(from_os_str))] recording_path: Option<PathBuf>, }, } // TODO: return Result fn main() { env_logger::init(); let mut runtime = tokio::runtime::Builder::new() ...
code_fim
hard
{ "lang": "rust", "repo": "bonsairobo/nocturne", "path": "/src/bin/cli.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let reading_voltage = reading as u32 * SUPPLY_VOLTAGE / self.adc.max_sample() as u32; (reading_voltage * VOLTAGE_FACTOR) as u16 } }<|fim_prefix|>// repo: DerFetzer/bike-distance-indicator path: /src/battery.rs use crate::types::{BatteryAdcType, BatteryChType}; use embedded_hal::adc::O...
code_fim
hard
{ "lang": "rust", "repo": "DerFetzer/bike-distance-indicator", "path": "/src/battery.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DerFetzer/bike-distance-indicator path: /src/battery.rs use crate::types::{BatteryAdcType, BatteryChType}; use embedded_hal::adc::OneShot; const SUPPLY_VOLTAGE: u32 = 3300; const LOW_BAT_THRESHOLD: u32 = 3450; const VOLTAGE_FACTOR: u32 = 2; <|fim_suffix|>pub struct BatteryMonitor { adc: Ba...
code_fim
medium
{ "lang": "rust", "repo": "DerFetzer/bike-distance-indicator", "path": "/src/battery.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let maybe_cfg: Option<Config> = serde_fs::from_fs(&config_dir).unwrap(); if maybe_cfg.is_none() { eprintln!("Config not found, creating one. You can edit it and re-run the example"); serde_fs::to_fs(&config_dir, &Config::default()).unwrap(); } let cfg: Config = serde_fs::...
code_fim
medium
{ "lang": "rust", "repo": "ErichDonGubler/serde_fs", "path": "/examples/config.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ErichDonGubler/serde_fs path: /examples/config.rs //! # Simple "config" example //! //! This example will create a default config if none is found (in `test_config` directory), //! or read existing one and will print it out as a JSON //! extern crate serde_fs; #[macro_use] extern crate serde_der...
code_fim
medium
{ "lang": "rust", "repo": "ErichDonGubler/serde_fs", "path": "/examples/config.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let cfg: Config = serde_fs::from_fs(&config_dir).unwrap(); println!("{}", serde_json::to_string_pretty(&cfg).unwrap()); }<|fim_prefix|>// repo: ErichDonGubler/serde_fs path: /examples/config.rs //! # Simple "config" example //! //! This example will create a default config if none is found (in `t...
code_fim
hard
{ "lang": "rust", "repo": "ErichDonGubler/serde_fs", "path": "/examples/config.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if let Some(only) = only { let only = Only::from_string(&only).map_err(|e| { ffx_error!("Invalid argument '{}' for '--only': {}\n{}", only, e, COMPONENT_LIST_HELP) })?; component.print(&only, verbose, 0); } else { // Default option is printing all compon...
code_fim
hard
{ "lang": "rust", "repo": "yueyedeai/fuchsia", "path": "/src/developer/ffx/plugins/component/list/src/lib.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yueyedeai/fuchsia path: /src/developer/ffx/plugins/component/list/src/lib.rs // Copyright 2020 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. use { anyhow::{Context, Result}, cs::{io::Dire...
code_fim
medium
{ "lang": "rust", "repo": "yueyedeai/fuchsia", "path": "/src/developer/ffx/plugins/component/list/src/lib.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> let mut v1 = std::vec::Vec::new(); let mut v2 = std::vec::Vec::new(); let sqrt = (m as f64).sqrt() as u64; for n in 2..sqrt { if m%n == 0 { v1.push(n); v2.push(m/n); } } v1.reserve(2*v1.len()); for n in v2.iter().rev() { v1.push...
code_fim
hard
{ "lang": "rust", "repo": "ScottBailey/project_euler", "path": "/p0003/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ScottBailey/project_euler path: /p0003/src/main.rs // https://projecteuler.net/problem=3 /* The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? */ fn main() { // problem source number let target : u64 = 600851475143; le...
code_fim
hard
{ "lang": "rust", "repo": "ScottBailey/project_euler", "path": "/p0003/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let sqrt = (m as f64).sqrt() as u64; for n in 2..sqrt { if m%n == 0 { v1.push(n); v2.push(m/n); } } v1.reserve(2*v1.len()); for n in v2.iter().rev() { v1.push(*n); } return v1; }<|fim_prefix|>// repo: ScottBailey/project_euler ...
code_fim
hard
{ "lang": "rust", "repo": "ScottBailey/project_euler", "path": "/p0003/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: JLLKerouac/Poker-Range-Trainer path: /src/toolbar.rs use iced::{button, Button, Container, Row, Text}; use iced_native::{Align, Length}; use crate::messages::Message; use crate::styles; <|fim_suffix|>impl ToolBar { pub fn view(&mut self) -> Container<Message> { Container::new( ...
code_fim
hard
{ "lang": "rust", "repo": "JLLKerouac/Poker-Range-Trainer", "path": "/src/toolbar.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl ToolBar { pub fn view(&mut self) -> Container<Message> { Container::new( Row::new() .width(Length::Fill) .align_items(Align::Center) .spacing(24) .push( Button::new(&mut self.study_button, Text...
code_fim
hard
{ "lang": "rust", "repo": "JLLKerouac/Poker-Range-Trainer", "path": "/src/toolbar.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: timfish/bincode-typescript path: /tests/tests.rs pub mod test_types; #[cfg(test)] mod test_round_trip { use serde::{de::DeserializeOwned, Serialize}; use super::test_types::*; use std::{ fmt::Debug, fs, io::Write, path::Path, proc...
code_fim
hard
{ "lang": "rust", "repo": "timfish/bincode-typescript", "path": "/tests/tests.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> return api.writeSomeEvent(expected); ", ); } #[test] fn unnamed_optional_vec() { generate_and_run( SomeEvent::UnnamedOptVec(Some(vec![128; 1000])), " let val = api.readSomeEvent(buffer); let arr = new Uint8Arra...
code_fim
hard
{ "lang": "rust", "repo": "timfish/bincode-typescript", "path": "/tests/tests.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> return api.writeSomeEvent(expected); ", ); } #[test] fn hashmap() { generate_and_run( SomeEvent::UnnamedHashMap(Some( vec![ ("One".to_string(), Some(UnitEnum::One)), ("Two".to_string...
code_fim
hard
{ "lang": "rust", "repo": "timfish/bincode-typescript", "path": "/tests/tests.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> { let mut data = client.data.write().await; data.insert::<util::ClientShardManager>(Arc::clone(&client.shard_manager)); data.insert::<util::DbPool>(Arc::clone(&pool)); data.insert::<Settings>(Arc::new(cfg)); } client.start_autosharded().await.map_err(|e| e.into...
code_fim
hard
{ "lang": "rust", "repo": "alecks/kioto", "path": "/src/discord/mod.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alecks/kioto path: /src/discord/mod.rs mod commands; mod util; use serenity::{ async_trait, client::{Client, Context, EventHandler}, framework::standard::{ help_commands, macros::{help, hook}, Args, CommandGroup, CommandResult, HelpOptions, StandardFramework,...
code_fim
hard
{ "lang": "rust", "repo": "alecks/kioto", "path": "/src/discord/mod.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> (owners, info.id) } Err(why) => fatal!("Couldn't get app info: {:?}", why), }; let framework = StandardFramework::new() .configure(|c| { c.prefix(&cfg.bot.prefix) .on_mention(Some(bot_id)) .owners(owners) }) ...
code_fim
hard
{ "lang": "rust", "repo": "alecks/kioto", "path": "/src/discord/mod.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }