text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> // struct Types<'a> { // type_i: &'a u32, // type_ia: &'a u32, // type_ii: &'a u32, // type_iii: &'a u32, // type_iv: &'a u32, // type_v: &'a u32, // type_vi: &'a u32, // } let mut rng = create_see...
code_fim
hard
{ "lang": "rust", "repo": "kbingman/stellar", "path": "/src/util.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Enable the Over-drive mode and wait for the ODRDY flag to be set. self.pwr.pwr_cr.modify(|r| r.set_oden()); loop { if self.pwr.pwr_csr.odrdy.read_bit() { break; } } // Set the ODSW bit in the PWR_CR register to switch the ...
code_fim
hard
{ "lang": "rust", "repo": "kaivol/drone-stm32f4-hal", "path": "/src/rcc/pwr.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kaivol/drone-stm32f4-hal path: /src/rcc/pwr.rs #![allow(dead_code)] use crate::periph::PwrPeriph; use drone_cortexm::reg::prelude::*; pub struct Pwr { pwr: PwrPeriph, } impl Pwr { pub fn with_enabled_clock(pwr: PwrPeriph) -> Pwr { // Enable pwr clock. pwr.rcc_apb1enr_p...
code_fim
hard
{ "lang": "rust", "repo": "kaivol/drone-stm32f4-hal", "path": "/src/rcc/pwr.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Set the ODSW bit in the PWR_CR register to switch the voltage regulator from Normal mode to Over-drive mode. self.pwr.pwr_cr.modify(|r| r.set_odswen()); loop { if self.pwr.pwr_csr.odswrdy.read_bit() { break; } } } }<|fim_prefix...
code_fim
hard
{ "lang": "rust", "repo": "kaivol/drone-stm32f4-hal", "path": "/src/rcc/pwr.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>uments". // Since 2016. So who knows. }<|fim_prefix|>// repo: niilz/Automate-the-Boring-Stuff-with-Rust path: /ch_03/ex03_keyword_args/src/main.rs fn main() { // RUST does not have key-<|fim_middle|>word arguments...yet // On the Pre-RFC is an ongoing discussion about "named arg
code_fim
medium
{ "lang": "rust", "repo": "niilz/Automate-the-Boring-Stuff-with-Rust", "path": "/ch_03/ex03_keyword_args/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: niilz/Automate-the-Boring-Stuff-with-Rust path: /ch_03/ex03_keyword_args/src/main.rs fn main() { // RUST does not have key-<|fim_suffix|>uments". // Since 2016. So who knows. }<|fim_middle|>word arguments...yet // On the Pre-RFC is an ongoing discussion about "named arg
code_fim
medium
{ "lang": "rust", "repo": "niilz/Automate-the-Boring-Stuff-with-Rust", "path": "/ch_03/ex03_keyword_args/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: da-x/logpack path: /logpack-derive/src/encode_derive.rs use std::collections::HashSet; use proc_macro2::{TokenStream as Tokens, Span}; use syn::{Data, DeriveInput, Fields, DataEnum, Ident}; use quote::quote; pub fn derive(input: &DeriveInput) -> Tokens { let name = &input.ident; let ge...
code_fim
hard
{ "lang": "rust", "repo": "da-x/logpack", "path": "/logpack-derive/src/encode_derive.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> idx += 1; match v.fields { Fields::Named(ref fields) => { let fields: Vec<_> = fields.named.iter().enumerate().map(|(i, f)| FieldExt::new(f, i, true)).collect(); encoder_for_enum_struct(name, ident,...
code_fim
hard
{ "lang": "rust", "repo": "da-x/logpack", "path": "/logpack-derive/src/encode_derive.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fields: Vec<FieldExt<'a>>, prefix: Tokens, named: bool, sizer: bool, header_size: usize) -> Tokens { let one_ref = fields.iter().map(|v| { let ident = &v.get_match_ident(); quote! { ref #ident } }); let fields_match...
code_fim
hard
{ "lang": "rust", "repo": "da-x/logpack", "path": "/logpack-derive/src/encode_derive.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>INK_DNRTMSG, /// Kernel messages to user space. KObjectUevent = NETLINK_KOBJECT_UEVENT, /// Generic netlink family for simplified netlink usage. Generic = NETLINK_GENERIC, /// SCSI transpots ScsiTransport = NETLINK_SCSITRANSPORT, /// Ecryptfs = NETLINK_ECRYPTFS, /// In...
code_fim
hard
{ "lang": "rust", "repo": "delbonis/netlink", "path": "/netlink-sys/src/protocols.rs", "mode": "spm", "license": "MITNFA", "source": "the-stack-v2" }
<|fim_prefix|>// repo: delbonis/netlink path: /netlink-sys/src/protocols.rs use crate::constants::*; /// List of netlink protocols pub enum Protocol { /// Receives routing and link updates and may be used to modify the routing tables (both IPv4 /// and IPv6), IP addresses, link parameters, neighbor setups, qu...
code_fim
hard
{ "lang": "rust", "repo": "delbonis/netlink", "path": "/netlink-sys/src/protocols.rs", "mode": "psm", "license": "MITNFA", "source": "the-stack-v2" }
<|fim_suffix|> async fn exists_interface(&self, interface: &Interface) -> Result<bool, Error> { match rtnetlink::new_connection() { Ok(connection) => { let (c, handle, r) = connection; tokio::spawn(c); let resp = handle .link() ...
code_fim
hard
{ "lang": "rust", "repo": "erikh/emu", "path": "/src/network.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> async fn delete_interface(&self, interface: &Interface) -> Result<(), Error> { match rtnetlink::new_connection() { Ok(connection) => { let (c, handle, r) = connection; tokio::spawn(c); let resp = handle.link().del(interface.index).ex...
code_fim
hard
{ "lang": "rust", "repo": "erikh/emu", "path": "/src/network.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: erikh/emu path: /src/network.rs use crate::error::Error; use async_trait::async_trait; use futures::TryStreamExt; const NAME_PREFIX: &str = "emu."; #[derive(Debug, Clone)] pub struct Network { name: String, index: u32, } #[derive(Debug, Clone)] pub struct Interface { name: String,...
code_fim
hard
{ "lang": "rust", "repo": "erikh/emu", "path": "/src/network.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match v { x if x == SubmsgIds::InitNAssetConfigHolder.id() => { Ok(SubmsgIds::InitNAssetConfigHolder) } x if x == SubmsgIds::InitNAsset.id() => Ok(SubmsgIds::InitNAsset), x if x == SubmsgIds::InitNAssetRewards.id() => Ok(SubmsgIds::In...
code_fim
medium
{ "lang": "rust", "repo": "vicioux/basset-vault-contracts", "path": "/contracts/basset_vault/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vicioux/basset-vault-contracts path: /contracts/basset_vault/src/lib.rs use cosmwasm_std::StdError; use std::convert::TryFrom; mod commands; pub mod contract; mod queries; mod reply_response; pub mod state; mod tax_querier; mod utils; #[cfg(test)] mod tests; //withdrawing from Anchor Deposit ...
code_fim
hard
{ "lang": "rust", "repo": "vicioux/basset-vault-contracts", "path": "/contracts/basset_vault/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> use std::process::exit as sys_exit; sys_exit(code as i32) } // resolve A or AAAA for `name` and print found addresses fn run<R>(resolver: &mut Resolver, name: &OsStr, sort: bool) where R: AddressRecord, R::Address: Ord, { match resolver.query(name.as_bytes(), Class::IN, R::get_record_type()) { Ok(...
code_fim
hard
{ "lang": "rust", "repo": "stbuehler/rust-alookup", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stbuehler/rust-alookup path: /src/main.rs mod resolv_ext; use resolv::{ error::{ Error, ResolutionError, }, record::{ A, AAAA, }, Class, Resolver, Section, }; use crate::resolv_ext::{ AddressRecord, ResponseExt, }; use std::{ ffi::OsStr, os::unix::ffi::OsStrExt, }; #[repr(...
code_fim
hard
{ "lang": "rust", "repo": "stbuehler/rust-alookup", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: LevitatingBusinessMan/dagon path: /src/server/commands/register.rs use dagon_lib::protocol::*; use dagon_lib::keys::verify; extern crate dagon_lib; use crate::commands::{ArgumentList, has_required}; use sequoia_openpgp as openpgp; use openpgp::cert::prelude::*; use openpgp::parse::Parse; use o...
code_fim
medium
{ "lang": "rust", "repo": "LevitatingBusinessMan/dagon", "path": "/src/server/commands/register.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let username = data.get("username").unwrap().data(); let pubkey = data.get("pubkey").unwrap().data(); let signed_username = data.get("signed").unwrap().data(); let cert = Cert::from_bytes(pubkey.as_slice()); //Invalid key if let Err(_) = cert { return "-REG\r\n".to_owned().into_bytes() } let ...
code_fim
hard
{ "lang": "rust", "repo": "LevitatingBusinessMan/dagon", "path": "/src/server/commands/register.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let decrypted_username = verify(signed_username.as_slice(), &cert).unwrap(); if &decrypted_username == username { keyserver::register(username, &cert).unwrap(); return "+REG\r\n".to_owned().into_bytes() } else { return error_message!("REG", "Failed to verify username signature") } }<|fim_prefi...
code_fim
hard
{ "lang": "rust", "repo": "LevitatingBusinessMan/dagon", "path": "/src/server/commands/register.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut next_set = HashSet::new(); for neighbor in self.get_all_neighbors().into_iter() { let mut active_neighbors = 0; for n in Conway::get_neighbors(&neighbor) { if self.active_cubes.contains(&n) { active_neighbors += 1; } } ...
code_fim
hard
{ "lang": "rust", "repo": "benj2468/holiday-coding-challenge", "path": "/src/day17/day17.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: benj2468/holiday-coding-challenge path: /src/day17/day17.rs use std::fs; use std::error::Error; use std::env; use std::cmp; use std::iter::Iterator; use std::collections::HashSet; struct Conway { active_cubes: Points } type Point = (isize, isize, isize); type Points = HashSet<Point>; impl...
code_fim
hard
{ "lang": "rust", "repo": "benj2468/holiday-coding-challenge", "path": "/src/day17/day17.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stm32-rs/stm32-rs-nightlies path: /stm32mp1/src/stm32mp153/gicd/gicd_pidr4.rs #[doc = "Register `GICD_PIDR4` reader"] pub type R = crate::R<GICD_PIDR4_SPEC>; #[doc = "Field `PIDR4` reader - PIDR4"] pub type PIDR4_R = crate::FieldReader<u32>; impl R { #[doc = "Bits 0:31 - PIDR4"] #[in<|fi...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32mp1/src/stm32mp153/gicd/gicd_pidr4.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>R`](R) reader structure"] impl crate::Readable for GICD_PIDR4_SPEC {} #[doc = "`reset()` method sets GICD_PIDR4 to value 0x04"] impl crate::Resettable for GICD_PIDR4_SPEC { const RESET_VALUE: Self::Ux = 0x04; }<|fim_prefix|>// repo: stm32-rs/stm32-rs-nightlies path: /stm32mp1/src/stm32mp153/gicd/gicd...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32mp1/src/stm32mp153/gicd/gicd_pidr4.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("{}", table.to_string()); let expected = " +-------------------+-----------+-----------+ | Header1 | Header2 |Header3 | +===========================================+ | One One | One Two |One Three | |-------------------+-----------+-----------| | Two One ...
code_fim
medium
{ "lang": "rust", "repo": "isgasho/comfy-table", "path": "/tests/padding_test.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/comfy-table path: /tests/padding_test.rs use pretty_assertions::assert_eq; use comfy_table::*; #[test] fn missing_column_table() { let mut table = Table::new(); table .set_header(&vec!["Header1", "Header2", "Header3"]) .add_row(&vec!["One One", "One Two", "One T...
code_fim
medium
{ "lang": "rust", "repo": "isgasho/comfy-table", "path": "/tests/padding_test.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: prateekkumarweb/revprox path: /src/settings.rs use config::{Config, File}; use serde::Deserialize; use std::{collections::HashMap, path::PathBuf}; #[derive(Debug, Deserialize)] pub struct Settings { servers: Vec<ServerSetting>, } #[derive(Debug, Deserialize)] struct ServerSetting { hos...
code_fim
hard
{ "lang": "rust", "repo": "prateekkumarweb/revprox", "path": "/src/settings.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn servers(self) -> HashMap<String, String> { self.servers .into_iter() .map(|setting| (setting.host, setting.proxy_pass)) .collect() } }<|fim_prefix|>// repo: prateekkumarweb/revprox path: /src/settings.rs use config::{Config, File}; use serde::Des...
code_fim
hard
{ "lang": "rust", "repo": "prateekkumarweb/revprox", "path": "/src/settings.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Computes metrics for reporting summaries of each processing stage. pub trait GroupedFileSetMetrics { /// Returns the total count of the files fn total_count(self) -> usize; /// Returns the sum of file lengths fn total_size(self) -> FileLen; /// Returns the total count of redundan...
code_fim
hard
{ "lang": "rust", "repo": "sunlinjin/fclones", "path": "/src/group.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sunlinjin/fclones path: /src/group.rs use std::collections::HashMap; use std::hash::Hash; use std::marker::PhantomData; use itertools::Itertools; use rayon::iter::{IntoParallelIterator, ParallelIterator}; use serde::*; use crate::files::{FileHash, FileLen}; use smallvec::SmallVec; use std::cmp...
code_fim
hard
{ "lang": "rust", "repo": "sunlinjin/fclones", "path": "/src/group.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>} impl<'a, I, F> GroupedFileSetMetrics for I where I: IntoIterator<Item = &'a FileGroup<F>> + 'a, F: 'a, { fn total_count(self) -> usize { self.into_iter().map(|g| g.files.len()).sum() } fn total_size(self) -> FileLen { self.into_iter() .map(|g| g.file_len...
code_fim
hard
{ "lang": "rust", "repo": "sunlinjin/fclones", "path": "/src/group.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: manpat/wsrs-test path: /client/src/rendering/framebuffer.rs use common::math::*; use rendering::gl; use rendering::texture::*; pub struct Framebuffer { gl_handle: u32, targets: Vec<Texture>, size: Vec2i, } impl Framebuffer { pub fn bind(&self) { unsafe { gl::BindFramebuffer(gl::FRAME...
code_fim
hard
{ "lang": "rust", "repo": "manpat/wsrs-test", "path": "/client/src/rendering/framebuffer.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let next_target = self.fb.targets.len() as u32; unsafe { gl::GenTextures(1, &mut gl_handle); gl::BindTexture(gl::TEXTURE_2D, gl_handle); gl::TexParameteri(gl::TEXTURE_2D, gl::TEXTURE_MIN_FILTER, gl::LINEAR as i32); gl::TexParameteri(gl::TEXTURE_2D, gl::TEXTURE_MAG_FILTER, gl::LINEAR as i3...
code_fim
hard
{ "lang": "rust", "repo": "manpat/wsrs-test", "path": "/client/src/rendering/framebuffer.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: doytsujin/rustcommon path: /logger/examples/demo.rs // Copyright 2019-2020 Twitter, Inc. // Licensed under the Apache License, Version 2.0 // http://www.apache.org/licenses/LICENSE-2.0 #[macro_use] extern crate rustcommon_logger as logger; <|fim_suffix|> logger::Logger::new() .label...
code_fim
medium
{ "lang": "rust", "repo": "doytsujin/rustcommon", "path": "/logger/examples/demo.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub fn main() { println!("A simple demo of the logger"); logger::Logger::new() .label("demo") .level(logger::Level::Trace) .init() .expect("Failed to initialize logger"); trace!("Some tracing message"); debug!("Some debugging message"); info!("Just some...
code_fim
medium
{ "lang": "rust", "repo": "doytsujin/rustcommon", "path": "/logger/examples/demo.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Self(s.lines().map(|line| MyString::from(line)).collect()) } fn code_minus_memory(&self) -> usize { self.0 .iter() .map(|s| s.code_length() - s.memory_length()) .sum() } fn encoded_minus_code(&self) -> usize { self.0 ...
code_fim
hard
{ "lang": "rust", "repo": "kczimm/advent-of-code-2015", "path": "/src/day8/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kczimm/advent-of-code-2015 path: /src/day8/main.rs /*! --- Day 8: Matchsticks --- Space on the sleigh is limited this year, and so Santa will be bringing his list as a digital copy. He needs to know how much space it will take up when stored. It is common in many programming languages to provi...
code_fim
hard
{ "lang": "rust", "repo": "kczimm/advent-of-code-2015", "path": "/src/day8/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.0 .iter() .map(|s| s.encoded_length() - s.code_length()) .sum() } } #[derive(Debug, PartialEq)] struct MyString<'a> { inner: &'a str, } impl<'a> MyString<'a> { fn from(s: &'a str) -> Self { Self { inner: s } } fn code_length(&...
code_fim
hard
{ "lang": "rust", "repo": "kczimm/advent-of-code-2015", "path": "/src/day8/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/bonsaidb path: /core/src/schema/collection.rs use std::{ borrow::Cow, convert::{TryFrom, TryInto}, fmt::Debug, }; use async_trait::async_trait; use serde::{Deserialize, Serialize}; use super::names::InvalidNameError; use crate::{ connection::Connection, document::{D...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/bonsaidb", "path": "/core/src/schema/collection.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<'a> From<&'a str> for NamedReference<'a> { fn from(name: &'a str) -> Self { Self::Name(Cow::Borrowed(name)) } } impl<'a> From<&'a String> for NamedReference<'a> { fn from(name: &'a String) -> Self { Self::Name(Cow::Borrowed(name.as_str())) } } impl<'a, 'b, 'c> From<&...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/bonsaidb", "path": "/core/src/schema/collection.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<'a> From<String> for NamedReference<'a> { fn from(name: String) -> Self { Self::Name(Cow::Owned(name)) } } impl<'a> From<u64> for NamedReference<'a> { fn from(id: u64) -> Self { Self::Id(id) } } impl<'a> NamedReference<'a> { /// Converts this reference to an owne...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/bonsaidb", "path": "/core/src/schema/collection.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zoujiaqing/rust_asio path: /src/socket_listener.rs use std::io; use std::marker::PhantomData; use error::ErrCode; use io_service::{IoObject, FromRawFd, IoService, IoActor, Callback, Handler}; use traits::{Protocol, IoControl, GetSocketOption, SetSocketOption}; use fd_ops::*; const SOMAXCONN: u3...
code_fim
hard
{ "lang": "rust", "repo": "zoujiaqing/rust_asio", "path": "/src/socket_listener.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn set_option<C>(&self, cmd: C) -> io::Result<()> where C: SetSocketOption<P>, { setsockopt(self, &self.pro, cmd) } } unsafe impl<P: Protocol, S: FromRawFd<P>> IoObject for SocketListener<P, S> { fn io_service(&self) -> &IoService { self.act.io_service() } ...
code_fim
hard
{ "lang": "rust", "repo": "zoujiaqing/rust_asio", "path": "/src/socket_listener.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn bind(&self, ep: &P::Endpoint) -> io::Result<()> { bind(self, ep) } pub fn cancel(&self) { cancel(self) } pub fn listen(&self) -> io::Result<()> { listen(self, SOMAXCONN) } pub fn local_endpoint(&self) -> io::Result<P::Endpoint> { getsoc...
code_fim
hard
{ "lang": "rust", "repo": "zoujiaqing/rust_asio", "path": "/src/socket_listener.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pgecsenyi/perm-rust path: /src/command_executor.rs use super::config; use std::process::{Command, Stdio}; use time::PreciseTime; pub struct CommandExecutor { pub execution_times: Vec<ExecutionRecord>, display_output: bool, } #[derive(Debug)] pub struct ExecutionRecord { pub group_n...
code_fim
hard
{ "lang": "rust", "repo": "pgecsenyi/perm-rust", "path": "/src/command_executor.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn execute_task_helper_command(&self, helper_command: &Vec<String>) { if helper_command.len() > 0 && helper_command[0] != "" { self.execute_command(&helper_command[0], &helper_command[1..]); } } fn execute_command(&self, command: &str, arguments: &[String]) { ...
code_fim
hard
{ "lang": "rust", "repo": "pgecsenyi/perm-rust", "path": "/src/command_executor.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn data_array_logic_op( op: DataValueLogicOperator, args: &[DataColumnarValue] ) -> Result<DataArrayRef> { match op { DataValueLogicOperator::Not => Self::data_array_negation(&args[0]), _ => Self::data_array_logic_binary(op, &args[0], &args[1]) ...
code_fim
hard
{ "lang": "rust", "repo": "gitsrc/datafuse", "path": "/common/datavalues/src/data_array_logic.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gitsrc/datafuse path: /common/datavalues/src/data_array_logic.rs // Copyright 2020-2021 The Datafuse Authors. // // SPDX-License-Identifier: Apache-2.0. use std::sync::Arc; use common_exception::ErrorCodes; use common_exception::Result; use crate::BooleanArray; use crate::DataArrayRef; use cr...
code_fim
hard
{ "lang": "rust", "repo": "gitsrc/datafuse", "path": "/common/datavalues/src/data_array_logic.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn data_array_negation(val: &DataColumnarValue) -> Result<DataArrayRef> { match val { DataColumnarValue::Array(array) => { let arr = downcast_array!(array, BooleanArray)?; Ok(Arc::new( common_arrow::arrow::compute::not(arr).map_er...
code_fim
hard
{ "lang": "rust", "repo": "gitsrc/datafuse", "path": "/common/datavalues/src/data_array_logic.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub fn main() { let args = parse_arguments::<NullExtension>(); let octree_factory = OctreeFactory::new().register("grpc://", octree_from_grpc_address); let point_cloud_client = point_cloud_client(&args, octree_factory); run(&args, &point_cloud_client, None); }<|fim_prefix|>// repo: Calm-wy...
code_fim
medium
{ "lang": "rust", "repo": "Calm-wy/point_cloud_viewer", "path": "/xray/src/bin/build_xray_quadtree.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Calm-wy/point_cloud_viewer path: /xray/src/bin/build_xray_quadtree.rs use point_viewer::octree::OctreeFactory; use point_viewer_grpc::octree_from_grpc_address; use xray::build_quadtree::{parse_arguments, point_cloud_client, run, Extension}; struct NullExtension; impl Extension for NullExtensio...
code_fim
medium
{ "lang": "rust", "repo": "Calm-wy/point_cloud_viewer", "path": "/xray/src/bin/build_xray_quadtree.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> match &std::env::args().collect::<Vec<String>>()[..] { [_, port, config_file] => { let connection = Connection::open(&port).expect("Failed to open a connection"); let config: Config = toml::from_str( &std::fs::read_to_string(config_file).expect("Failed t...
code_fim
medium
{ "lang": "rust", "repo": "coffeecup-winner/taptain", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: coffeecup-winner/taptain path: /src/main.rs mod builtin; mod comms; mod config; mod core; mod events; mod protocol; mod tasks; mod views; <|fim_suffix|>fn main() { match &std::env::args().collect::<Vec<String>>()[..] { [_, port, config_file] => { let connection = Connect...
code_fim
medium
{ "lang": "rust", "repo": "coffeecup-winner/taptain", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: JCapucho/pseudoc path: /src/common.rs pub use lasso::RodeoResolver; use lasso::{Rodeo as LassoRodeo, Spur}; use std::{ collections::HashMap, fmt, hash::{self, Hash}, ops::Deref, }; pub mod arena; pub mod ast; pub mod error; pub mod src; pub type Symbol = Spur; pub type Rodeo =...
code_fim
hard
{ "lang": "rust", "repo": "JCapucho/pseudoc", "path": "/src/common.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match self { UnaryOp::BitWiseNot => write!(f, "!"), UnaryOp::Negation => write!(f, "-"), } } } #[repr(u8)] #[derive(Clone, Debug, Hash, PartialEq, Eq, Copy, PartialOrd, Ord)] pub enum PrimitiveType { Int = 0, Float, Bool, String, } impl fmt::Di...
code_fim
hard
{ "lang": "rust", "repo": "JCapucho/pseudoc", "path": "/src/common.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match self { BinaryOp::LogicalOr => write!(f, "||"), BinaryOp::LogicalAnd => write!(f, "&&"), BinaryOp::Equality => write!(f, "=="), BinaryOp::Inequality => write!(f, "!="), BinaryOp::Greater => write!(f, ">"), BinaryOp::Gre...
code_fim
hard
{ "lang": "rust", "repo": "JCapucho/pseudoc", "path": "/src/common.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: static-web-server/iron-test path: /src/response.rs use iron::prelude::*; /// Extracts a utf8 response body to a String. pub fn extract_body_to_string(response: Response) -> String { let result = extract_body_to_bytes(response); String::from_utf8(result).unwrap() } /// Extracts a respon...
code_fim
hard
{ "lang": "rust", "repo": "static-web-server/iron-test", "path": "/src/response.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_extract_body_to_bytes() { let response = request::get("http://localhost:3000", Headers::new(), &HelloWorldHandler); let result = extract_body_to_bytes(response.unwrap()); assert_eq!(result, b"Hello, world!"); } }<|fim_prefix|>// repo: static-web-server/...
code_fim
hard
{ "lang": "rust", "repo": "static-web-server/iron-test", "path": "/src/response.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> info!("handling request."); let ref query = req.extensions.get::<Router>().unwrap().find("query").unwrap_or("/"); println!("query {}", query); //Ok(Response::with(status::Ok, *query)) Ok(Response::with(status::Ok)) } chain }<|fim_prefix|>// repo: e...
code_fim
hard
{ "lang": "rust", "repo": "evadnoob/iron-issue-request-too-large", "path": "/src/myrouter.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> info!("handling request."); let ref query = req.extensions.get::<Router>().unwrap().find("query").unwrap_or("/"); println!("query {}", query); //Ok(Response::with(status::Ok, *query)) Ok(Response::with(status::Ok)) } chain }<|fim_prefix|>// repo: evadnoob/i...
code_fim
hard
{ "lang": "rust", "repo": "evadnoob/iron-issue-request-too-large", "path": "/src/myrouter.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: evadnoob/iron-issue-request-too-large path: /src/myrouter.rs extern crate iron; extern crate router; extern crate bodyparser; extern crate persistent; extern crate rustc_serialize; <|fim_suffix|>//const MAX_BODY_LENGTH: usize = 1024 * 1024 * 10; pub fn setup() -> Chain { let mut router = ...
code_fim
medium
{ "lang": "rust", "repo": "evadnoob/iron-issue-request-too-large", "path": "/src/myrouter.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hrvolapeter/javascript-es9-parser path: /components/evaluator/tests/ui/function.rs function a() { console.log(1); } a(); <|fim_suffix|>var a = (a) => { console.log(a); }; a(4);<|fim_middle|>var a = function() { console.log(2); }; a(); var a = () => { console.log(3); }; a();
code_fim
medium
{ "lang": "rust", "repo": "hrvolapeter/javascript-es9-parser", "path": "/components/evaluator/tests/ui/function.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>var a = (a) => { console.log(a); }; a(4);<|fim_prefix|>// repo: hrvolapeter/javascript-es9-parser path: /components/evaluator/tests/ui/function.rs function a() { console.log(1); } a(); <|fim_middle|>var a = function() { console.log(2); }; a(); var a = () => { console.log(3); }; a();
code_fim
medium
{ "lang": "rust", "repo": "hrvolapeter/javascript-es9-parser", "path": "/components/evaluator/tests/ui/function.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dalevross/projecteuler100 path: /src/p002.rs // Even Fibonacci numbers // Problem 2 // Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: // 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... <|fim_suffix|>pub fn...
code_fim
medium
{ "lang": "rust", "repo": "dalevross/projecteuler100", "path": "/src/p002.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn run(limit: i64 ) -> i64 { let mut sum: i64 = 0; let mut fib = [1,2]; while fib[1] <= limit { sum += if fib[1] % 2 == 0 { fib[1] } else { 0 }; let _temp = fib[0]; fib[0]=fib[1]; fib[1] += _temp; } sum }<|fim_prefix|>// repo: dalevross/projecteuler1...
code_fim
medium
{ "lang": "rust", "repo": "dalevross/projecteuler100", "path": "/src/p002.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>mod data; pub(crate) use data::*; #[proc_macro_derive(Api, attributes(construct, auth, searchable))] pub fn derive_api(input: TokenStream) -> TokenStream { api::derive(input.into()) } #[proc_macro_attribute] #[allow(non_snake_case)] pub fn Support(_attr: TokenStream, input: TokenStream) -> TokenStre...
code_fim
medium
{ "lang": "rust", "repo": "benj2468/yoda-rs", "path": "/derive/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[proc_macro_attribute] #[allow(non_snake_case)] pub fn Support(_attr: TokenStream, input: TokenStream) -> TokenStream { support::derive(input.into()) } #[cfg(test)] mod test;<|fim_prefix|>// repo: benj2468/yoda-rs path: /derive/src/lib.rs use proc_macro::TokenStream; use proc_macro2::TokenStream as...
code_fim
hard
{ "lang": "rust", "repo": "benj2468/yoda-rs", "path": "/derive/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: benj2468/yoda-rs path: /derive/src/lib.rs use proc_macro::TokenStream; use proc_macro2::TokenStream as TokenStream2; use quote::quote; use syn::{Data, DeriveInput, GenericArgument, Ident, PathArguments, PathSegment, Visibility}; mod api; mod support; <|fim_suffix|>#[proc_macro_derive(Api, attr...
code_fim
medium
{ "lang": "rust", "repo": "benj2468/yoda-rs", "path": "/derive/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>3DC1683, 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE4...
code_fim
hard
{ "lang": "rust", "repo": "ulrichji/MegFileZip", "path": "/src/petroglyph/mega_file/crc/crc32.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>E6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, 0x...
code_fim
hard
{ "lang": "rust", "repo": "ulrichji/MegFileZip", "path": "/src/petroglyph/mega_file/crc/crc32.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ulrichji/MegFileZip path: /src/petroglyph/mega_file/crc/crc32.rs // Table taken from web: // url: https://docs.microsoft.com/en-us/openspecs/office_protocols/ms-abs/06966aa2-70da-4bf9-8448-3355f277cd77?redirectedfrom=MSDN // title: 5.1 32-Bit CRC Algorithm // fetch_date: 2019-12-14 ...
code_fim
hard
{ "lang": "rust", "repo": "ulrichji/MegFileZip", "path": "/src/petroglyph/mega_file/crc/crc32.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alexcarol/dots_wasm path: /src/geometry/size.rs /// A `Size` represents a region in space #[derive(Clone, Copy, Default)] p<|fim_suffix|>height: f64) -> Size { Size { width: width, height: height } } }<|fim_middle|>ub struct Size { pub width: f64, pub height: f64 } impl Size...
code_fim
medium
{ "lang": "rust", "repo": "alexcarol/dots_wasm", "path": "/src/geometry/size.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>height: f64) -> Size { Size { width: width, height: height } } }<|fim_prefix|>// repo: alexcarol/dots_wasm path: /src/geometry/size.rs /// A `Size` represents a region in space #[derive(Clone, Copy, Default)] p<|fim_middle|>ub struct Size { pub width: f64, pub height: f64 } impl Size...
code_fim
medium
{ "lang": "rust", "repo": "alexcarol/dots_wasm", "path": "/src/geometry/size.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Returns a new `Size` of the given dimensions pub fn new(width: f64, height: f64) -> Size { Size { width: width, height: height } } }<|fim_prefix|>// repo: alexcarol/dots_wasm path: /src/geometry/size.rs /// A `Size` represents a region in space #[derive(Clone, Copy, Default)] p<|fim_m...
code_fim
medium
{ "lang": "rust", "repo": "alexcarol/dots_wasm", "path": "/src/geometry/size.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>{ for(method, action, handler) in rest::get_handlers() { let m = match method { rest::RestMethod::GET => iron::method::Get, rest::RestMethod::POST => iron::method::Post, rest::RestMethod::PUT => iron::method::Put, rest::RestMethod::DE...
code_fim
hard
{ "lang": "rust", "repo": "flagoworld/rusty-car", "path": "/core/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: flagoworld/rusty-car path: /core/src/main.rs extern crate iron; extern crate router; extern crate rustc_serialize; extern crate serial; extern crate time; extern crate websocket; use std::thread; use std::sync::Arc; use lin::LINOptions; use lin::LINMaster; use lin::frame; use lin::frame::LINFr...
code_fim
hard
{ "lang": "rust", "repo": "flagoworld/rusty-car", "path": "/core/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Perform the partial comparison tests fn partial_cmp_box(&self, other: &dyn ClientContextCmp) -> Option<Ordering>; } impl<Context> ClientContextCmp for Context where Context: 'static + PartialEq + PartialOrd, { fn as_any(&self) -> &dyn Any { self } fn eq_box(&self, ot...
code_fim
hard
{ "lang": "rust", "repo": "blessanabraham/usd-rs", "path": "/ar/src/resolver_context/client_context.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: blessanabraham/usd-rs path: /ar/src/resolver_context/client_context.rs use alloc::boxed::Box; use core::any::Any; use core::cmp::Ordering; use core::fmt::Debug; /// The trait for Client Contexts pub trait ClientContext: ClientContextClone + Debug + ClientContextCmp {} #[doc(hidden)] /// Trait ...
code_fim
hard
{ "lang": "rust", "repo": "blessanabraham/usd-rs", "path": "/ar/src/resolver_context/client_context.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Do a type-safe casting. If the types are different, // return false, otherwise tests the values for equality. other .as_any() .downcast_ref::<Self>() .map_or(false, |ctx| ctx == self) } fn partial_cmp_box(&self, other: &dyn ClientCont...
code_fim
hard
{ "lang": "rust", "repo": "blessanabraham/usd-rs", "path": "/ar/src/resolver_context/client_context.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hyperium/headers path: /src/common/sec_websocket_accept.rs use base64; use bytes::Bytes; use sha1::{Digest, Sha1}; use super::SecWebsocketKey; /// The `Sec-Websocket-Accept` header. /// /// This header is used in the Websocket handshake, sent back by the /// server indicating a successful hand...
code_fim
hard
{ "lang": "rust", "repo": "hyperium/headers", "path": "/src/common/sec_websocket_accept.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn key_to_accept() { // From https://tools.ietf.org/html/rfc6455#section-1.2 let key = test_decode::<SecWebsocketKey>(&["dGhlIHNhbXBsZSBub25jZQ=="]).expect("key"); let accept = SecWebsocketAccept::from(key); let headers = test_encode(accept); assert...
code_fim
medium
{ "lang": "rust", "repo": "hyperium/headers", "path": "/src/common/sec_websocket_accept.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> sign(key.0.as_bytes()) } } fn sign(key: &[u8]) -> SecWebsocketAccept { let mut sha1 = Sha1::default(); sha1.update(key); sha1.update(&b"258EAFA5-E914-47DA-95CA-C5AB0DC85B11"[..]); let b64 = Bytes::from(base64::encode(&sha1.finalize())); let val = ::HeaderValue::from_maybe...
code_fim
medium
{ "lang": "rust", "repo": "hyperium/headers", "path": "/src/common/sec_websocket_accept.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn not_included() { let mut builder = Ciboulette2PgBuilder::default(); let store = gen_bag(); let dest_table = Ciboulette2PgTable::new( vec![Ciboulette2PgId::Uuid( Ciboulette2PgSafeIdent::try_from("id").unwrap(), )], Some(Ciboulette2PgSafeIdent::try_...
code_fim
hard
{ "lang": "rust", "repo": "basiliqio/ciboulette2pg", "path": "/src/builder/tests/inserts/gen_json_builder.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: basiliqio/ciboulette2pg path: /src/builder/tests/inserts/gen_json_builder.rs use super::*; #[test] fn no_sparse_fields() { let mut builder = Ciboulette2PgBuilder::default(); let store = gen_bag(); let dest_table = Ciboulette2PgTable::new( vec![Ciboulette2PgId::Uuid( ...
code_fim
hard
{ "lang": "rust", "repo": "basiliqio/ciboulette2pg", "path": "/src/builder/tests/inserts/gen_json_builder.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Clone, Copy, Debug)] pub enum BodyTag { PC, DummyArea, Obstacle, // RectangleRight, } bitflags! { pub struct Category: u32 { const GROUND = 0b1 << 1; const ALLY = 0b1 << 2; //const ENEMY = 0b1 << 3; } }<|fim_prefix|>// repo: RybekU/Slimeu path: /s...
code_fim
medium
{ "lang": "rust", "repo": "RybekU/Slimeu", "path": "/src/phx/collision/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>bitflags! { pub struct Category: u32 { const GROUND = 0b1 << 1; const ALLY = 0b1 << 2; //const ENEMY = 0b1 << 3; } }<|fim_prefix|>// repo: RybekU/Slimeu path: /src/phx/collision/mod.rs mod hitbox; pub use self::hitbox::{physics_post_sync, physics_pre_sync, Hitbox}; <|fim...
code_fim
hard
{ "lang": "rust", "repo": "RybekU/Slimeu", "path": "/src/phx/collision/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: RybekU/Slimeu path: /src/phx/collision/mod.rs mod hitbox; pub use self::hitbox::{physics_post_sync, physics_pre_sync, Hitbox}; use bitflags::bitflags; use resphys::{Body as B, PhysicsWorld as Pworld}; <|fim_suffix|>bitflags! { pub struct Category: u32 { const GROUND = 0b1 << 1; ...
code_fim
medium
{ "lang": "rust", "repo": "RybekU/Slimeu", "path": "/src/phx/collision/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> [ [ cos_theta_2, -Complex64::new(0.0, lam.into_inner()).exp() * sin_theta_2, ], [ Complex64::new(0.0, phi.into_inner()).exp() * sin_theta_2, Complex64::new(0.0, (phi + lam).into_inner()).exp() * cos_theta_2, ], ] } #[...
code_fim
hard
{ "lang": "rust", "repo": "pandaman64/qopter", "path": "/src/postprocess.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pandaman64/qopter path: /src/postprocess.rs use super::{Float, Gate, PhysicalQubit}; use num_complex::Complex64; use pyo3::prelude::*; fn err<T>(res: PyResult<T>, py: Python) -> PyResult<T> { match res { Ok(x) => Ok(x), Err(e) => { e.clone_ref(py).print(py); ...
code_fim
hard
{ "lang": "rust", "repo": "pandaman64/qopter", "path": "/src/postprocess.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> METER.with_label_values(&[peer.to_string().as_str(), String::from_utf8_lossy(protocol).as_ref()]) } pub fn client_errors(peer: &NodeId, protocol: &ProtocolId) -> IntCounter { static METER: Lazy<IntCounterVec> = Lazy::new(|| { tari_metrics::register_int_counter_vec( "comms::rpc...
code_fim
hard
{ "lang": "rust", "repo": "tari-project/tari", "path": "/comms/core/src/protocol/rpc/client/metrics.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tari-project/tari path: /comms/core/src/protocol/rpc/client/metrics.rs // Copyright 2021, The Tari Project // // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the // following conditions are met: // // 1. Redistributions of sourc...
code_fim
hard
{ "lang": "rust", "repo": "tari-project/tari", "path": "/comms/core/src/protocol/rpc/client/metrics.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> let reflected = reflect(&ray_in.direction.unit_vec(), &rec.normal); if reflected.dot(rec.normal) > 0.0 { return Some(ScatterRecord { attenuation: self.albedo, scattered: Ray::new(rec.p, reflected + random_in_unit_sphere() * self.fuzz), ...
code_fim
medium
{ "lang": "rust", "repo": "KiKoS0/ray-tracer", "path": "/src/libcore/material/metallic.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: KiKoS0/ray-tracer path: /src/libcore/material/metallic.rs use super::Material; use super::ScatterRecord; use crate::color::Color; use crate::libcore::hit::HitRecord; use crate::math::{random_in_unit_sphere, reflect, Ray, Vec3}; <|fim_suffix|> let reflected = reflect(&ray_in.direction.uni...
code_fim
medium
{ "lang": "rust", "repo": "KiKoS0/ray-tracer", "path": "/src/libcore/material/metallic.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>ify`](crate::generic::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."] pub struct CCR1_SPEC; impl crate::RegisterSpec for CCR1_SPEC { type Ux = u32; } #[doc = "`read()` method returns [`ccr1::R`](R) reader structure"] impl crate::Readable for CCR1_SPEC {} #[d...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32l5/src/stm32l552/tim4/ccr1.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stm32-rs/stm32-rs-nightlies path: /stm32l5/src/stm32l552/tim4/ccr1.rs #[doc = "Register `CCR1` reader"] pub type R = crate::R<CCR1_SPEC>; #[doc = "Register `CCR1` writer"] pub type W = crate::W<CCR1_SPEC>; #[doc = "Field `CCR1_L` reader - Low Capture/Compare 1 value"] pub type CCR1_L_R = crate::...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32l5/src/stm32l552/tim4/ccr1.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Resend any data whose retransmit time has been reached, if we have the bandwidth for it async fn resend(&mut self, shared: &mut Shared) -> Result<(), Error> { for unacked in self.unacked_ranges.values_mut() { if !self.bandwidth_limiter.bytes_available() { bre...
code_fim
hard
{ "lang": "rust", "repo": "kyren/turbulence", "path": "/src/reliable_channel.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kyren/turbulence path: /src/reliable_channel.rs f unreliable, unordered packets into a reliable in-order stream of data. /// /// All methods on `ReliableChannel` are always cancel safe, they return immediately once any amount /// of work is done, so canceling the returned futures makes them have...
code_fim
hard
{ "lang": "rust", "repo": "kyren/turbulence", "path": "/src/reliable_channel.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.unacked_ranges.insert( start, UnackedRange { start, end, last_sent: Some(self.runtime.now()), retransmit: false, }, ); self.bandwidth_limiter.take_bytes(packet.len() as u32); ...
code_fim
hard
{ "lang": "rust", "repo": "kyren/turbulence", "path": "/src/reliable_channel.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: crgl/npuzzle path: /src/game.rs use opengl_graphics::{GlGraphics, Texture}; use piston::input::*; use piston_window::TextureSettings; use std::path::Path; pub struct Game { gl: GlGraphics, zero: (usize, usize), board: Vec<Vec<usize>>, goal: Vec<Vec<usize>>, imgref: Vec<(grap...
code_fim
hard
{ "lang": "rust", "repo": "crgl/npuzzle", "path": "/src/game.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }