text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: svark/asti.rs path: /src/spline_interp.rs use vectorspace::{PointT, to_pt, PV}; use la::Matrix; use std::ops::Mul; use tol::Tol; use either::*; use errcodes::GeomErrorCode; use bspline::Bspline; use periodic_spline::PeriodicBspline; use std::iter::once; use vectorspace::NVS; #[derive(PartialEq)...
code_fim
hard
{ "lang": "rust", "repo": "svark/asti.rs", "path": "/src/spline_interp.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> for i in 0..n { knots[2*i + 2] = params[i]; knots[2*i + 3] = params[i]; } knots[2*n + 2] = params[n - 1] + e!(params, 0); knots[2*n + 3] = knots[2*n + 3]; for i in 0..n { cpts[2*i] = pts[i] + tgts[i] * (-e!(knots, 2*i + 1, 2) / 3.0); cpts[2*i + ...
code_fim
hard
{ "lang": "rust", "repo": "svark/asti.rs", "path": "/src/spline_interp.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> for ps in pts.chunks(2).into_iter() { if (ps[1] - ps[0]).norm().small() { return Err(GeomErrorCode::DuplicatePointData); } } Ok(()) } fn pchip_open<P>(pts :&[P], params: &[f64], tgts: &[<P as PV>::V] ...
code_fim
hard
{ "lang": "rust", "repo": "svark/asti.rs", "path": "/src/spline_interp.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/issues/issue-46855.rs // run-pass #![allow(dead_code)] // compile-flags: -Zmir-opt-level=1 use std::mem; #[derive(Copy, Clone)] enum Never {} <|fim_suffix|> let f = [Foo { a: 42 }, Foo { a: 10 }]; println!("{:?}", unsafe { f[0].a }); }...
code_fim
medium
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/issues/issue-46855.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn main() { println!("{}", mem::size_of::<Foo>()); let f = [Foo { a: 42 }, Foo { a: 10 }]; println!("{:?}", unsafe { f[0].a }); }<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/issues/issue-46855.rs // run-pass #![allow(dead_code)] // compile-flags: -Zmir-opt-level...
code_fim
medium
{ "lang": "rust", "repo": "IThawk/rust-project", "path": "/rust-master/src/test/ui/issues/issue-46855.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub const SAMPLE_INPUT: &str = "\ [1518-11-01 00:00] Guard #10 begins shift [1518-11-01 00:05] falls asleep [1518-11-01 00:25] wakes up [1518-11-01 00:30] falls asleep [1518-11-01 00:55] wakes up [1518-11-01 23:58] Guard #99 begins shift [1518-11-02 00:40] falls asleep [1518-11-02 00:50] wakes up [151...
code_fim
hard
{ "lang": "rust", "repo": "joelpedraza/aoc2018", "path": "/src/problem04/solution.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: joelpedraza/aoc2018 path: /src/problem04/solution.rs use super::input::INPUT; pub fn part1() { println!("Problem 4, Part 1: {}", solve_1(INPUT)) } pub fn part2() { println!("Problem 4, Part 2: {}", solve_2(INPUT)) } fn solve_1(input: &str) -> usize { let events = sort_events(input...
code_fim
hard
{ "lang": "rust", "repo": "joelpedraza/aoc2018", "path": "/src/problem04/solution.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> vec.sort(); vec } #[cfg(test)] mod tests { use super::*; #[test] fn part_1_is_correct() { assert_eq!(240, solve_1(SAMPLE_INPUT)) } #[test] fn part_2_is_correct() { assert_eq!(4455, solve_2(SAMPLE_INPUT)) } pub const SAMPLE_INPUT: &str = "\ [1518...
code_fim
hard
{ "lang": "rust", "repo": "joelpedraza/aoc2018", "path": "/src/problem04/solution.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub(super) fn cost<A: DimLike + Clone, B: DimLike + Clone>( a: &[A], b: &[B], dt: DatumType, a_trans: bool, b_trans: bool, ) -> TractResult<TVec<(Cost, TDim)>> { let (m, k, n, c_shape) = compute_shape( &a.iter().map(|d| d.clone().to_dim()).collect::<TVec<_>>(), &b.i...
code_fim
hard
{ "lang": "rust", "repo": "dtolnay-contrib/tract", "path": "/core/src/ops/matmul.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dtolnay-contrib/tract path: /core/src/ops/matmul.rs pub mod lir_unary; pub mod mir; pub mod mir_quant; pub mod mir_quant_unary; pub mod mir_unary; pub mod pack; use crate::internal::*; use tract_itertools::Itertools; use tract_linalg::mmm::FusedSpec; use tract_ndarray::prelude::*; pub use self...
code_fim
hard
{ "lang": "rust", "repo": "dtolnay-contrib/tract", "path": "/core/src/ops/matmul.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Asapin/bf_compile path: /src/optimizer.rs use crate::enums::Command; pub struct Optimizer {} impl Optimizer { pub fn optimize_ir(ir: &[Command]) -> Vec<Command> { ir.iter() .map(|command| match command { Command::Loop { commands } => { ...
code_fim
hard
{ "lang": "rust", "repo": "Asapin/bf_compile", "path": "/src/optimizer.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>erse { step: *n } } Command::DecValByN { n: _ } => Command::SetZero, Command::Loop { commands } => Command::Loop { commands: Optimizer::optimize_ir(commands), }, ...
code_fim
hard
{ "lang": "rust", "repo": "Asapin/bf_compile", "path": "/src/optimizer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>", + "powerpc-unknown-netbsd" => "BSD-generic32", "powerpc64-unknown-freebsd" => "BSD-generic64", "powerpc64-unknown-linux-gnu" => "linux-ppc64", "powerpc64le-unknown-linux-gnu" => "linux-ppc64le", "riscv64gc-unknown-linux-gnu" => "linux-generic64", ...
code_fim
hard
{ "lang": "rust", "repo": "erig0/pkgsrc-wip", "path": "/rust/patches/patch-vendor_openssl-src_src_lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>-unknown-freebsd" => "BSD-x86-elf", "i686-unknown-linux-gnu" => "linux-elf", "i686-unknown-linux-musl" => "linux-elf", + "i686-unknown-netbsd" => "BSD-x86-elf", "mips-unknown-linux-gnu" => "linux-mips32", "mips-unknown-linux-musl" => "linux-mips32", ...
code_fim
hard
{ "lang": "rust", "repo": "erig0/pkgsrc-wip", "path": "/rust/patches/patch-vendor_openssl-src_src_lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: erig0/pkgsrc-wip path: /rust/patches/patch-vendor_openssl-src_src_lib.rs $NetBSD: patch-vendor_openssl-src_src_lib.rs,v 1.1 2021/01/01 20:44:48 he Exp $ Provide defaults for the various NetBSD targets. --- vendor/openssl-src/src/lib.rs.orig 2020-11-16 14:27:50.000000000 +0000 +++ vendor/openss...
code_fim
hard
{ "lang": "rust", "repo": "erig0/pkgsrc-wip", "path": "/rust/patches/patch-vendor_openssl-src_src_lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nickray/nrf5340-pac path: /nrf5340-net-pac/src/cti_ns/ctitrigoutstatus.rs #[doc = "Reader of register CTITRIGOUTSTATUS"] pub type R = crate::R<u32, super::CTITRIGOUTSTATUS>; #[doc = "Processor debug request\n\nValue on reset: 0"] #[derive(Clone, Copy, Debug, PartialEq)] pub enum DEBUGREQ_A { ...
code_fim
hard
{ "lang": "rust", "repo": "nickray/nrf5340-pac", "path": "/nrf5340-net-pac/src/cti_ns/ctitrigoutstatus.rs", "mode": "psm", "license": "0BSD", "source": "the-stack-v2" }
<|fim_suffix|> if maybe_depositor.is_none() { collection_details.owner_deposit.saturating_accrue(deposit); collection_details.owner_deposit.saturating_reduce(old_deposit.amount); } *metadata = Some(ItemMetadata { deposit: ItemMetadataDeposit { account: maybe_depositor, amount: deposit }, data: ...
code_fim
hard
{ "lang": "rust", "repo": "paritytech/substrate", "path": "/frame/nfts/src/features/metadata.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: paritytech/substrate path: /frame/nfts/src/features/metadata.rs // This file is part of Substrate. // Copyright (C) Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in com...
code_fim
hard
{ "lang": "rust", "repo": "paritytech/substrate", "path": "/frame/nfts/src/features/metadata.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> collection_details.item_metadatas.saturating_dec(); T::Currency::unreserve(&depositor_account, metadata.deposit.amount); if depositor_account == collection_details.owner { collection_details.owner_deposit.saturating_reduce(metadata.deposit.amount); } Collection::<T, I>::insert(&collection, ...
code_fim
hard
{ "lang": "rust", "repo": "paritytech/substrate", "path": "/frame/nfts/src/features/metadata.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: scotttrinh/automerge-rs path: /automerge/src/error.rs use crate::types::{ActorId, ScalarValue}; use crate::value::DataType; use crate::{decoding, encoding, ChangeHash}; use thiserror::Error; #[derive(Error, Debug, PartialEq)] pub enum AutomergeError { #[error("invalid obj id format `{0}`")]...
code_fim
hard
{ "lang": "rust", "repo": "scotttrinh/automerge-rs", "path": "/automerge/src/error.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Error, Debug, PartialEq)] #[error("Invalid change hash slice: {0:?}")] pub struct InvalidChangeHashSlice(pub Vec<u8>); #[derive(Error, Debug, PartialEq)] #[error("Invalid object ID: {0}")] pub struct InvalidObjectId(pub String); #[derive(Error, Debug)] #[error("Invalid element ID: {0}")] pub st...
code_fim
hard
{ "lang": "rust", "repo": "scotttrinh/automerge-rs", "path": "/automerge/src/error.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> max(a, b) - min(a, b) } pub fn in_card(offset: usize, card: usize) -> bool { CARDS[card].contains(&offset) } const CARDS: &[&[usize]] = &[ &[7, 13, 17], &[7, 11, 13], &[7, 11, 17], &[6, 8, 11, 13], &[7, 10, 14], &[2, 17], &[6, 8, 16, 18], &[7, 16, 18], &[5, 9,...
code_fim
hard
{ "lang": "rust", "repo": "LHolten/onitama-game", "path": "/onitama-lib/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: LHolten/onitama-game path: /onitama-lib/src/lib.rs extern crate serde; use boolinator::Boolinator; use serde::{Deserialize, Serialize}; use std::{ cmp::{max, min}, mem::{replace, take}, ops::Not, time::Duration, }; #[derive(Debug, Serialize, Deserialize)] pub struct ClientMsg {...
code_fim
hard
{ "lang": "rust", "repo": "LHolten/onitama-game", "path": "/onitama-lib/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let king = game.board.iter().position(|&p| p == KING).unwrap(); is_check_card(game, king, game.cards[3]) || is_check_card(game, king, game.cards[4]) } fn is_check_card(game: &ServerMsg, from: usize, card: usize) -> bool { CARDS[card] .iter() .map(|&offset| apply_offset(offset,...
code_fim
hard
{ "lang": "rust", "repo": "LHolten/onitama-game", "path": "/onitama-lib/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: azuqua/fred.rs path: /src/multiplexer/utils.rs } pub fn last_command_has_blocking_response(last_request: &Rc<RefCell<Option<RedisCommand>>>) -> bool { last_request.borrow() .deref() .as_ref() .map(|c| c.kind.has_blocking_response_kind()) .unwrap_or(false) } pub fn merge_multi...
code_fim
hard
{ "lang": "rust", "repo": "azuqua/fred.rs", "path": "/src/multiplexer/utils.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // try to do this such that the channel and message only cloned len() times, not len() + 1 // while also checking for closed receivers during iteration let to_send = message_tx_ref.len() - 1; for idx in 0..to_send { // send clones let tx = match message_tx_ref.get(...
code_fim
hard
{ "lang": "rust", "repo": "azuqua/fred.rs", "path": "/src/multiplexer/utils.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let state = ValueScanResult::SScan(SScanResult { can_continue, inner: inner.clone(), scan_state, args, results: Some(result) }); tx.unbounded_send(Ok(state)) .map_err(|_| RedisError::new(RedisErrorKind::Unknown, "Error sending value scan c...
code_fim
hard
{ "lang": "rust", "repo": "azuqua/fred.rs", "path": "/src/multiplexer/utils.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: furuhama/open_data_structures_in_rust path: /src/solvers/read_file.rs use super::super::modules::list_container::{ListContainer, Node}; use std::fs::File; use std::io::{BufRead, BufReader, Lines}; pub fn read_files_and_do_something() { // `seed_data.txt` contains 1,000,000 lines of texts. ...
code_fim
hard
{ "lang": "rust", "repo": "furuhama/open_data_structures_in_rust", "path": "/src/solvers/read_file.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn read_each_50_lines(lines: &mut Lines<BufReader<File>>, list_container: &mut ListContainer) { let mut idx = 0; // while let Ok(i) = read_50_lines_and_write(lines, list_container, idx) { while let Ok(i) = read_50_lines_and_write_from_last(lines, list_container, idx) { idx = i; ...
code_fim
hard
{ "lang": "rust", "repo": "furuhama/open_data_structures_in_rust", "path": "/src/solvers/read_file.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // while let Ok(i) = read_50_lines_and_write(lines, list_container, idx) { while let Ok(i) = read_50_lines_and_write_from_last(lines, list_container, idx) { idx = i; println!("Take a break, I'm little bit tired. I'm in line {}.", idx); } } fn read_50_lines_and_write( lines...
code_fim
hard
{ "lang": "rust", "repo": "furuhama/open_data_structures_in_rust", "path": "/src/solvers/read_file.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if rogue_dhcp_ips.len() > 0 { println!("Found rogue DHCP servers: {:?}", rogue_dhcp_ips); } Ok(()) } fn listen_for_dhcp_broadcasts() -> Vec<IpAddr>{ let now = Instant::now(); let five_seconds = Duration::new(5,0); let socket = UdpSocket::bind("0.0.0.0:68").unwrap(); ...
code_fim
hard
{ "lang": "rust", "repo": "lukehackworth/windows_rogue_dhcp", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lukehackworth/windows_rogue_dhcp path: /src/main.rs use std::net::{IpAddr, UdpSocket}; use std::time::{Duration, Instant}; use std::fs; use ipconfig; fn main() -> std::io::Result<()> { let system_ip_addresses = get_system_ip_adresses(); let mut found_dhcp_server_ips: Vec<IpAddr> = ...
code_fim
hard
{ "lang": "rust", "repo": "lukehackworth/windows_rogue_dhcp", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: limotree/shadowsocks-rust path: /src/relay/udprelay/local.rs //! UDP local relay server use std::{ io::{self, Error, ErrorKind}, time::Duration, }; use crate::{config::ConfigType, context::SharedContext}; <|fim_suffix|> if context.config().udp_timeout == Some(Duration::from_secs(0)...
code_fim
hard
{ "lang": "rust", "repo": "limotree/shadowsocks-rust", "path": "/src/relay/udprelay/local.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match context.config().config_type { ConfigType::Socks5Local => super::socks5_local::run(context).await, #[cfg(feature = "local-socks4")] ConfigType::Socks4Local => unreachable!(), #[cfg(feature = "local-tunnel")] ConfigType::TunnelLocal => super::tunnel_local::...
code_fim
medium
{ "lang": "rust", "repo": "limotree/shadowsocks-rust", "path": "/src/relay/udprelay/local.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> file.write_all(default_data.as_bytes()).expect("write file failed."); println!("please finish config file and run again"); } match File::open(file_path) { Err(why) => panic!("couldn't open {}: {}", file_path.display(), why), Ok(file) => file } } fn read_codex_...
code_fim
hard
{ "lang": "rust", "repo": "is-DW/codex", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: is-DW/codex path: /src/main.rs use std::fs::File; use std::io::{Write}; use std::process::{ Command }; use std::env; use std::path::{ Path }; use structopt::StructOpt; use serde::{ Deserialize, Serialize }; use serde_json::Result; <|fim_suffix|> file.write_all(default_data.as_bytes()).e...
code_fim
hard
{ "lang": "rust", "repo": "is-DW/codex", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn wait_all(&self) { while self.thread_pool_data.task_count.load(Ordering::Relaxed) != 0 { yield_now(); } } pub fn destroy(&self) { self.thread_pool_data.stop.store(true, Ordering::Release); let (_, cvar) = &self.thread_pool_data.cond_mutex_pair...
code_fim
hard
{ "lang": "rust", "repo": "supervitas/path-tracer", "path": "/src/renderer/thread_pool.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: supervitas/path-tracer path: /src/renderer/thread_pool.rs extern crate num_cpus; use std::thread; use std::sync::{Arc, Condvar, Mutex}; use std::sync::atomic::{AtomicBool, Ordering, AtomicUsize}; use std::thread::yield_now; use std::collections::VecDeque; struct ThreadPoolData { task_count...
code_fim
hard
{ "lang": "rust", "repo": "supervitas/path-tracer", "path": "/src/renderer/thread_pool.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn dfs(i : usize, j : usize, id : usize, board : &mut Vec<Vec<char>>, word : &mut Vec<char>) -> bool { if id == (word.len() - 1) { return true; } let a = board[i][j]; board[i][j] = '#'; if i > 0 && board[i - 1][j] == word[id + 1] && Solution::dfs...
code_fim
hard
{ "lang": "rust", "repo": "HectorIGH/Competitive-Programming", "path": "/Leetcode Challenge/07_July_2020/Rust/Week 3/7_Word Search.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: HectorIGH/Competitive-Programming path: /Leetcode Challenge/07_July_2020/Rust/Week 3/7_Word Search.rs //Given a 2D board and a word, find if the word exists in the grid. // //The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or ...
code_fim
hard
{ "lang": "rust", "repo": "HectorIGH/Competitive-Programming", "path": "/Leetcode Challenge/07_July_2020/Rust/Week 3/7_Word Search.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl ChunkCumAgg<CategoricalType> for CategoricalChunked {} impl ChunkCumAgg<Utf8Type> for Utf8Chunked {} impl ChunkCumAgg<ListType> for ListChunked {} impl ChunkCumAgg<BooleanType> for BooleanChunked { fn cum_max(&self, reverse: bool) -> ChunkedArray<BooleanType> { let iter: Box<dyn Iterator<...
code_fim
hard
{ "lang": "rust", "repo": "haixuanTao/polars", "path": "/polars/polars-core/src/chunked_array/ops/cum_agg.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: haixuanTao/polars path: /polars/polars-core/src/chunked_array/ops/cum_agg.rs use crate::prelude::*; use itertools::__std_iter::FromIterator; use num::Bounded; use std::ops::AddAssign; impl<T> ChunkCumAgg<T> for ChunkedArray<T> where T: PolarsNumericType, T::Native: Bounded + PartialOrd ...
code_fim
hard
{ "lang": "rust", "repo": "haixuanTao/polars", "path": "/polars/polars-core/src/chunked_array/ops/cum_agg.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: burdges/bellman path: /src/curves/tests/fields.rs use rand::{self, Rng}; use super::super::{Engine, Field, SqrtField, PrimeField}; fn inversion_tests<E: Engine, F: Field<E>, R: Rng>(e: &E, rng: &mut R) { let mut a = F::one(e); for _ in 0..10000 { let mut b = a.inverse(e).unwrap(...
code_fim
hard
{ "lang": "rust", "repo": "burdges/bellman", "path": "/src/curves/tests/fields.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(acc, c); acc.add_assign(e, &F::one(e)); } } { let mut acc = F::one(e); for _ in 0..SAMPLES { match acc.sqrt(e) { Some(mut a) => { a.square(e); assert_eq!(a, acc); ...
code_fim
hard
{ "lang": "rust", "repo": "burdges/bellman", "path": "/src/curves/tests/fields.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.buffer.write(buf) } fn flush(&mut self) -> Result<(), Error> { trace!("flush the connection"); self.set_timestamp(Some(time::precise_time_ns())); let result = match self.buffer.write_to(&mut self.session) { Ok(Some(bytes)) => { // ...
code_fim
hard
{ "lang": "rust", "repo": "altusnets/rpc-perf", "path": "/rpc-perf/src/session/tls_session.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn write_buf(&mut self) -> &mut BytesMut { self.buffer.tx_buffer() } fn read_to(&mut self) -> Result<usize, Error> { self.session_read()?; match self.buffer.read_from(&mut self.session) { Ok(Some(0)) => { trace!("connection closed on read");...
code_fim
hard
{ "lang": "rust", "repo": "altusnets/rpc-perf", "path": "/rpc-perf/src/session/tls_session.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: altusnets/rpc-perf path: /rpc-perf/src/session/tls_session.rs // Copyright 2019 Twitter, Inc. // Licensed under the Apache License, Version 2.0 // http://www.apache.org/licenses/LICENSE-2.0 use crate::session::*; use buffer::Buffer; use rustls::Session as OtherSession; use rustls::{ClientConfi...
code_fim
hard
{ "lang": "rust", "repo": "altusnets/rpc-perf", "path": "/rpc-perf/src/session/tls_session.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub type CowError<Cx> = CowErr<MapErr<Cx>, GetErr<Cx>, MapPhysPageErr<Cx>>; impl<Cx: Context> Space<Cx> where Cx::PageData: AsRef<PageRefCount>, { pub fn page_fault( self: Pin<&Self>, fault_addr: VirtAddr, fault_conditions: FaultConditions, ) -> Result<(), FaultError<C...
code_fim
hard
{ "lang": "rust", "repo": "aalistairr/brutos", "path": "/memory/vm/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self: Pin<&Self>, mapping: &Pin<Arc<Mapping<Cx>, Cx>>, entry: <Cx::MmuMap as MmuMap>::Entry, offset: usize, ) { let ps = mapping.page_size; let page = entry.address(ps); if entry.flags(ps).copied { self.release_copied_page(mapping, pa...
code_fim
hard
{ "lang": "rust", "repo": "aalistairr/brutos", "path": "/memory/vm/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aalistairr/brutos path: /memory/vm/src/lib.rs ze, Ordering}; use brutos_alloc::{AllocOne, Arc, ArcInner, OutOfMemory}; use brutos_memory_traits::{AllocPhysPage, MapPhysPage, MmuEntry, MmuMap}; use brutos_memory_units::{PhysAddr, VirtAddr}; use brutos_sync::condvar::Condvar; use brutos_sync::mut...
code_fim
hard
{ "lang": "rust", "repo": "aalistairr/brutos", "path": "/memory/vm/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> info!("find ref {:?} to repo:{}", sha.to_string(), full_name); let x: Value = octocrab.patch(format!("/repos/htynkn/{}/git/refs/heads/{}", repo_name, &default_branch), Some(&serde_json::json!({ "sha": sha.to_string() }))).await.unwrap(); ...
code_fim
hard
{ "lang": "rust", "repo": "htynkn/faas-collections", "path": "/update-forked-repo-rust/code/src/handler.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: htynkn/faas-collections path: /update-forked-repo-rust/code/src/handler.rs use octocrab::models::repos::Object; use octocrab::models::Repository; use octocrab::Octocrab; use octocrab::params::repos::Reference; use serde_json::Value; use warp::{Rejection, Reply}; use warp::http::StatusCode; pub ...
code_fim
hard
{ "lang": "rust", "repo": "htynkn/faas-collections", "path": "/update-forked-repo-rust/code/src/handler.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: peredwardsson/rpg_rust path: /src/renderer.rs use specs::{ReadStorage, join::Join, ReadExpect}; use crate::components::*; use sdl2::render::{WindowCanvas, Texture, TextureCreator, TextureQuery}; use sdl2::pixels::Color; use sdl2::{video::WindowContext, rect::{Point, Rect}}; use std::collections:...
code_fim
hard
{ "lang": "rust", "repo": "peredwardsson/rpg_rust", "path": "/src/renderer.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let (width, height) = canvas.output_size()?; let origin = Point::new(width as i32 / 2, height as i32 /2); canvas.set_draw_color(Color::RGB(255, 0, 0)); for (pos, sprite, col) in (&position, &sprite, (&collision).maybe()).join() { match col { Some(col) => { ...
code_fim
hard
{ "lang": "rust", "repo": "peredwardsson/rpg_rust", "path": "/src/renderer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if *gamestate == Gamestate::Dialogue { if let Some(dialogue_item) = dialogue_list.front() { if dialogue_item.dialogue_text != previous_dialogue.text { // Update the texture if there's new dialogue txt_texture = text_to_texture(&texture_creator, &(di...
code_fim
hard
{ "lang": "rust", "repo": "peredwardsson/rpg_rust", "path": "/src/renderer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mklein994/weather path: /src/graph.rs mod font; use ansi_term; pub use self::font::Style; use self::font::SPARKS_FONT_SIZE; pub use self::font::{Font, Weight}; use crate::color::Color; #[derive(Copy, Clone, Debug, Default, Deserialize)] #[serde(deny_unknown_fields)] pub struct Highlight { ...
code_fim
hard
{ "lang": "rust", "repo": "mklein994/weather", "path": "/src/graph.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn calculate_min_max_and_ratio(values: &[Option<f64>], size: usize) -> (f64, f64, f64) { let mut min = ::std::f64::MAX; let mut max = ::std::f64::MIN; values.iter().filter_map(|i| *i).for_each(|i| { if i > max { max = i; } if i < min { min = i;...
code_fim
hard
{ "lang": "rust", "repo": "mklein994/weather", "path": "/src/graph.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kyeah/codegenta path: /tests/gen/system/base.rs //! WARNING: This file is generated, derived from table system.base, DO NOT EDIT use chrono::datetime::DateTime; use chrono::offset::utc::UTC; use uuid::Uuid; use rustorm::dao::Dao; use rustorm::dao::IsDao; use rustorm::table::IsTable; use rustorm...
code_fim
hard
{ "lang": "rust", "repo": "kyeah/codegenta", "path": "/tests/gen/system/base.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn to_dao(&self)->Dao{ let mut dao = Dao::new(); match self.organization_id{ Some(ref _value) => dao.set("organization_id", _value), None => dao.set_null("organization_id") } match self.client_id{ Some(ref _value) => dao.set("client_i...
code_fim
hard
{ "lang": "rust", "repo": "kyeah/codegenta", "path": "/tests/gen/system/base.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let (a, b) = (1, 2); println!("{}", Solution::add(a, b)); }<|fim_prefix|>// repo: Schenk75/Learn-Rust path: /leetcode-by-rust/LCOF/lcof65-不用加减乘除做加法/src/main.rs struct Solution; impl Solution { pub fn add(a: i32, b: i32) -> i32 { let (mut a, mut b) = (a, b); while b != 0 { // ...
code_fim
easy
{ "lang": "rust", "repo": "Schenk75/Learn-Rust", "path": "/leetcode-by-rust/LCOF/lcof65-不用加减乘除做加法/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Schenk75/Learn-Rust path: /leetcode-by-rust/LCOF/lcof65-不用加减乘除做加法/src/main.rs struct Solution; impl Solution { pub fn add(a: i32, b: i32) -> i32 { let (mut a, mut b) = (a, b); while b != 0 { // 当进位为 0 时跳出 let c = (a & b) << 1; // c = 进位 a ^= b; // a ...
code_fim
easy
{ "lang": "rust", "repo": "Schenk75/Learn-Rust", "path": "/leetcode-by-rust/LCOF/lcof65-不用加减乘除做加法/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> unsafe { let name = CString::new("asdf").unwrap(); assert_eq!(1, cashacc_check_name(name.as_ptr(), 4)); let name = CString::new("").unwrap(); assert_eq!(0, cashacc_check_name(name.as_ptr(), 0)); } } }<|fim_prefix|>// repo: dagurval/cashac...
code_fim
medium
{ "lang": "rust", "repo": "dagurval/cashaccount-sys", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dagurval/cashaccount-sys path: /src/lib.rs #![allow(non_upper_case_globals)] #![allow(non_camel_case_types)] #![allow(non_snake_case)] include!(concat!(env!("OUT_DIR"), "/bindings.rs")); <|fim_suffix|> unsafe { let name = CString::new("asdf").unwrap(); assert_eq!...
code_fim
medium
{ "lang": "rust", "repo": "dagurval/cashaccount-sys", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests { use std::ffi::CString; use super::*; #[test] fn accountname() { unsafe { let name = CString::new("asdf").unwrap(); assert_eq!(1, cashacc_check_name(name.as_ptr(), 4)); let name = CString::new("").unwrap(); as...
code_fim
medium
{ "lang": "rust", "repo": "dagurval/cashaccount-sys", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/miri path: /test-cargo-miri/tests/test.rs #[test] fn simple() { assert_eq!(4, 4); } // A test that won't work on miri (tests disabling tests). #[test] #[cfg_attr(miri, ignore)] fn does_not_work_on_miri() { // Only do this where inline assembly is stable. #[cfg(any(target_a...
code_fim
medium
{ "lang": "rust", "repo": "rust-lang/miri", "path": "/test-cargo-miri/tests/test.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>// A different way of raising a panic #[test] #[allow(unconditional_panic)] #[should_panic(expected = "the len is 0 but the index is 42")] fn fail_index_check() { [][42] }<|fim_prefix|>// repo: rust-lang/miri path: /test-cargo-miri/tests/test.rs #[test] fn simple() { assert_eq!(4, 4); } // A tes...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/miri", "path": "/test-cargo-miri/tests/test.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn matches(&self, _network_id: NetworkId) -> bool { // We store the genesis block hash for future reference. // However, our circuits currently are generic over the genesis block, // which is why we exclude it from the check. self.blocks_per_epoch == Policy::blocks_...
code_fim
medium
{ "lang": "rust", "repo": "nimiq/core-rs-albatross", "path": "/zkp-circuits/src/metadata.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nimiq/core-rs-albatross path: /zkp-circuits/src/metadata.rs use std::{fs::File, io, path::Path}; use nimiq_hash::Blake2bHash; use nimiq_primitives::{networks::NetworkId, policy::Policy}; use nimiq_serde::{Deserialize, Serialize}; <|fim_suffix|> pub fn matches(&self, _network_id: NetworkId) ...
code_fim
hard
{ "lang": "rust", "repo": "nimiq/core-rs-albatross", "path": "/zkp-circuits/src/metadata.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: laizy/ice path: /src/agent/agent_vnet_test.rs <usize> { Ok(0) } async fn local_addr(&self) -> io::Result<SocketAddr> { Ok(SocketAddr::new(Ipv4Addr::new(0, 0, 0, 0).into(), 0)) } } pub(crate) struct VNet { pub(crate) wan: Arc<Mutex<router::Router>>, pub(crate)...
code_fim
hard
{ "lang": "rust", "repo": "laizy/ice", "path": "/src/agent/agent_vnet_test.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let v = build_vnet(nat_type0, nat_type1).await?; log::debug!("Connecting..."); let a0test_config = AgentTestConfig { urls: vec![], nat_1to1_ip_candidate_type: CandidateType::Host, // Use 1:1 NAT IP as a host candidate }; let a1test_config = AgentTestConfig { ur...
code_fim
hard
{ "lang": "rust", "repo": "laizy/ice", "path": "/src/agent/agent_vnet_test.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> connect_with_vnet(&controlling_agent, &controlled_agent).await?; // Assert we have gone to connected block_until_state_seen( ConnectionState::Connected, &mut controlling_state_changes_rx, ) .await; block_until_state_seen(ConnectionState::Connected, &mut controlled_...
code_fim
hard
{ "lang": "rust", "repo": "laizy/ice", "path": "/src/agent/agent_vnet_test.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: KieronJ/rpsx path: /src/psx/cdrom/container/no_disk.rs use std::path; use super::Container; pub struct NoDisk; <|fim_suffix|> for i in 0..buffer.len() { buffer[i] = 0; } Err("No disk inserted".to_string()) } }<|fim_middle|>impl Container for NoDisk { fn open(_: &path::...
code_fim
hard
{ "lang": "rust", "repo": "KieronJ/rpsx", "path": "/src/psx/cdrom/container/no_disk.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for i in 0..buffer.len() { buffer[i] = 0; } Err("No disk inserted".to_string()) } }<|fim_prefix|>// repo: KieronJ/rpsx path: /src/psx/cdrom/container/no_disk.rs use std::path; use super::Container; pub struct NoDisk; impl Container for NoDisk { fn open(_: &path::Path) -> Resul...
code_fim
medium
{ "lang": "rust", "repo": "KieronJ/rpsx", "path": "/src/psx/cdrom/container/no_disk.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AlexanderThaller/todust path: /src/store/vcs.rs use log::debug; use serde::{ Deserialize, Serialize, }; use std::{ fmt, path::Path, }; #[derive(Debug, Serialize, Deserialize, Clone)] pub(super) struct VcsSettings { #[serde(rename = "type")] vcs_type: VcsType, } impl Def...
code_fim
hard
{ "lang": "rust", "repo": "AlexanderThaller/todust", "path": "/src/store/vcs.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Ok(()) } } #[derive(Debug)] pub(super) enum VcsSettingsError { Add(std::io::Error), Commit(std::io::Error), Pull(std::io::Error), Push(std::io::Error), } impl fmt::Display for VcsSettingsError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self...
code_fim
hard
{ "lang": "rust", "repo": "AlexanderThaller/todust", "path": "/src/store/vcs.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match self { VcsSettingsError::Add(err) => write!(f, "can not add files to git repository: {}", err), VcsSettingsError::Commit(err) => { write!(f, "can not commit changes to git repository: {}", err) } VcsSettingsError::Pull(err) =>...
code_fim
hard
{ "lang": "rust", "repo": "AlexanderThaller/todust", "path": "/src/store/vcs.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mystor/dist-xprs-example path: /rt/nsISecretDecoderRing.rs // // DO NOT EDIT. THIS FILE IS GENERATED FROM ../../../dist/idl/nsISecretDecoderRing.idl // #[repr(C)] pub struct nsISecretDecoderRing { vtable: *const nsISecretDecoderRingVTable, /// This field is a phantomdata to ensure th...
code_fim
hard
{ "lang": "rust", "repo": "mystor/dist-xprs-example", "path": "/rt/nsISecretDecoderRing.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let schema = ASTBuilder::default() .with_directory("./examples/schema_old") .with_directory("./examples/schema") .build(); let _result = schema.generate("./examples/test/src/generated", "generated"); }<|fim_prefix|>// repo: Project-StarDust/spatialos-codegen path: /example...
code_fim
easy
{ "lang": "rust", "repo": "Project-StarDust/spatialos-codegen", "path": "/examples/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Project-StarDust/spatialos-codegen path: /examples/main.rs use spatialos_codegen::ASTBuilder; <|fim_suffix|> let schema = ASTBuilder::default() .with_directory("./examples/schema_old") .with_directory("./examples/schema") .build(); let _result = schema.generate("....
code_fim
easy
{ "lang": "rust", "repo": "Project-StarDust/spatialos-codegen", "path": "/examples/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let prog = Prog { inst: vec![ Inst::Set { target: 1_u8.into(), value: 2_u8.into(), span: 0..0, }, Inst::Set { target: 2_u8.into(), value: ...
code_fim
hard
{ "lang": "rust", "repo": "iCodeIN/while-lang", "path": "/src/evaluator.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: iCodeIN/while-lang path: /src/evaluator.rs use std::{ collections::HashMap, convert::{TryFrom, TryInto}, }; use num_bigint::BigUint; use num_traits::Zero; use crate::*; #[derive(Debug, Clone)] enum Repeat<T> { Once(T), Many(T, BigUint), } #[derive(Debug)] pub struct Frame { ...
code_fim
hard
{ "lang": "rust", "repo": "iCodeIN/while-lang", "path": "/src/evaluator.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let fname = format!("linker_{}.lds", platform); let output_arch = if arch == "x86_64" { "i386:x86-64" } else if arch.contains("riscv") { "riscv" // OUTPUT_ARCH of both riscv32/riscv64 is "riscv" } else { arch }; let ld_content = std::fs::read_to_string("link...
code_fim
hard
{ "lang": "rust", "repo": "rcore-os/arceos", "path": "/modules/axhal/build.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rcore-os/arceos path: /modules/axhal/build.rs use std::io::Result; fn main() { let arch = std::env::var("CARGO_CFG_TARGET_ARCH").unwrap(); let platform = axconfig::PLATFORM; if platform != "dummy" { gen_linker_script(&arch, platform).unwrap(); } <|fim_suffix|>fn gen_lin...
code_fim
medium
{ "lang": "rust", "repo": "rcore-os/arceos", "path": "/modules/axhal/build.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: david-mcgillicuddy-moixa/rumqtt path: /src/codec.rs //! Codec to convert incoming bytes of a tcp stream into mqtt packets //! and outgoing mqtt packets to raw bytes use bytes::BytesMut; use mqtt311::{self, MqttRead, MqttWrite, Packet}; use std::io::{self, Cursor, ErrorKind}; use tokio::codec::{D...
code_fim
hard
{ "lang": "rust", "repo": "david-mcgillicuddy-moixa/rumqtt", "path": "/src/codec.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> let (packet, len) = { let mut buf_ref = buf.as_ref(); match buf_ref.read_packet_with_len() { Err(e) => { if let mqtt311::Error::Io(e) = e { match e.kind() { ErrorKind::TimedOut | ErrorKi...
code_fim
hard
{ "lang": "rust", "repo": "david-mcgillicuddy-moixa/rumqtt", "path": "/src/codec.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> // NOTE: It's possible that `decode` got called before `buf` has full bytes // necessary to frame raw bytes into a packet. In that case return Ok(None) // and the next time decode` gets called, there will be more bytes in `buf`, // hopefully enough to frame the packet ...
code_fim
hard
{ "lang": "rust", "repo": "david-mcgillicuddy-moixa/rumqtt", "path": "/src/codec.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DanielMena399/cc1312take3 path: /cc1312/src/prcm/secdmaclkgds.rs #[doc = "Reader of register SECDMACLKGDS"] pub type R = crate::R<u32, super::SECDMACLKGDS>; #[doc = "Writer for register SECDMACLKGDS"] pub type W = crate::W<u32, super::SECDMACLKGDS>; #[doc = "Register SECDMACLKGDS `reset()`'s wit...
code_fim
hard
{ "lang": "rust", "repo": "DanielMena399/cc1312take3", "path": "/cc1312/src/prcm/secdmaclkgds.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>oc = "Bit 2 - PKA_CLK_EN"] #[inline(always)] pub fn pka_clk_en(&self) -> PKA_CLK_EN_R { PKA_CLK_EN_R::new(((self.bits >> 2) & 0x01) != 0) } #[doc = "Bit 1 - TRNG_CLK_EN"] #[inline(always)] pub fn trng_clk_en(&self) -> TRNG_CLK_EN_R { TRNG_CLK_EN_R::new(((self.bits >...
code_fim
hard
{ "lang": "rust", "repo": "DanielMena399/cc1312take3", "path": "/cc1312/src/prcm/secdmaclkgds.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Criterion::default().warm_up_time(core::time::Duration::new(0, 500)).noise_threshold(0.05) } criterion_group!( name = morton; config = config(); targets = bench_morton );<|fim_prefix|>// repo: bcolloran/yasph2d path: /benches/benchmarks/morton.rs use criterion::{black_box, criterion_grou...
code_fim
hard
{ "lang": "rust", "repo": "bcolloran/yasph2d", "path": "/benches/benchmarks/morton.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bcolloran/yasph2d path: /benches/benchmarks/morton.rs use criterion::{black_box, criterion_group, Criterion}; use yasph2d::sph::morton::*; fn bench_morton(c: &mut Criterion) { { let min = encode(2, 2); let max = encode(3, 6); let cur = encode(4, 0); // TODO...
code_fim
medium
{ "lang": "rust", "repo": "bcolloran/yasph2d", "path": "/benches/benchmarks/morton.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn config() -> Criterion { Criterion::default().warm_up_time(core::time::Duration::new(0, 500)).noise_threshold(0.05) } criterion_group!( name = morton; config = config(); targets = bench_morton );<|fim_prefix|>// repo: bcolloran/yasph2d path: /benches/benchmarks/morton.rs use criterion:...
code_fim
hard
{ "lang": "rust", "repo": "bcolloran/yasph2d", "path": "/benches/benchmarks/morton.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn test() { assert_eq!( Solution::defang_i_paddr("1.1.1.1".into()), "1[.]1[.]1[.]1".to_owned() ); }<|fim_prefix|>// repo: ackintosh/sandbox path: /rust/leetcode/src/defanging_an_ip_address.rs // https://leetcode.com/problems/defanging-an-ip-address/ struct Solution; <|fi...
code_fim
medium
{ "lang": "rust", "repo": "ackintosh/sandbox", "path": "/rust/leetcode/src/defanging_an_ip_address.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ackintosh/sandbox path: /rust/leetcode/src/defanging_an_ip_address.rs // https://leetcode.com/problems/defanging-an-ip-address/ struct Solution; impl Solution { pub fn defang_i_paddr(address: String) -> String { address.replace('.', "[.]") } } <|fim_suffix|> assert_eq!( ...
code_fim
easy
{ "lang": "rust", "repo": "ackintosh/sandbox", "path": "/rust/leetcode/src/defanging_an_ip_address.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> rest_api::serve(settings.api.rest, shared_state).await; Ok(()) }<|fim_prefix|>// repo: Rexagon/raccoin path: /blockchain/src/main.rs mod block; mod blockchain; mod hash; mod peers_network; mod rest_api; mod rpc; mod settings; mod state; <|fim_middle|>use crate::settings::Settings; use crate::st...
code_fim
hard
{ "lang": "rust", "repo": "Rexagon/raccoin", "path": "/blockchain/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Rexagon/raccoin path: /blockchain/src/main.rs mod block; mod blockchain; mod hash; mod peers_network; mod rest_api; mod rpc; mod settings; mod state; use crate::settings::Settings; use crate::state::State; <|fim_suffix|> let settings = Settings::new().expect("Unable to parse settings.json")...
code_fim
medium
{ "lang": "rust", "repo": "Rexagon/raccoin", "path": "/blockchain/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: KULeuven-COSIC/SCALE-MAMBA path: /RustPrograms/examples/test_call/main.rs // Copyright (c) 2021, COSIC-KU Leuven, Kasteelpark Arenberg 10, bus 2452, B-3001 Leuven-Heverlee, Belgium. // Copyright (c) 2021, Cosmian Tech SAS, 53-55 rue La Boétie, Paris, France. <|fim_suffix|>#[inline(never)] fn ma...
code_fim
hard
{ "lang": "rust", "repo": "KULeuven-COSIC/SCALE-MAMBA", "path": "/RustPrograms/examples/test_call/main.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> print!( "asfdasdfasfasdfasdfasdfasdfasdfasdfasdfasdfadsfasdfasdfasdfasdfasdfadsfasdfasdf", x, "\n" ); x * 2 } #[inline(never)] fn main() { print!("foo"); let y = bar(42); bar(43 + y).test(); }<|fim_prefix|>// repo: KULeuven-COSIC/SCALE-MAMBA path: /RustPrograms/ex...
code_fim
medium
{ "lang": "rust", "repo": "KULeuven-COSIC/SCALE-MAMBA", "path": "/RustPrograms/examples/test_call/main.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> ni_over_nt: f32, ) -> Option<Vector<f32>> { let uv = normalize(&vector); let dt = uv.dot(&normal); let discriminant = 1.0 - ni_over_nt.powi(2) * (1.0 - dt.powi(2)); if discriminant > 0.0 { Some(ni_over_nt * (uv - normal * dt) - normal * discriminant.s...
code_fim
hard
{ "lang": "rust", "repo": "dannyfritz/ray-tracing-in-one-weekend-rs", "path": "/src/utility.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dannyfritz/ray-tracing-in-one-weekend-rs path: /src/utility.rs #[allow(dead_code)] pub mod random { use ncollide3d::math::Vector; use rand::distributions::StandardNormal; use rand::prelude::*; pub fn rand_gaussian() -> f32 { thread_rng().sample(StandardNormal) as f32 ...
code_fim
hard
{ "lang": "rust", "repo": "dannyfritz/ray-tracing-in-one-weekend-rs", "path": "/src/utility.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: HoppinWorld/hoppinworldclient path: /src/state/login.rs use amethyst::ecs::SystemData; use amethyst::prelude::*; use amethyst::ui::*; use amethyst::utils::removal::*; use amethyst_extra::set_discord_state; use amethyst_extra::dirty::Dirty; use amethyst::core::Time; use hoppinworld_runtime::{AllE...
code_fim
hard
{ "lang": "rust", "repo": "HoppinWorld/hoppinworldclient", "path": "/src/state/login.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }