text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|>impl BudgetDetail { pub fn new(id: String, name: String) -> BudgetDetail { BudgetDetail { id, name, last_modified_on: None, first_month: None, last_month: None, date_format: None, currency_format: None, ...
code_fim
hard
{ "lang": "rust", "repo": "doy/ynab-api", "path": "/src/models/budget_detail.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: doy/ynab-api path: /src/models/budget_detail.rs /* * YNAB API Endpoints * * Our API uses a REST based design, leverages the JSON data format, and relies upon HTTPS for transport. We respond with meaningful HTTP response codes and if an error occurs, we include error details in the response bo...
code_fim
hard
{ "lang": "rust", "repo": "doy/ynab-api", "path": "/src/models/budget_detail.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jdlambert/advent-of-code-2019 path: /day22/src/main.rs use std::fs; extern crate regex; use regex::Regex; enum Action { Deal(i128), Cut(i128), Stack, } fn part1(actions: &Vec<Action>) -> i128 { let len = 10007; actions.iter().fold(2019, |i, action| match action { Ac...
code_fim
hard
{ "lang": "rust", "repo": "jdlambert/advent-of-code-2019", "path": "/day22/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> const LEN: i128 = 119_315_717_514_047; const TIMES: i128 = 101_741_582_076_661; let (offset_diff, increment_mul) = actions .clone() .iter() .fold((0, 1), |(offset, increment), action| { let (new_offset, new_increment) = match action ...
code_fim
hard
{ "lang": "rust", "repo": "jdlambert/advent-of-code-2019", "path": "/day22/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let increment = mod_exp(increment_mul, TIMES, LEN); let offset = offset_diff * (1 - mod_exp(increment_mul, TIMES, LEN)) % LEN; let offset = offset * mod_exp(1 - increment_mul, LEN - 2, LEN) % LEN; (offset + increment * 2020) % LEN } fn main() { let new_stack_re: Regex = Regex::new(r#...
code_fim
hard
{ "lang": "rust", "repo": "jdlambert/advent-of-code-2019", "path": "/day22/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: muscad-io/MusCAD path: /muscad-core/src/sealed/vector2d/angle.rs use super::*; pub fn angle_between<U, V, T>(u: &U, v: &V) -> T where U: AsV3d<T>, V: AsV3d<T>, T: Float, { let u = u.as_ref(); let v = v.as_ref(); let a1 = u[Y].clone().atan2(u[X].clone()); let mut a2 ...
code_fim
medium
{ "lang": "rust", "repo": "muscad-io/MusCAD", "path": "/muscad-core/src/sealed/vector2d/angle.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests { use super::*; #[test] fn test_v2d_angle_between() { let v1 = [1.0, 0.0]; let v2 = [0.0, 1.0]; let v3 = [0.0, -1.0]; assert_eq!(angle_between(&v1, &v2), f64::PI / 2.0); assert_eq!(angle_between(&v1, &v3), -f64::PI / 2.0); ...
code_fim
medium
{ "lang": "rust", "repo": "muscad-io/MusCAD", "path": "/muscad-core/src/sealed/vector2d/angle.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!( "{}", (0..1000) .scan(Some(BigRational::new(zero(), one())), |ratio, _| { let r = one::<BigRational>() / (ratio.take().unwrap() + BigRational::from_integer(BigInt::from(2))); *ratio = Some(r.clone()); ...
code_fim
medium
{ "lang": "rust", "repo": "TAKEDA-Takashi/rust-project-euler", "path": "/project-euler/src/bin/problem-057.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TAKEDA-Takashi/rust-project-euler path: /project-euler/src/bin/problem-057.rs //! https://projecteuler.net/problem=57 //! //! 2の平方根は無限に続く連分数で表すことができる. //! //! √ 2 = 1 + 1/(2 + 1/(2 + 1/(2 + ... ))) = 1.414213... //! 最初の4回の繰り返しを展開すると以下が得られる. //! //! 1 + 1/2 = 3/2 = 1.5 //! 1 + 1/(2 + 1/2) = 7/5 =...
code_fim
hard
{ "lang": "rust", "repo": "TAKEDA-Takashi/rust-project-euler", "path": "/project-euler/src/bin/problem-057.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> *ratio = Some(r.clone()); Some(r + one::<BigRational>()) }) .filter(|ratio| ratio.numer().to_string().len() > ratio.denom().to_string().len()) .count() ); }<|fim_prefix|>// repo: TAKEDA-Takashi/rust-project-euler path: /project-euler...
code_fim
hard
{ "lang": "rust", "repo": "TAKEDA-Takashi/rust-project-euler", "path": "/project-euler/src/bin/problem-057.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: inferiorhumanorgans/sam3x8e-fork path: /src/usart3/csr_spi_mode.rs #[doc = r" Value read from the register"] pub struct R { bits: u32, } impl super::CSR_SPI_MODE { #[doc = r" Reads the contents of the register"] #[inline] pub fn read(&self) -> R { R { bits: se...
code_fim
hard
{ "lang": "rust", "repo": "inferiorhumanorgans/sam3x8e-fork", "path": "/src/usart3/csr_spi_mode.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>nst MASK: bool = true; const OFFSET: u8 = 3; ((self.bits >> OFFSET) & MASK as u32) != 0 }; ENDRXR { bits } } #[doc = "Bit 4"] #[inline] pub fn endtx(&self) -> ENDTXR { let bits = { const MASK: bool = true; const OFFSET...
code_fim
hard
{ "lang": "rust", "repo": "inferiorhumanorgans/sam3x8e-fork", "path": "/src/usart3/csr_spi_mode.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: briansmith/ring path: /tests/ed25519_tests.rs // Copyright 2015-2017 Brian Smith. // // Permission to use, copy, modify, and/or distribute this software for any // purpose with or without fee is hereby granted, provided that the above // copyright notice and this permission notice appear in all ...
code_fim
hard
{ "lang": "rust", "repo": "briansmith/ring", "path": "/tests/ed25519_tests.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> const PRIVATE_KEY: &[u8] = include_bytes!("ed25519_test_private_key.bin"); const PUBLIC_KEY: &[u8] = include_bytes!("ed25519_test_public_key.bin"); assert!(Ed25519KeyPair::from_seed_and_public_key(PRIVATE_KEY, PUBLIC_KEY).is_ok()); // Truncated private key. assert!(Ed25519KeyPair::fr...
code_fim
hard
{ "lang": "rust", "repo": "briansmith/ring", "path": "/tests/ed25519_tests.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> // Start the server let point = ([127, 0, 0, 1], 8080); warp::serve(api).run(point).await; }<|fim_prefix|>// repo: Tullsworth/gradecoin path: /src/bin/main.rs use drocoin::routes::consensus_routes; use drocoin::schema::create_database; <|fim_middle|>#[tokio::main] async fn main() { log4r...
code_fim
medium
{ "lang": "rust", "repo": "Tullsworth/gradecoin", "path": "/src/bin/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Tullsworth/gradecoin path: /src/bin/main.rs use drocoin::routes::consensus_routes; use drocoin::schema::create_database; <|fim_suffix|> // Start the server let point = ([127, 0, 0, 1], 8080); warp::serve(api).run(point).await; }<|fim_middle|>#[tokio::main] async fn main() { log4r...
code_fim
medium
{ "lang": "rust", "repo": "Tullsworth/gradecoin", "path": "/src/bin/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let size = 10000000; println!("\nSorting arrays of size {}", size); let mut total = 0; for i in 0..25{ let time = run_benchmark(size); total += time.as_millis(); println!("\tSorted array {}, took {}ms", i, time.as_millis()); } println!("...
code_fim
hard
{ "lang": "rust", "repo": "cartermcgee/rust_vs_cpp", "path": "/QuickSort/quick_sort.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cartermcgee/rust_vs_cpp path: /QuickSort/quick_sort.rs use std::time::{Duration, Instant}; fn run_benchmark(size: u32) -> Duration{ let mut vec = make_rand_vec(size); let now = Instant::now(); quick_sort(&mut vec); return now.elapsed() } fn quick_sort(array: &mut [i32]...
code_fim
hard
{ "lang": "rust", "repo": "cartermcgee/rust_vs_cpp", "path": "/QuickSort/quick_sort.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: konradmoesch/rust_asio path: /src/core/mod.rs use ffi::{c_void, sockaddr, socklen_t, AsRawFd, RawFd}; mod callstack; use self::callstack::ThreadCallStack; mod exec; pub use self::exec::{IoContext, AsIoContext, IoContextWork, Exec, Perform, ThreadIoContext}; <|fim_suffix|> /// Returns a val...
code_fim
hard
{ "lang": "rust", "repo": "konradmoesch/rust_asio", "path": "/src/core/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self as *mut _ as *mut _ } unsafe fn resize(&mut self, _len: u32) {} } pub trait SetSocketOption<P>: SocketOption<P> { fn as_ptr(&self) -> *const c_void { self as *const _ as *const _ } fn size(&self) -> u32 { self.capacity() } } pub trait Cancel: AsIoCo...
code_fim
hard
{ "lang": "rust", "repo": "konradmoesch/rust_asio", "path": "/src/core/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub trait GetSocketOption<P>: SocketOption<P> + Default { fn as_mut_ptr(&mut self) -> *mut c_void { self as *mut _ as *mut _ } unsafe fn resize(&mut self, _len: u32) {} } pub trait SetSocketOption<P>: SocketOption<P> { fn as_ptr(&self) -> *const c_void { self as *const _ ...
code_fim
hard
{ "lang": "rust", "repo": "konradmoesch/rust_asio", "path": "/src/core/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>// Overwriting NeedsStop methods impl Stop { /// Next bus arrivals at this stop. /// [WMATA Documentation](https://developer.wmata.com/docs/services/5476365e031f590f38092508/operations/5476365e031f5909e4fe331d) /// /// # Examples /// ``` /// use wmata::Stop; /// use tokio_test:...
code_fim
hard
{ "lang": "rust", "repo": "emma-k-alexandra/wmata", "path": "/src/bus/stop.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: emma-k-alexandra/wmata path: /src/bus/stop.rs //! MetroBus Stop related structs and methods. use crate::{ bus::{client::responses, traits::NeedsStop}, error::Error, requests::Fetch, Date, }; use serde::{ de::{Deserializer, Error as SerdeError}, Deserialize, }; #[derive(D...
code_fim
hard
{ "lang": "rust", "repo": "emma-k-alexandra/wmata", "path": "/src/bus/stop.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> /// Buses scheduled at this stop for an optional given date. /// [WMATA Documentation](https://developer.wmata.com/docs/services/54763629281d83086473f231/operations/5476362a281d830c946a3d6c?) /// /// # Date /// Omit date for current date /// /// # Examples /// ``` /// u...
code_fim
hard
{ "lang": "rust", "repo": "emma-k-alexandra/wmata", "path": "/src/bus/stop.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: slinkydeveloper/extending-kubernetes-api-in-process-poc path: /kube-rs/src/api/typed.rs use either::Either; use serde::{de::DeserializeOwned, Serialize}; use std::iter; use crate::{ api::{ DeleteParams, ListParams, Meta, ObjectList, PatchParams, PostParams, Resource, }, clie...
code_fim
hard
{ "lang": "rust", "repo": "slinkydeveloper/extending-kubernetes-api-in-process-poc", "path": "/kube-rs/src/api/typed.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Delete a collection of resources /// /// When you get an `ObjectList<K>` via `Left`, your delete has started. /// When you get a `Status` via `Right`, this should be a a 2XX style /// confirmation that the object being gone. /// /// 4XX and 5XX status types are returned as ...
code_fim
hard
{ "lang": "rust", "repo": "slinkydeveloper/extending-kubernetes-api-in-process-poc", "path": "/kube-rs/src/api/typed.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tawaren/Sanskrit path: /sanskrit_test_script_compiler/src/generate.rs use model::*; use environment::*; use std::collections::HashMap; use sanskrit_core::model::{OpCode as ROpCode, TypeRef, Field}; use sanskrit_core::model::Accessibility as RVisibility; use sanskrit_core::model::Case as RCa...
code_fim
hard
{ "lang": "rust", "repo": "tawaren/Sanskrit", "path": "/sanskrit_test_script_compiler/src/generate.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> OpCode::Unpack(ref assigs, ref val, ref typ) => { let from_v = env.get_id_pos(&val).unwrap(); let r_typ = imp.import_perm_ref(&(Perm::Consume,typ.clone()))?; for assig in assigs { env.push_new(assig.clone()); ...
code_fim
hard
{ "lang": "rust", "repo": "tawaren/Sanskrit", "path": "/sanskrit_test_script_compiler/src/generate.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> OpCode::UnProject(ref to_id, ref from_id, ref typ) => { let from_v = env.get_id_pos(&from_id).unwrap(); let t = imp.import_typ_ref(&typ)?; env.push_new(to_id.clone()); Ok(ROpCode::UnProject(t, from_v)) }, ...
code_fim
hard
{ "lang": "rust", "repo": "tawaren/Sanskrit", "path": "/sanskrit_test_script_compiler/src/generate.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[macro_export] /// Create a `Vec3` from components. This macro takes an optional conversion parameter which must be /// a function. It will be applied to each element of the vector before construction. /// /// ```rust /// #[macro_use] /// extern crate isoengine; /// /// use std::num::Float; /// ...
code_fim
hard
{ "lang": "rust", "repo": "lambdacat/isoengine", "path": "/src/math/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lambdacat/isoengine path: /src/math/mod.rs // Copyright (c) 2015, Sam Payson // // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and // associated documentation files (the "Software"), to deal in the Software without restriction, // including witho...
code_fim
hard
{ "lang": "rust", "repo": "lambdacat/isoengine", "path": "/src/math/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: redox-os/ion path: /members/ranges/src/select.rs use super::{parse_index_range, Index, Range}; use std::{ iter::{empty, FromIterator}, str::FromStr, }; /// Represents a filter on a vector-like object #[derive(Debug, PartialEq, Clone)] pub enum Select<K> { /// Select all elements ...
code_fim
hard
{ "lang": "rust", "repo": "redox-os/ion", "path": "/members/ranges/src/select.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn select<O, K>(&mut self, s: &Select<K>, size: usize) -> O where O: FromIterator<Self::Item>, { match s { Select::Key(_) => empty().collect(), Select::All => self.collect(), Select::Index(Index::Forward(idx)) => self.nth(*idx).into_iter().co...
code_fim
hard
{ "lang": "rust", "repo": "redox-os/ion", "path": "/members/ranges/src/select.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>orestTrustInformationW( ServerName: LPCWSTR, TrustedDomainName: LPCWSTR, Flags: DWORD, ForestTrustInfo: *mut PLSA_FOREST_TRUST_INFORMATION, ) -> DWORD; pub fn DsMergeForestTrustInformationW( DomainName: LPCWSTR, NewForestTrustInfo: PLSA_FOREST_TRUST_...
code_fim
hard
{ "lang": "rust", "repo": "chromium/chromium", "path": "/third_party/rust/winapi/v0_3/crate/src/um/dsgetdc.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>me: LPCWSTR, SiteName: *mut LPWSTR, ) -> DWORD; pub fn DsValidateSubnetNameW( SubnetName: LPCWSTR, ) -> DWORD; pub fn DsValidateSubnetNameA( SubnetName: LPCSTR, ) -> DWORD; pub fn DsAddressToSiteNamesW( ComputerName: LPCWSTR, EntryCount: DWOR...
code_fim
hard
{ "lang": "rust", "repo": "chromium/chromium", "path": "/third_party/rust/winapi/v0_3/crate/src/um/dsgetdc.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chromium/chromium path: /third_party/rust/winapi/v0_3/crate/src/um/dsgetdc.rs // Licensed under the Apache License, Version 2.0 // <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. // All file...
code_fim
hard
{ "lang": "rust", "repo": "chromium/chromium", "path": "/third_party/rust/winapi/v0_3/crate/src/um/dsgetdc.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Serbis/sealrs path: /src/examples/actors/stash/example.rs use crate::actors::prelude::*; use crate::examples::actors::stash::behactor; use std::sync::{Mutex, Arc}; use std::thread; pub fn run() { <|fim_suffix|> let mut system = LocalActorSystem::new(); let mut actor = system .a...
code_fim
hard
{ "lang": "rust", "repo": "Serbis/sealrs", "path": "/src/examples/actors/stash/example.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut actor = system .actor_of(behactor::props(), None); actor.tell(msg!(behactor::MessageA {}), None); actor.tell(msg!(behactor::MessageB {}), None); actor.tell(msg!(behactor::MessageC {}), None); actor.tell(msg!(behactor::MessageD {}), None); thread::park() }<|fim_pre...
code_fim
medium
{ "lang": "rust", "repo": "Serbis/sealrs", "path": "/src/examples/actors/stash/example.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TomboFry/creature-evolution path: /src/lib.rs extern crate rand; extern crate time; extern crat<|fim_suffix|>ion; pub mod optimisationmethods; pub mod physics;<|fim_middle|>e rayon; #[cfg(test)] #[macro_use] extern crate assert_approx_eq; pub mod creature; pub mod populat
code_fim
medium
{ "lang": "rust", "repo": "TomboFry/creature-evolution", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>ion; pub mod optimisationmethods; pub mod physics;<|fim_prefix|>// repo: TomboFry/creature-evolution path: /src/lib.rs extern crate rand; extern crate time; extern crat<|fim_middle|>e rayon; #[cfg(test)] #[macro_use] extern crate assert_approx_eq; pub mod creature; pub mod populat
code_fim
medium
{ "lang": "rust", "repo": "TomboFry/creature-evolution", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>sert_approx_eq; pub mod creature; pub mod population; pub mod optimisationmethods; pub mod physics;<|fim_prefix|>// repo: TomboFry/creature-evolution path: /src/lib.rs extern crate rand; extern crate time; extern crat<|fim_middle|>e rayon; #[cfg(test)] #[macro_use] extern crate as
code_fim
easy
{ "lang": "rust", "repo": "TomboFry/creature-evolution", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[cfg(not(test))] { let _ = logger::fini(); } } #[cfg(feature = "runtime_tests")] fn runtime_tests() { info!("Executing runtime tests..."); info!("Runtime tests succeeded"); }<|fim_prefix|>// repo: tathanhdinh/rustyvisor path: /src/lib.rs #![no_std] #![feature(asm)] #![featur...
code_fim
hard
{ "lang": "rust", "repo": "tathanhdinh/rustyvisor", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tathanhdinh/rustyvisor path: /src/lib.rs #![no_std] #![feature(asm)] #![feature(const_fn)] #![feature(lang_items)] #![allow(unknown_lints)] use ::log::{error, info, log}; pub mod runtime; pub mod vmx; #[cfg(not(test))] mod serial_logger; #[cfg(not(test))] use serial_logger as logger; <|fim_s...
code_fim
hard
{ "lang": "rust", "repo": "tathanhdinh/rustyvisor", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[repr(C)] pub struct PerCoreData { vmxon_region: *mut u8, vmcs: *mut u8, vmxon_region_phys: u64, vmcs_phys: u64, vmxon_region_size: usize, vmcs_size: usize, loaded_successfully: bool, } #[no_mangle] pub extern "C" fn rustyvisor_load() -> i32 { #[cfg(not(test))] { ...
code_fim
hard
{ "lang": "rust", "repo": "tathanhdinh/rustyvisor", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Fimasik/reql path: /src/lib.rs //! A native RethinkDB driver written in Rust #[macro_use] extern crate reql_derive; extern crate ql2; extern crate protobuf; extern crate serde_json; #[macro_use] extern crate derive_error; #[cfg(feature = "with_io")] extern crate reql_io; #[macro_use] extern cra...
code_fim
hard
{ "lang": "rust", "repo": "Fimasik/reql", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> *self == Term::new() } } impl Encode for Vec<TA> { fn encode(&self) -> String { let mut opts = String::from("{"); for term in self { opts.push_str(&format!("\"{}\":{},", term.get_key(), term.get_val().encode())); } opts = opts.trim_right_matches...
code_fim
hard
{ "lang": "rust", "repo": "Fimasik/reql", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Encode for Vec<TA> { fn encode(&self) -> String { let mut opts = String::from("{"); for term in self { opts.push_str(&format!("\"{}\":{},", term.get_key(), term.get_val().encode())); } opts = opts.trim_right_matches(",").to_string(); opts.push_s...
code_fim
hard
{ "lang": "rust", "repo": "Fimasik/reql", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: samcday/m451 path: /pac/src/uart1/uart_linctl.rs o()) } #[doc = "LIN frame ID parity Disabled"] #[inline(always)] pub fn _0(self) -> &'a mut W { self.variant(IDPEN_A::_0) } #[doc = "LIN frame ID parity Enabled"] #[inline(always)] pub fn _1(self) -> &'a mut...
code_fim
hard
{ "lang": "rust", "repo": "samcday/m451", "path": "/pac/src/uart1/uart_linctl.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> &self.0 } } #[doc = "Field `HSEL` writer - LIN Header Select"] pub struct HSEL_W<'a> { w: &'a mut W, } impl<'a> HSEL_W<'a> { #[doc = r"Writes `variant` to the field"] #[inline(always)] pub fn variant(self, variant: HSEL_A) -> &'a mut W { self.bits(variant.into()) } ...
code_fim
hard
{ "lang": "rust", "repo": "samcday/m451", "path": "/pac/src/uart1/uart_linctl.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> variant as _ } } #[doc = "Field `HSEL` reader - LIN Header Select"] pub struct HSEL_R(crate::FieldReader<u8, HSEL_A>); impl HSEL_R { pub(crate) fn new(bits: u8) -> Self { HSEL_R(crate::FieldReader::new(bits)) } #[doc = r"Get enumerated values variant"] #[inline(always)]...
code_fim
hard
{ "lang": "rust", "repo": "samcday/m451", "path": "/pac/src/uart1/uart_linctl.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fbenkstein/advent-of-code path: /gabriel/day15/src/parser.rs use std::cmp::{Ord, Ordering, PartialOrd}; use std::collections::BTreeMap; use std::collections::BTreeSet; use std::collections::HashSet; use std::collections::VecDeque; use std::fmt; use std::str::FromStr; use log::debug; #[derive(D...
code_fim
hard
{ "lang": "rust", "repo": "fbenkstein/advent-of-code", "path": "/gabriel/day15/src/parser.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // all reachable points around me // cheapest move is the one with the lowest distance AND first in readability order let mut around_unit = HashSet::new(); let pts = Unit::points_around(unit.x, unit.y); around_unit.extend(pts.into_iter()); ...
code_fim
hard
{ "lang": "rust", "repo": "fbenkstein/advent-of-code", "path": "/gabriel/day15/src/parser.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // intersect with the ennemy next tiles // find nearest // TODO: is this where it's better to use a priority queue? (i.e. do everything in one operation) let mut nearest_tiles: BTreeMap<usize, Vec<(usize, usize)>> = BTreeMap::new(); for (x, y) in in_range.intersecti...
code_fim
hard
{ "lang": "rust", "repo": "fbenkstein/advent-of-code", "path": "/gabriel/day15/src/parser.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: innerop/stun3489 path: /src/lib.rs #![feature(pin)] #![feature(await_macro, async_await, futures_api)] extern crate byteorder; extern crate rand; extern crate ring; extern crate futures; #[macro_use] extern crate log; extern crate env_logger; extern crate bytes; pub mod codec; pub use crate::c...
code_fim
hard
{ "lang": "rust", "repo": "innerop/stun3489", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> tokio::run_async(async { let bind_addr = SocketAddr::from(([0, 0, 0, 0], 0)); let sock = UdpSocket::bind(&bind_addr).unwrap(); let (sink, stream) = UdpFramed::new(sock, StunCodec).split(); let stream = stream.timeout(Duration::from_secs(1)); let stream = stream...
code_fim
hard
{ "lang": "rust", "repo": "innerop/stun3489", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> setup_logging(); let tests_dir = tempfile::tempdir().expect("failed to create mountpoint tmpdir"); let cfg = Config { view: TEST_VIEW, bucket: CTHON_BASIC_BUCKET, addresses: Arc::new(AddressBook::with_addresses(vec![String::from( ANTIDOTE_URL, )])),...
code_fim
hard
{ "lang": "rust", "repo": "AntidoteDB/elmerfs", "path": "/tests/cthon.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AntidoteDB/elmerfs path: /tests/cthon.rs use elmerfs::{AddressBook, Bucket, Config, View}; use std::ffi::OsString; use std::fs; use std::path::Path; use std::process::{Command, Stdio}; use std::sync::Arc; use std::thread; use std::time::Duration; use tempfile; use tracing::info; use tracing_subs...
code_fim
hard
{ "lang": "rust", "repo": "AntidoteDB/elmerfs", "path": "/tests/cthon.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let tests_dir = tempfile::tempdir().expect("failed to create mountpoint tmpdir"); let cfg = Config { view: TEST_VIEW, bucket: CTHON_BASIC_BUCKET, addresses: Arc::new(AddressBook::with_addresses(vec![String::from( ANTIDOTE_URL, )])), locks: true, ...
code_fim
hard
{ "lang": "rust", "repo": "AntidoteDB/elmerfs", "path": "/tests/cthon.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: y-yagi/til path: /leetcode/shuffle-an-array/rust/src/lib.rs use rand::distributions::Uniform; use rand::prelude::*; struct Solution { origin: Vec<i32>, shuffled: Vec<i32>, rng: ThreadRng, } /** * `&self` means the method takes an immutable reference. * If you need a mutable refer...
code_fim
medium
{ "lang": "rust", "repo": "y-yagi/til", "path": "/leetcode/shuffle-an-array/rust/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /** Returns a random shuffling of the array. */ fn shuffle(&mut self) -> Vec<i32> { let n = self.shuffled.len(); // NOTE: Fisher–Yates shuffle for i in 0..(n - 1) { let uniform = Uniform::from(i..n); let j = self.rng.sample(uniform); self...
code_fim
medium
{ "lang": "rust", "repo": "y-yagi/til", "path": "/leetcode/shuffle-an-array/rust/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cpmech/gemlab path: /src/shapes/qua9.rs use russell_lab::{Matrix, Vector}; /// Defines a quadrilateral with 9 nodes (quadratic edges; interior node) /// /// ![qua9](https://raw.githubusercontent.com/cpmech/gemlab/main/data/figures/test_draw_shape_qua9.svg) /// /// # Local IDs of nodes /// /// `...
code_fim
hard
{ "lang": "rust", "repo": "cpmech/gemlab", "path": "/src/shapes/qua9.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> deriv.set(0, 0, (r + r - 1.0) * s * (s - 1.0) / 4.0); deriv.set(1, 0, (r + r + 1.0) * s * (s - 1.0) / 4.0); deriv.set(2, 0, (r + r + 1.0) * s * (s + 1.0) / 4.0); deriv.set(3, 0, (r + r - 1.0) * s * (s + 1.0) / 4.0); deriv.set(0, 1, r * (r - 1.0) * (s + s - 1.0) / 4...
code_fim
hard
{ "lang": "rust", "repo": "cpmech/gemlab", "path": "/src/shapes/qua9.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/sys/component_manager/src/framework/realm_query.rs rovider::query( self, component.abs_moniker.clone(), ))); } } } Ok(()) } /// Create the instance...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/sys/component_manager/src/framework/realm_query.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> // Component Manager serves the namespace dir with the `foo` protocol. let ns_dir = resolved.ns_dir.into_proxy().unwrap(); let entries = fuchsia_fs::directory::readdir(&ns_dir).await.unwrap(); assert_eq!( entries, vec![ fuchsia_fs::di...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/sys/component_manager/src/framework/realm_query.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/sys/component_manager/src/framework/realm_query.rs = self.model.find(&moniker).await.ok_or(fsys::RealmQueryError::InstanceNotFound)?; let resolved = instance.create_fidl_resolved_state().await; let instance_id = self.model.component_id_i...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/sys/component_manager/src/framework/realm_query.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: little-dude/ofpkt path: /src/packets/hello/mod.rs //! Types to parse and emit Hello messages mod bitmap; mod element; use {Error, Repr, Result}; use byteorder::{ByteOrder, NetworkEndian}; pub use self::bitmap::{Bitmap, BitmapRepr}; pub use self::element::{Element, ElementData, ElementRepr, Kin...
code_fim
hard
{ "lang": "rust", "repo": "little-dude/ofpkt", "path": "/src/packets/hello/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn hello_element_repr() -> ElementRepr { ElementRepr { kind: Kind::Bitmap, payload: ElementData::Bitmap(BitmapRepr(0x12)), } } #[test] fn test_parse() { let repr = openflow::PacketRepr::<OxmExperimenter>::parse(&BYTES).unwrap(); if l...
code_fim
hard
{ "lang": "rust", "repo": "little-dude/ofpkt", "path": "/src/packets/hello/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tonimctoni/rustcrawl path: /src/crawl_worker.rs #![allow(dead_code)] use url; use reqwest; use regex; use std::sync; use bloom_filter; use url_reservoir; use thread; use std::time; const MAX_URLS_PER_SITE: usize = 100; const SLEEP_SECONDS_PER_LOOP: u64 = 1; /// Composite error structure for ea...
code_fim
hard
{ "lang": "rust", "repo": "tonimctoni/rustcrawl", "path": "/src/crawl_worker.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Check if url has been crawled already. If not, add to bloom_filter and go on. If yes, continue. let url_has_been_used={ let mut mutex_guard=match bloom_filter.lock() { Ok(mutex_guard) => mutex_guard, Err(e) => {eprintln!("Error: {:?}", e);brea...
code_fim
hard
{ "lang": "rust", "repo": "tonimctoni/rustcrawl", "path": "/src/crawl_worker.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xoyo24/nushell path: /crates/nu-command/src/shells/n.rs use nu_engine::current_dir; use nu_protocol::ast::Call; use nu_protocol::engine::{Command, EngineState, Stack}; use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, Value}; /// Source a file for environment variables. ...
code_fim
hard
{ "lang": "rust", "repo": "xoyo24/nushell", "path": "/crates/nu-command/src/shells/n.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Ok(PipelineData::new(call.head)) } fn examples(&self) -> Vec<Example> { vec![ Example { description: "Make two directories and enter new shells for them, use `n` to jump to the next shell", example: r#"mkdir foo bar; enter foo; enter ../...
code_fim
hard
{ "lang": "rust", "repo": "xoyo24/nushell", "path": "/crates/nu-command/src/shells/n.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> stack.add_env_var("PWD".into(), new_path); Ok(PipelineData::new(call.head)) } fn examples(&self) -> Vec<Example> { vec![ Example { description: "Make two directories and enter new shells for them, use `n` to jump to the next shell", ...
code_fim
hard
{ "lang": "rust", "repo": "xoyo24/nushell", "path": "/crates/nu-command/src/shells/n.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rcoh/angle-grinder path: /src/printer.rs do any terminals not support unicode anymore? If so it would be nice to detect that // and display "..." instead const ELLIPSIS: &str = "…"; fn format_with_ellipsis<S: Into<String>>(inp: S, limit: usize) -> String { let inp = inp.into(); if inp....
code_fim
hard
{ "lang": "rust", "repo": "rcoh/angle-grinder", "path": "/src/printer.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rcoh/angle-grinder path: /src/printer.rs ttyPrinter { render_config: RenderConfig, column_widths: HashMap<String, usize>, column_order: Vec<String>, term_size: Option<TerminalSize>, } // MAYBE TODO: do any terminals not support unicode anymore? If so it would be nice to detect t...
code_fim
hard
{ "lang": "rust", "repo": "rcoh/angle-grinder", "path": "/src/printer.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn print_raw() { let rec = Record::new("Hello, World!\n"); let render_config = RenderConfig { display_config: DisplayConfig { floating_points: 2 }, min_buffer: 1, max_buffer: 4, }; let display_config = DisplayConfig { floa...
code_fim
hard
{ "lang": "rust", "repo": "rcoh/angle-grinder", "path": "/src/printer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zimond/seed path: /examples/canvas/src/lib.rs //! [Web-sys docs](https://rustwasm.github.io/wasm-bindgen/api/web_sys/struct.CanvasRenderingContext2d.html) //! [Web-sys example](https://rustwasm.github.io/wasm-bindgen/examples/2d-canvas.html) //! [MDN](https://developer.mozilla.org/en-US/docs/Web...
code_fim
hard
{ "lang": "rust", "repo": "zimond/seed", "path": "/examples/canvas/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn draw(fill_color: Color) { let canvas = seed::canvas(CANVAS_ID).unwrap(); let ctx = seed::canvas_context_2d(&canvas); ctx.rect(0., 0., 200., 100.); ctx.set_fill_style(&JsValue::from_str(fill_color)); ctx.fill(); ctx.move_to(0., 0.); ctx.line_to(200., 100.); ctx.stroke()...
code_fim
hard
{ "lang": "rust", "repo": "zimond/seed", "path": "/examples/canvas/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>// Update #[derive(Copy, Clone)] enum Msg { Rendered, ChangeColor, } fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) { match msg { Msg::Rendered => { draw(model.fill_color); // We want to call `.skip` to prevent infinite loop. ...
code_fim
hard
{ "lang": "rust", "repo": "zimond/seed", "path": "/examples/canvas/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn check(&self, dtc: u8) -> bool { *self & (1 << dtc) != 0 } fn are_any_set(&self) -> bool { *self > 0 } }<|fim_prefix|>// repo: jonlamb-gh/oxcc path: /src/dtc.rs //! Diagnostic trouble codes pub trait DtcBitfield { fn set(&mut self, dtc: u8); fn clear(&mut self,...
code_fim
hard
{ "lang": "rust", "repo": "jonlamb-gh/oxcc", "path": "/src/dtc.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jonlamb-gh/oxcc path: /src/dtc.rs //! Diagnostic trouble codes pub trait DtcBitfield { fn set(&mut self, dtc: u8); fn clear(&mut self, dtc: u8); fn clear_all(&mut self); fn check(&self, dtc: u8) -> bool; fn are_any_set(&self) -> bool; } <|fim_suffix|> fn clear(&mut self,...
code_fim
medium
{ "lang": "rust", "repo": "jonlamb-gh/oxcc", "path": "/src/dtc.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: SylphieBot/minnie path: /minnie/src/gateway/shard.rs e: RwLock<PresenceUpdate>, pub config: RwLock<GatewayConfig>, } impl ManagerSharedState { pub fn new(presence: PresenceUpdate, config: GatewayConfig) -> Self { ManagerSharedState { presence: RwLock::new(presence), ...
code_fim
hard
{ "lang": "rust", "repo": "SylphieBot/minnie", "path": "/minnie/src/gateway/shard.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Copy, Clone, Eq, PartialEq, Debug)] enum ShardPhase { /// The initial phase of shard connections, before the Hello packet is recieved. /// /// In this state, the shard manager code will allow up to 10 seconds for this packet to be /// received before raising an error. Initial,...
code_fim
hard
{ "lang": "rust", "repo": "SylphieBot/minnie", "path": "/minnie/src/gateway/shard.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn reconnect(&self) { self.send.send(ShardSignal::Reconnect).unwrap(); } pub fn notify_update_presence(&self) { self.send.send(ShardSignal::SendPresenceUpdate).unwrap(); } pub fn request_guild_members(&self, request: GuildMembersRequest) { self.send.send(Sha...
code_fim
hard
{ "lang": "rust", "repo": "SylphieBot/minnie", "path": "/minnie/src/gateway/shard.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: CC-CHAN/fork path: /src/auth/controller.rs use super::session::UserSession; use crate::auth::session::get_cookie_from_header; use crate::init::AppConnections; use async_session::SessionStore; use axum::{ extract::Extension, http::{self, HeaderMap, HeaderValue, StatusCode}, response::...
code_fim
hard
{ "lang": "rust", "repo": "CC-CHAN/fork", "path": "/src/auth/controller.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub async fn logout( header: HeaderMap, Extension(app_connections): Extension<AppConnections>, ) -> impl IntoResponse { let store = app_connections.session_store; // get cookie if let Some(mut cookie) = get_cookie_from_header(&header) { if let Some(session) = store ...
code_fim
hard
{ "lang": "rust", "repo": "CC-CHAN/fork", "path": "/src/auth/controller.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// /// Finds the bounds of a path using the looser 'fast' algorithm /// pub fn path_fast_bounding_box<P: BezierPath, Bounds: BoundingBox<Point=P::Point>>(path: &P) -> Bounds { path_to_curves(path) .map(|curve: Curve<P::Point>| curve.fast_bounding_box()) .reduce(|first: Bounds, second...
code_fim
hard
{ "lang": "rust", "repo": "Logicalshift/flo_curves", "path": "/src/bezier/path/bounds.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Logicalshift/flo_curves path: /src/bezier/path/bounds.rs use super::path::*; use super::to_curves::*; use super::super::curve::*; use super::super::super::geo::*; <|fim_suffix|>/// /// Finds the bounds of a path using the looser 'fast' algorithm /// pub fn path_fast_bounding_box<P: BezierPath,...
code_fim
hard
{ "lang": "rust", "repo": "Logicalshift/flo_curves", "path": "/src/bezier/path/bounds.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bollu/equinox path: /src/main.rs extern crate rustc_serialize; extern crate num; // Couldn't find anything using this so ¯\_(ツ)_/¯ //extern crate native; // This is grabbed from a .so file. When googling "librsfml" I literally // got 6 results, 1 from this project. It seems to have been renamed ...
code_fim
hard
{ "lang": "rust", "repo": "bollu/equinox", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> _ => { event_queue.send_event(&event) } } } let engine_state = state_machine.tick(1.0 / 60.0, &mut event_queue, &mut render_queue); match engine_state { EngineShutdown => { window.close() } _ => {} } render_que...
code_fim
hard
{ "lang": "rust", "repo": "bollu/equinox", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lthiery/stm32l0xx-hal path: /build.rs use std::env; use std::fs::File; use std::io::Write; use std::path::PathBuf; fn main() { // Put the linker script somewhere the linker can find it let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap()); let linker = match (cfg!(feature = "st...
code_fim
medium
{ "lang": "rust", "repo": "lthiery/stm32l0xx-hal", "path": "/build.rs", "mode": "psm", "license": "0BSD", "source": "the-stack-v2" }
<|fim_suffix|> println!("cargo:rerun-if-changed=build.rs"); println!("cargo:rerun-if-changed=memory_l0x1.x"); println!("cargo:rerun-if-changed=memory_l0x2.x"); }<|fim_prefix|>// repo: lthiery/stm32l0xx-hal path: /build.rs use std::env; use std::fs::File; use std::io::Write; use std::path::PathBuf; fn main(...
code_fim
medium
{ "lang": "rust", "repo": "lthiery/stm32l0xx-hal", "path": "/build.rs", "mode": "spm", "license": "0BSD", "source": "the-stack-v2" }
<|fim_prefix|>// repo: calsaviour/voting-anchor-moonzoon path: /program_/src/lib.rs #![warn(clippy::all, clippy::pedantic, clippy::nursery)] #![allow( clippy::try_err, clippy::must_use_candidate, clippy::doc_markdown, clippy::module_name_repetitions, clippy::semicolon_if_nothing_returned, clipp...
code_fim
medium
{ "lang": "rust", "repo": "calsaviour/voting-anchor-moonzoon", "path": "/program_/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>// @TODO_QUESTION Is possible to read it from "../keypairs/program-pubkey"? // // @TODO_QUESTION Should I use declare_program! instead? Does it work with the `no-entrypoint` feature? // (Do I really need the `no-entrypoint` feature?) declare_id!("4dKeVRjqyVNA3n48d1RGf3k2f8fEo1fGsUMPSmsHW4LG");<|fim_prefix...
code_fim
medium
{ "lang": "rust", "repo": "calsaviour/voting-anchor-moonzoon", "path": "/program_/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> W(writer) } } #[doc = "Field `HEADERMASK` reader - Header (S0) mask"] pub struct HEADERMASK_R(crate::FieldReader<u8, u8>); impl HEADERMASK_R { pub(crate) fn new(bits: u8) -> Self { HEADERMASK_R(crate::FieldReader::new(bits)) } } impl core::ops::Deref for HEADERMASK_R { type...
code_fim
hard
{ "lang": "rust", "repo": "nrf-rs/nrf5340-pac", "path": "/nrf5340-net-pac/src/ccm_ns/headermask.rs", "mode": "spm", "license": "0BSD", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nrf-rs/nrf5340-pac path: /nrf5340-net-pac/src/ccm_ns/headermask.rs #[doc = "Register `HEADERMASK` reader"] pub struct R(crate::R<HEADERMASK_SPEC>); impl core::ops::Deref for R { type Target = crate::R<HEADERMASK_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Target { &sel...
code_fim
hard
{ "lang": "rust", "repo": "nrf-rs/nrf5340-pac", "path": "/nrf5340-net-pac/src/ccm_ns/headermask.rs", "mode": "psm", "license": "0BSD", "source": "the-stack-v2" }
<|fim_suffix|> &self.0 } } #[doc = "Field `HEADERMASK` writer - Header (S0) mask"] pub struct HEADERMASK_W<'a> { w: &'a mut W, } impl<'a> HEADERMASK_W<'a> { #[doc = r"Writes raw bits to the field"] #[inline(always)] pub unsafe fn bits(self, value: u8) -> &'a mut W { self.w.bits = (sel...
code_fim
hard
{ "lang": "rust", "repo": "nrf-rs/nrf5340-pac", "path": "/nrf5340-net-pac/src/ccm_ns/headermask.rs", "mode": "spm", "license": "0BSD", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ilyadruzh/rust-libp2p path: /misc/core-derive/tests/test.rs // Copyright 2018 Parity Technologies (UK) Ltd. // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), // to deal in the Software witho...
code_fim
hard
{ "lang": "rust", "repo": "ilyadruzh/rust-libp2p", "path": "/misc/core-derive/tests/test.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: m-kann0/atcoder-rust path: /examples/abc047_b.rs use std::io::Read; fn main() { let mut buf = String::new(); std::io::stdin().read_to_string(&mut buf).unwrap(); let answer = solve(&buf); println!("{}", answer); } fn solve(input: &str) -> String { let mut iterator = input....
code_fim
hard
{ "lang": "rust", "repo": "m-kann0/atcoder-rust", "path": "/examples/abc047_b.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pfeilbr/rust-playground path: /src/main.rs #![allow(dead_code)] #![allow(unused_variables)] #![allow(warnings, unused)] use std::char; use std::env; use std::fs; use std::io; use std::mem; use std::process::Command; use std::str::FromStr; #[test] fn test_hello_format() { print!("hello"); ...
code_fim
hard
{ "lang": "rust", "repo": "pfeilbr/rust-playground", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let player_2 = Player::new("Roger".to_string(), "Federer".to_string()); assert_eq!( format!("Player 02: {}", player_2.full_name()), "Player 02: Roger Federer" ) } #[test] fn test_command_line_args() { let args: Vec<String> = env::args().collect(); println!("{:?}", arg...
code_fim
hard
{ "lang": "rust", "repo": "pfeilbr/rust-playground", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }