text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> self.interest.insert(EventSet::writable()); } else { trace!( target: "tcp", "Received incompelte msg ({})", String::from_utf8(buf.bytes().to_vec()).unwrap_or("<n...
code_fim
hard
{ "lang": "rust", "repo": "DigixGlobal/json-tcp-server", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> config } pub fn bind_address(&self) -> &str { &self.bind_address } pub fn bind_port(&self) -> u16 { self.bind_port } pub fn config_path(&self) -> &str { &self.config_path } } impl Default for Settings { fn default() -> Self { Sett...
code_fim
hard
{ "lang": "rust", "repo": "SnakeSolid/rust-show-on-map", "path": "/src/settings.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: SnakeSolid/rust-show-on-map path: /src/settings.rs use argparse::ArgumentParser; use argparse::StoreOption; #[derive(Debug, Clone)] pub struct Settings { bind_address: String, bind_port: u16, config_path: String, } impl Settings { pub fn from_args() -> Settings { info!(...
code_fim
hard
{ "lang": "rust", "repo": "SnakeSolid/rust-show-on-map", "path": "/src/settings.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: digitalbitbox/bitbox02-firmware path: /src/rust/vendor/miniscript/src/pub_macros.rs // SPDX-License-Identifier: CC0-1.0 //! Macros exported by the miniscript crate //! /// Macro for failing translation for other associated types. /// Handy for testing String -> concrete keys as we don't want t...
code_fim
hard
{ "lang": "rust", "repo": "digitalbitbox/bitbox02-firmware", "path": "/src/rust/vendor/miniscript/src/pub_macros.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn hash256( &mut self, _hash256: &<$source as $crate::MiniscriptKey>::Hash256, ) -> Result<<$target as $crate::MiniscriptKey>::Hash256, $error_ty> { panic!("Called hash256 on translate_only_pk") } fn hash160( &mut self, ...
code_fim
hard
{ "lang": "rust", "repo": "digitalbitbox/bitbox02-firmware", "path": "/src/rust/vendor/miniscript/src/pub_macros.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: koompi/pix path: /backend/src/main.rs // #![allow(unused_imports)] pub mod graphql; pub mod models; pub mod utils; use actix_web::{ guard, http::{header, StatusCode}, web, App, HttpRequest, HttpResponse, HttpServer, Result, }; use actix_cors::Cors; use actix_files; use actix_files a...
code_fim
hard
{ "lang": "rust", "repo": "koompi/pix", "path": "/backend/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let schema = Schema::build(QueryRoot, MutationRoot, EmptySubscription).finish(); HttpServer::new(move || { App::new() .data(schema.clone()) .wrap( // Cors::default() // .allow_any_header() // .allowed_methods(v...
code_fim
hard
{ "lang": "rust", "repo": "koompi/pix", "path": "/backend/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// 404 handler async fn p404() -> Result<fs::NamedFile> { Ok(fs::NamedFile::open("./public/index.html")?.set_status_code(StatusCode::NOT_FOUND)) } #[actix_rt::main] async fn main() -> std::io::Result<()> { let env = EnvFile::new(&Path::new(".env")).unwrap(); let file_exists = metadata("db.jso...
code_fim
hard
{ "lang": "rust", "repo": "koompi/pix", "path": "/backend/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>; pub mod queryable; pub mod query_arg; pub mod model; pub use query_result::QueryResult;<|fim_prefix|>// repo: autarch/edgedb-rust path: /edgedb-protocol/src/lib.rs mod query_result; // sealed trait should remain non-public pub mod encoding; pub mod comm<|fim_middle|>on; pub mod features; pub mod ser...
code_fim
medium
{ "lang": "rust", "repo": "autarch/edgedb-rust", "path": "/edgedb-protocol/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: autarch/edgedb-rust path: /edgedb-protocol/src/lib.rs mod query_result; // sealed trait should remain non-public pub mod encoding; pub mod comm<|fim_suffix|>; pub mod queryable; pub mod query_arg; pub mod model; pub use query_result::QueryResult;<|fim_middle|>on; pub mod features; pub mod ser...
code_fim
medium
{ "lang": "rust", "repo": "autarch/edgedb-rust", "path": "/edgedb-protocol/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Implement QueryKindTrait with query being `Value` pub struct ValueQuery; impl<Value, OnEmpty> QueryKindTrait<Value, OnEmpty> for ValueQuery where Value: FullCodec + 'static, OnEmpty: crate::traits::Get<Value>, { const METADATA: StorageEntryModifierIR = StorageEntryModifierIR::Default; type Query ...
code_fim
hard
{ "lang": "rust", "repo": "paritytech/substrate", "path": "/frame/support/src/storage/types/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn from_optional_value_to_query(v: Option<Value>) -> Self::Query { match v { Some(v) => Ok(v), None => OnEmpty::get(), } } fn from_query_to_optional_value(v: Self::Query) -> Option<Value> { v.ok() } } /// Implement QueryKindTrait with query being `Value` pub struct ValueQuery; impl<Value...
code_fim
hard
{ "lang": "rust", "repo": "paritytech/substrate", "path": "/frame/support/src/storage/types/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: paritytech/substrate path: /frame/support/src/storage/types/mod.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 ...
code_fim
hard
{ "lang": "rust", "repo": "paritytech/substrate", "path": "/frame/support/src/storage/types/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> for (i, item) in xy_out_fft.iter().enumerate().take(6) { println!("{} {} {}", i, item.re, item.im); } }<|fim_prefix|>// repo: hg2ecz/ProgrammingLanguageBenchmark-FFT_4096 path: /Rust-tests/Rust-safe-owncomplex-operator-generic/src/main.rs mod fft; use std::time::Instant; const LOG2FFTS...
code_fim
hard
{ "lang": "rust", "repo": "hg2ecz/ProgrammingLanguageBenchmark-FFT_4096", "path": "/Rust-tests/Rust-safe-owncomplex-operator-generic/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hg2ecz/ProgrammingLanguageBenchmark-FFT_4096 path: /Rust-tests/Rust-safe-owncomplex-operator-generic/src/main.rs mod fft; use std::time::Instant; const LOG2FFTSIZE: u32 = 12; const FFT_REPEAT: u32 = 10000; const SIZE: usize = (1 << LOG2FFTSIZE); <|fim_suffix|> for (i, item) in xy_out_fft....
code_fim
hard
{ "lang": "rust", "repo": "hg2ecz/ProgrammingLanguageBenchmark-FFT_4096", "path": "/Rust-tests/Rust-safe-owncomplex-operator-generic/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dhconnelly/crab path: /src/parser.rs use crate::ast::*; use crate::scanner; use crate::scanner::Tokens; use crate::token::{Token, TokenType, TokenType::*}; use std::error; use std::fmt; use std::iter::Peekable; use std::num; use std::result; // TODO: carry line and column information #[derive(D...
code_fim
hard
{ "lang": "rust", "repo": "dhconnelly/crab", "path": "/src/parser.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut left = self.add_expr(tok)?; while !self.at_end() { let tok = self.peek()?; left = match tok.typ { EqEq => self.binary_op(BinaryOp::EqEq, left)?, Less => self.binary_op(BinaryOp::Less, left)?, _ => break, ...
code_fim
hard
{ "lang": "rust", "repo": "dhconnelly/crab", "path": "/src/parser.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: g-w1/rust_game path: /src/main.rs use ggez; use ggez::event; use ggez::graphics; use ggez::timer::sleep; use std::time::Duration; mod player; use player::Rec; mod ground; use ground::Bottom; struct MainState { background: [f32; 4], player: Rec, ground: Bottom, gravity: f32, } ...
code_fim
hard
{ "lang": "rust", "repo": "g-w1/rust_game", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> graphics::clear(ctx, self.background.into()); self.player.draw(ctx)?; self.ground.draw(ctx)?; graphics::present(ctx)?; Ok(()) } } pub fn main() -> ggez::GameResult { let cb = ggez::ContextBuilder::new("platformer", "jacob"); let (ctx, event_loop) = &mut...
code_fim
medium
{ "lang": "rust", "repo": "g-w1/rust_game", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>use std::fmt; use crate::model::{ bidding::{Bid, Bidder}, game::{GameData, PlayPhaseData}, primitives::{CardId, Position}, }; pub trait Agent: fmt::Debug { /// Invoked during the Bidding phase when it's the agent's turn to bid in a /// given [Bidder] position. Should return the desir...
code_fim
medium
{ "lang": "rust", "repo": "thurn/oak", "path": "/src/agents/agent.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: thurn/oak path: /src/agents/agent.rs // Copyright © 2021-present Derek Thurn // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at <|fim_suffix|>//! Defines the trait imp...
code_fim
hard
{ "lang": "rust", "repo": "thurn/oak", "path": "/src/agents/agent.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ColonelPhantom/brainiter path: /src/to_c.rs use crate::bytecode::Bytecode; pub fn compile_c(code: &Bytecode, tape_size: usize) -> String { let mut c_code: String = format!("#include<stdio.h>\n\ #include <stdint.h>\n\ #include <stdlib.h>\n\ void main() {{\n\ ...
code_fim
hard
{ "lang": "rust", "repo": "ColonelPhantom/brainiter", "path": "/src/to_c.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn compile_c_recurse(code: &Bytecode) -> String { let mut c_code = String::new(); for i in code { use crate::bytecode::BfOperation; c_code += &match i { BfOperation::Add(x) => format!("tape[mi] += {};\n", x), BfOperation::Sub(x) => format!("tape[mi] -= {};\n...
code_fim
hard
{ "lang": "rust", "repo": "ColonelPhantom/brainiter", "path": "/src/to_c.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: itaibn/turing path: /src/turing.rs use std::collections::VecDeque; use std::fmt; use std::iter; use std::rc::Rc; use rand::{Rng, Rand}; #[derive(Clone, Copy, Debug)] pub enum Symbol {Zero, One} pub const NUM_SYMBOLS: usize = 2; const SYMBOLS: [Symbol; NUM_SYMBOLS] = [Symbol::Zero, Symbol:...
code_fim
hard
{ "lang": "rust", "repo": "itaibn/turing", "path": "/src/turing.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> write!(f, "S{}", self.0) } } impl fmt::Display for Direction { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let dir_char: char = match *self { Direction::Left => 'L', Direction::Right => 'R', }; write!(f, "{}", dir_char) } } i...
code_fim
hard
{ "lang": "rust", "repo": "itaibn/turing", "path": "/src/turing.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn is_halted(&self) -> bool { self.is_halted } pub fn tape(&self) -> &Tape { &self.tape } pub fn tape_head_position(&self) -> i32 { self.tape_head } pub fn current_state(&self) -> StateID { self.cur_state } fn read_head(&self) -> ...
code_fim
hard
{ "lang": "rust", "repo": "itaibn/turing", "path": "/src/turing.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oberien/hp-x360-elan-fix path: /src/main.rs extern crate evdev; extern crate libc; extern crate uinput_sys; extern crate uinput; extern crate mio; mod u_input; use std::os::unix::io::AsRawFd; use std::io::Error; use std::time::Duration; use evdev::{Device as EvDevice}; use uinput::Device as U...
code_fim
hard
{ "lang": "rust", "repo": "oberien/hp-x360-elan-fix", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let expected_types = evdev::SYNCHRONIZATION | evdev::KEY | evdev::ABSOLUTE | evdev::MISC; let mut device = None; for dev in evdev::enumerate() { if dev.name().to_str().unwrap() == "ELAN22CA:00 04F3:22CA" && dev.input_id().vendor == 0x4f3 ...
code_fim
hard
{ "lang": "rust", "repo": "oberien/hp-x360-elan-fix", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>struct Wave { cells: Vec<u64>, width: usize, height: usize, } const SKY_BIT: u64 = 1 << 0; const GROUND_BIT: u64 = 2 << 0; const GROUND_SKYP_UP: u64 = 2 << 0; fn main() { let model = Model { patterns: vec![ Pattern { bit: SKY_BIT, left:...
code_fim
medium
{ "lang": "rust", "repo": "nical/sketches", "path": "/src/bin/tiles.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nical/sketches path: /src/bin/tiles.rs type PatternId = usize; struct Pattern { left: u64, right: u64, up: u64, down: u64, bit: u64, } struct Model { patterns: Vec<Pattern>, } struct Wave { cells: Vec<u64>, width: usize, height: usize, } const SKY_BIT: u64...
code_fim
medium
{ "lang": "rust", "repo": "nical/sketches", "path": "/src/bin/tiles.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>const SKY_BIT: u64 = 1 << 0; const GROUND_BIT: u64 = 2 << 0; const GROUND_SKYP_UP: u64 = 2 << 0; fn main() { let model = Model { patterns: vec![ Pattern { bit: SKY_BIT, left: 0, right: 0, up: 0, down: ...
code_fim
medium
{ "lang": "rust", "repo": "nical/sketches", "path": "/src/bin/tiles.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[tokio::test] async fn check_command_formatter() { let command = Command { args: vec!["ReadAsset".to_string(), "asset1".to_string()], }; let json_view = r#"{"Args":["ReadAsset","asset1"]}"#; let formatted_command = serde_json::to_string(&command).unwrap...
code_fim
hard
{ "lang": "rust", "repo": "karnaukhovlad/hyperledger_fabric", "path": "/src/source/cli.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: karnaukhovlad/hyperledger_fabric path: /src/source/cli.rs use crate::source::{Asset, AssetsList}; use serde::{Deserialize, Serialize}; use serde_json; use std::convert::From; use std::ffi::OsString; use std::future::Future; use std::path::PathBuf; use std::process::Output; use std::{env, io}; us...
code_fim
hard
{ "lang": "rust", "repo": "karnaukhovlad/hyperledger_fabric", "path": "/src/source/cli.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>use super::super::super::qlib::mem::seq::*; use super::transport::unix::*; // EndpointWriter implements safemem.Writer that writes to a transport.Endpoint. pub struct EndpointWriter { pub Endpoint: Arc<Endpoint>, pub Control: SCMControlMessages, pub To: BoundEndpoint, } /* impl BlockSeqWriter...
code_fim
medium
{ "lang": "rust", "repo": "k82cn/Quark", "path": "/qkernel/src/socket/unix/io.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: k82cn/Quark path: /qkernel/src/socket/unix/io.rs // Copyright (c) 2021 Quark Container Authors / 2018 The gVisor Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the Lice...
code_fim
medium
{ "lang": "rust", "repo": "k82cn/Quark", "path": "/qkernel/src/socket/unix/io.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: csixteen/LeetCode path: /Problems/Algorithms/src/Rust/pascal-triangle/src/lib.rs // https://leetcode.com/problems/pascals-triangle/ #![allow(dead_code)] struct Solution; impl Solution { pub fn generate(num_rows: i32) -> Vec<Vec<i32>> { let mut ret: Vec<Vec<i32>> = Vec::new(); ...
code_fim
hard
{ "lang": "rust", "repo": "csixteen/LeetCode", "path": "/Problems/Algorithms/src/Rust/pascal-triangle/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!( vec![ vec![1], vec![1, 1], vec![1, 2, 1], vec![1, 3, 3, 1], vec![1, 4, 6, 4, 1], ], Solution::generate(5), ); } #[test] fn test_example2() { ...
code_fim
medium
{ "lang": "rust", "repo": "csixteen/LeetCode", "path": "/Problems/Algorithms/src/Rust/pascal-triangle/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: RaasAhsan/ironjdk path: /src/runtime/interpreter.rs runtime::class::method::{RuntimeMethod, MethodDescriptor}; enum Step { Next, Jump(i16), Return(Value), ReturnVoid, // TODO: Could unify with Return variant Exception(Value) } pub enum InvokeResult { Void, Value(Va...
code_fim
hard
{ "lang": "rust", "repo": "RaasAhsan/ironjdk", "path": "/src/runtime/interpreter.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let invoke_result = invoke_virtual_method(object, method, arguments, invoked_class, class_table).unwrap(); match invoke_result { InvokeResult::Value(value) => { stack_frame.push(value); Ok(Step::Next) }, ...
code_fim
hard
{ "lang": "rust", "repo": "RaasAhsan/ironjdk", "path": "/src/runtime/interpreter.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let method = invoked_class.get_method(method_ref.name_and_type.name.as_str()).unwrap(); let method_descriptor = MethodDescriptor::parse(method_ref.name_and_type.descriptor.as_str()).unwrap(); let mut arguments = stack_frame.pop_many(method_descriptor.parameters_length(...
code_fim
hard
{ "lang": "rust", "repo": "RaasAhsan/ironjdk", "path": "/src/runtime/interpreter.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub struct InfoRpcImpl<N> where N: NetworkOpsClient, { ops_client: N, } impl<N> InfoRpcImpl<N> where N: NetworkOpsClient, { pub fn new(ops_client: N) -> Self { InfoRpcImpl { ops_client } } } impl<N> InfoRpc for InfoRpcImpl<N> where N: NetworkOpsClient + 'static, { fn ...
code_fim
medium
{ "lang": "rust", "repo": "leejw51crypto/chain", "path": "/client-rpc/src/rpc/info_rpc.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl<N> InfoRpcImpl<N> where N: NetworkOpsClient, { pub fn new(ops_client: N) -> Self { InfoRpcImpl { ops_client } } } impl<N> InfoRpc for InfoRpcImpl<N> where N: NetworkOpsClient + 'static, { fn genesis(&self) -> Result<Genesis> { self.ops_client.get_genesis().map_err...
code_fim
medium
{ "lang": "rust", "repo": "leejw51crypto/chain", "path": "/client-rpc/src/rpc/info_rpc.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: leejw51crypto/chain path: /client-rpc/src/rpc/info_rpc.rs use jsonrpc_core::Result; use jsonrpc_derive::rpc; use crate::to_rpc_error; use client_common::tendermint::types::{Genesis, StatusResponse}; use client_network::NetworkOpsClient; #[rpc(server)] pub trait InfoRpc: Send + Sync { #[rpc...
code_fim
medium
{ "lang": "rust", "repo": "leejw51crypto/chain", "path": "/client-rpc/src/rpc/info_rpc.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Devolutions/devolutions-gateway path: /crates/transport/tests/forwarding.rs use anyhow::Context as _; use futures_util::FutureExt; use proptest::prelude::*; use test_utils::{find_unused_ports, payload, read_assert_payload, transport_kind, write_payload, TransportKind}; use tokio::io::AsyncWriteE...
code_fim
hard
{ "lang": "rust", "repo": "Devolutions/devolutions-gateway", "path": "/crates/transport/tests/forwarding.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> proptest!(ProptestConfig::with_cases(10), |( payload in payload().no_shrink(), client_to_node_kind in transport_kind(), node_to_server_kind in transport_kind(), )| { rt.block_on(async { let server_fut = server(&payload.0, node_to_server_kind, port_server...
code_fim
medium
{ "lang": "rust", "repo": "Devolutions/devolutions-gateway", "path": "/crates/transport/tests/forwarding.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> title("7. Loops"); loops::run(); title("8. Functions"); functions::run(); title("9. Pointer Ref"); pointer_ref::run(); title("10. Struct"); structs::run(); title("11. Enums"); enums::run(); } fn title(title: &str) { println!("<<---------{}-------->", t...
code_fim
medium
{ "lang": "rust", "repo": "PabloG6/rust_sandbox", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PabloG6/rust_sandbox path: /src/main.rs mod print; mod variables; mod types; mod string; mod arrays; mod pointer_ref; mod vectors; mod conditionals; mod loops; mod functions; mod structs; mod enums; fn main() { title("Start of tutorial!"); title("1. Print"); print::run(); title(...
code_fim
medium
{ "lang": "rust", "repo": "PabloG6/rust_sandbox", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let secret = oracle.secret.as_binvector(oracle.get_k()); let fwht_solution = fwht_solve(oracle); println!("Found (fwht): {:?}", fwht_solution); println!("Actual: {:?}", secret); }<|fim_prefix|>// repo: thomwiggers/lpn path: /examples/large_xor_fwht.rs /// An example of a reductio...
code_fim
hard
{ "lang": "rust", "repo": "thomwiggers/lpn", "path": "/examples/large_xor_fwht.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: thomwiggers/lpn path: /examples/large_xor_fwht.rs /// An example of a reduction chain for LPN_128,1/32 extern crate lpn; use lpn::bkw::*; use lpn::lf1::*; use lpn::oracle::LpnOracle; fn main() { use simple_logger::SimpleLogger; SimpleLogger::new() .with_level(log::LevelFilter::...
code_fim
hard
{ "lang": "rust", "repo": "thomwiggers/lpn", "path": "/examples/large_xor_fwht.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut oracle: LpnOracle = LpnOracle::new(128, 1.0 / 32.0); oracle.get_samples(200_000); xor_reduce(&mut oracle, 8); partition_reduce(&mut oracle, 8); partition_reduce(&mut oracle, 8); partition_reduce(&mut oracle, 8); partition_reduce(&mut oracle, 8); xor_reduce(&mut orac...
code_fim
medium
{ "lang": "rust", "repo": "thomwiggers/lpn", "path": "/examples/large_xor_fwht.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> prep_and_common!( u32, crc_32_posix, 0x4C11DB7, false, [ 0x00000000 0x04C11DB7 0x09823B6E 0x0D4326D9 0x130476DC 0x17C56B6B 0x1A864DB2 0x1E475005 0x2608EDB8 0x22C9F00F 0x2F8AD6D6 0x2B4BCB61 0x350C9B64 0x31CD86D3 0x3C8EA00A 0x384FBDBD 0x4C11DB70 0x48D0...
code_fim
hard
{ "lang": "rust", "repo": "ypoluektovich/crc-rocksoft.rs", "path": "/src/primitive/table.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ypoluektovich/crc-rocksoft.rs path: /src/primitive/table.rs use super::ValueType; use std::mem::size_of; use bit_reverse::ParallelReverse; pub type Table<T> = [T; 256]; pub fn fill_table<T: ValueType>(table: &mut Table<T>, poly: T, reflected: bool) { let zero = T::from(0); let top_bit_...
code_fim
hard
{ "lang": "rust", "repo": "ypoluektovich/crc-rocksoft.rs", "path": "/src/primitive/table.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tonlabs/ton-labs-node-storage path: /src/lt_db.rs use crate::db_impl_cbor; use crate::db:<|fim_suffix|>::{LtDbEntry, LtDbKey}; db_impl_cbor!(LtDb, KvcWriteable, LtDbKey, LtDbEntry);<|fim_middle|>:traits::KvcWriteable; use crate::types
code_fim
easy
{ "lang": "rust", "repo": "tonlabs/ton-labs-node-storage", "path": "/src/lt_db.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>LtDb, KvcWriteable, LtDbKey, LtDbEntry);<|fim_prefix|>// repo: tonlabs/ton-labs-node-storage path: /src/lt_db.rs use crate::db_impl_cbor; use crate::db::traits::KvcWriteable; use crate::types<|fim_middle|>::{LtDbEntry, LtDbKey}; db_impl_cbor!(
code_fim
easy
{ "lang": "rust", "repo": "tonlabs/ton-labs-node-storage", "path": "/src/lt_db.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tonlabs/ton-labs-node-storage path: /src/lt_db.rs use crate::db_impl_cbor; use crate::db::traits::KvcWriteable; use crate::types<|fim_suffix|>LtDb, KvcWriteable, LtDbKey, LtDbEntry);<|fim_middle|>::{LtDbEntry, LtDbKey}; db_impl_cbor!(
code_fim
easy
{ "lang": "rust", "repo": "tonlabs/ton-labs-node-storage", "path": "/src/lt_db.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Saravanan-Jodavula/libra path: /common/debug-interface/src/lib.rs // Copyright (c) The Libra Core Contributors // SPDX-License-Identifier: Apache-2.0 #![forbid(unsafe_code)] use crate::proto::{ node_debug_interface_client::NodeDebugInterfaceClient, GetEventsRequest, GetEventsResponse, ...
code_fim
hard
{ "lang": "rust", "repo": "Saravanan-Jodavula/libra", "path": "/common/debug-interface/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Self { client: None, addr, rt, } } fn client( &mut self, ) -> Result<( &mut Runtime, &mut NodeDebugInterfaceClient<tonic::transport::Channel>, )> { if self.client.is_none() { self.client = Some...
code_fim
hard
{ "lang": "rust", "repo": "Saravanan-Jodavula/libra", "path": "/common/debug-interface/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if node.get_data().is_goal() { break; } if node.get_data().is_end_state() { continue; } for mut neighbor_node in node.production() { let neighbor_id = neighbor_node.get_id(); if !visited.contains(&neighbor_id) { neighbor_node.add_parent(node...
code_fim
hard
{ "lang": "rust", "repo": "esraa-saleh/RustyAI", "path": "/rusty_ai/src/search/heuristic/a_star.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: esraa-saleh/RustyAI path: /rusty_ai/src/search/heuristic/a_star.rs use std::hash::Hash; use std::collections::HashSet; use std::collections::BinaryHeap; use core::node::Node; use core::state::State; use core::state::StateCost; use core::state::Production; pub fn a_start<T>(start: T) -> Vec<T> ...
code_fim
hard
{ "lang": "rust", "repo": "esraa-saleh/RustyAI", "path": "/rusty_ai/src/search/heuristic/a_star.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(threads_count, map.len()); assert!(map.capacity() > capacity && map.capacity() / capacity <= 2); } } /// Test concurrent remove /// /// Two threads perform remove on the same keys. /// /// Assert that if remove r1 occurs before remove r2, than r2 must view changes by r1 ///...
code_fim
hard
{ "lang": "rust", "repo": "kuzyanov/rust-concurrent-hash-map", "path": "/tests/concurrency_test.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kuzyanov/rust-concurrent-hash-map path: /tests/concurrency_test.rs use std::sync::Arc; use std::thread; use concurrent_hash_map::ConcurrentHashMap; use core::borrow::Borrow; /// Each test repeats count const TEST_COUNT: usize = 32; /// Test concurrent get value /// /// Two threads perform ins...
code_fim
hard
{ "lang": "rust", "repo": "kuzyanov/rust-concurrent-hash-map", "path": "/tests/concurrency_test.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> use rocket_okapi::okapi::openapi3::RefOr; // Can switch between to the but both are checked if they compile correctly let use_method = "recommended"; // It can return a "400 BadRequest" and a "401 Unauthorized" // In both cases we just return a what we have set in t...
code_fim
hard
{ "lang": "rust", "repo": "GREsau/okapi", "path": "/examples/secure_request_guard/src/api_key.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: GREsau/okapi path: /examples/secure_request_guard/src/api_key.rs //! ------ ApiKey (in http header, query or cookie) ------ use rocket::serde::json::Json; use rocket::{ get, http::Status, request::{self, FromRequest, Outcome}, }; use rocket_okapi::okapi; use rocket_okapi::okapi::open...
code_fim
hard
{ "lang": "rust", "repo": "GREsau/okapi", "path": "/examples/secure_request_guard/src/api_key.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AustinHaugerud/oxidsys path: /src/language/operations/agents_and_teams/agent_refill_ammo.rs use language::operations::{make_param_doc, Operation, ParamInfo}; pub struct AgentRefillAmmoOp; const DOC: &str = "Refills all ammo and throwing weapon stacks that the agent has in his equipment."; ...
code_fim
hard
{ "lang": "rust", "repo": "AustinHaugerud/oxidsys", "path": "/src/language/operations/agents_and_teams/agent_refill_ammo.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Call { /// /// A shortcut constructor. /// pub fn new(address: usize, input_size: usize) -> Self { Self { address, input_size, } } /// /// If the instruction is for the debug mode only. /// pub fn is_debug(&self) -> bool { ...
code_fim
hard
{ "lang": "rust", "repo": "prz23/zinc", "path": "/zinc-types/src/instructions/flow/call.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: prz23/zinc path: /zinc-types/src/instructions/flow/call.rs //! //! The `function call` instruction. //! use std::fmt; use serde::Deserialize; use serde::Serialize; use crate::instructions::Instruction; /// /// The `function call` instruction. /// #[derive(Debug, Clone, Serialize, Deserialize...
code_fim
medium
{ "lang": "rust", "repo": "prz23/zinc", "path": "/zinc-types/src/instructions/flow/call.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// /// If the instruction is for the debug mode only. /// pub fn is_debug(&self) -> bool { false } } impl Into<Instruction> for Call { fn into(self) -> Instruction { Instruction::Call(self) } } impl fmt::Display for Call { fn fmt(&self, f: &mut fmt::Forma...
code_fim
medium
{ "lang": "rust", "repo": "prz23/zinc", "path": "/zinc-types/src/instructions/flow/call.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn save_to_file(&mut self, file_name: &str) { let buffer = File::create(file_name).expect("Cannot create file"); let compressed = ZlibEncoder::new(buffer, Compression::default()); serde_json::to_writer(compressed, self).unwrap(); } pub fn generate_random_word(&m...
code_fim
hard
{ "lang": "rust", "repo": "sladecek/rust-wordgen-001", "path": "/src/generator.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sladecek/rust-wordgen-001 path: /src/generator.rs use std::io::BufReader; use std::fs::File; use std::collections::HashMap; use rand::{Rng}; use rand::rngs::StdRng; use serde::{Serialize, Deserialize}; use flate2::Compression; use flate2::write::ZlibEncoder; use flate2::bufread::ZlibDecoder; us...
code_fim
hard
{ "lang": "rust", "repo": "sladecek/rust-wordgen-001", "path": "/src/generator.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: curx/huber path: /src/app/src/service/config.rs use std::fs::{remove_file, File}; use std::sync::Arc; use log::{debug, info}; use crate::service::ServiceTrait; use huber_common::model::config::{Config, ConfigPath}; use huber_common::result::Result; use simpledi_rs::di::{DIContainer, DIContaine...
code_fim
hard
{ "lang": "rust", "repo": "curx/huber", "path": "/src/app/src/service/config.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if path.exists() { debug!("Getting the config from {:?}", path); let f = File::open(&path)?; Ok(serde_yaml::from_reader::<File, Config>(f)?) } else { debug!( "Getting the config from runtime, because {:?} does not exists", ...
code_fim
hard
{ "lang": "rust", "repo": "curx/huber", "path": "/src/app/src/service/config.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let integer_point = Point{ x: 5, y: 10 }; let float_point = Point{ x: 1.0, y: 1.0 }; } // Enums also enum MyResult<T, E> { Ok(T), Err(E) } // The methods in impls of a struct can use the generic type impl<T> Point<T> { fn x(&self) -> &T { &self.x } }<|fim_prefix|>// repo:...
code_fim
hard
{ "lang": "rust", "repo": "brianduff/learnrust", "path": "/generics/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> largest } // Structs can also use generic types: struct Point<T> { x: T, y: T } fn test_generic_struct() { let integer_point = Point{ x: 5, y: 10 }; let float_point = Point{ x: 1.0, y: 1.0 }; } // Enums also enum MyResult<T, E> { Ok(T), Err(E) } // The methods in impls of a...
code_fim
medium
{ "lang": "rust", "repo": "brianduff/learnrust", "path": "/generics/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: brianduff/learnrust path: /generics/src/main.rs fn main() { test_generic_struct(); } // A generic function that takes a reference to an array of T and returns a T fn largest<T>(list: &[T]) -> T { let mut largest = list[0]; for &item in list.iter() { // This doesn't compile...
code_fim
hard
{ "lang": "rust", "repo": "brianduff/learnrust", "path": "/generics/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self: Pin<&mut Self>, ctx: &mut task::Context, buf: &mut [u8], ) -> Poll<Result<usize, io::Error>> { match Pin::new(&mut self.get_mut().stream).poll_read(ctx, buf) { Poll::Ready(Ok(read)) if read == 0 => Poll::Pending, polled => polled, }...
code_fim
hard
{ "lang": "rust", "repo": "aktoro-rs/aktoro", "path": "/aktoro-runtime/src/tcp.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Pin::new(&mut self.get_mut().stream).poll_close(ctx) } } impl AsyncRead for TcpStream { fn poll_read( self: Pin<&mut Self>, ctx: &mut task::Context, buf: &mut [u8], ) -> Poll<Result<usize, io::Error>> { match Pin::new(&mut self.get_mut().stream).poll_re...
code_fim
hard
{ "lang": "rust", "repo": "aktoro-rs/aktoro", "path": "/aktoro-runtime/src/tcp.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aktoro-rs/aktoro path: /aktoro-runtime/src/tcp.rs use std::future::Future; use std::net::SocketAddr; use std::net::ToSocketAddrs; use std::pin::Pin; use std::task; use std::task::Poll; use aktoro_raw as raw; use futures_core::Stream; use futures_io as io; use futures_io::AsyncRead; use futures_...
code_fim
hard
{ "lang": "rust", "repo": "aktoro-rs/aktoro", "path": "/aktoro-runtime/src/tcp.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hawnzug/gmachine path: /src/parser.rs use ast::*; use lexer; use token::*; use std::path::Path; use std::fmt; use std::error; use std::result; use std::mem; struct Parser { tokens: Vec<TokenAndPos>, curr_index: usize, curr_token: Option<Token>, } pub type Result<T> = result::Resul...
code_fim
hard
{ "lang": "rust", "repo": "hawnzug/gmachine", "path": "/src/parser.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn is_binop_and_ge(&self, min: u8) -> bool { match self.curr_token { Some(Token::BinOp(binop)) => get_precedence(binop) >= min, _ => false, } } } fn get_precedence(binop: BinOpToken) -> u8 { match binop { BinOpToken::Lt | BinOpToken::Le | BinOpT...
code_fim
hard
{ "lang": "rust", "repo": "hawnzug/gmachine", "path": "/src/parser.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match self.curr_token { Some(Token::BinOp(binop)) => binop, _ => unreachable!(), } } fn is_binop_and_ge(&self, min: u8) -> bool { match self.curr_token { Some(Token::BinOp(binop)) => get_precedence(binop) >= min, _ => false, ...
code_fim
hard
{ "lang": "rust", "repo": "hawnzug/gmachine", "path": "/src/parser.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if let Err(e) = dup2(fd, 2) { println!("Failed duplicating the console fd to stderr, {}", e); std::process::exit(1); } if fd > 2 { if let Err(e) = close(fd) { println!("Failed closing the console fd, {}", e); } } println!("Hello linux!"); }...
code_fim
hard
{ "lang": "rust", "repo": "tontinton/krab", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tontinton/krab path: /src/main.rs extern crate tokio; use nix::unistd::{getpid, setsid, dup2, close}; use nix::fcntl::{open, OFlag}; use nix::sys::stat::{Mode}; #[tokio::main] async fn main() { let pid = getpid(); <|fim_suffix|> if let Err(e) = dup2(fd, 1) { println!("Failed ...
code_fim
hard
{ "lang": "rust", "repo": "tontinton/krab", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if fd > 2 { if let Err(e) = close(fd) { println!("Failed closing the console fd, {}", e); } } println!("Hello linux!"); }<|fim_prefix|>// repo: tontinton/krab path: /src/main.rs extern crate tokio; use nix::unistd::{getpid, setsid, dup2, close}; use nix::fcntl::...
code_fim
hard
{ "lang": "rust", "repo": "tontinton/krab", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: infinity0/rb-prefix-map path: /consume/pecsplit.rs /* TODO: this needs an actual Rust person to review it first. I am a Rust newbie. */ use std::ffi::OsString; use std::path::PathBuf; use std::os::unix::ffi::{OsStrExt, OsStringExt}; // TODO: windows fn pathbuf_to_u8(path: &PathBuf) -> &[u8] { ...
code_fim
hard
{ "lang": "rust", "repo": "infinity0/rb-prefix-map", "path": "/consume/pecsplit.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn decode(prefix_str: Option<OsString>) -> Result<Vec<(PathBuf, PathBuf)>, &'static str> { prefix_str.unwrap_or(OsString::new()) .as_os_str().as_bytes() // TODO: windows .split(|b| *b == b':') .filter(|part| !part.is_empty()) .map(|part| { let tuple = part .split(|b| *b == ...
code_fim
hard
{ "lang": "rust", "repo": "infinity0/rb-prefix-map", "path": "/consume/pecsplit.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>benchmark_group!(benches, bench_generate); benchmark_main!(benches);<|fim_prefix|>// repo: nimiq/core-rs-albatross path: /zkp-primitives/pedersen-generators/benches/generate.rs use bencher::{benchmark_group, benchmark_main, Bencher}; <|fim_middle|>pub fn bench_generate(bench: &mut Bencher) { bench.i...
code_fim
medium
{ "lang": "rust", "repo": "nimiq/core-rs-albatross", "path": "/zkp-primitives/pedersen-generators/benches/generate.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nimiq/core-rs-albatross path: /zkp-primitives/pedersen-generators/benches/generate.rs use bencher::{benchmark_group, benchmark_main, Bencher}; <|fim_suffix|>benchmark_group!(benches, bench_generate); benchmark_main!(benches);<|fim_middle|>pub fn bench_generate(bench: &mut Bencher) { bench.i...
code_fim
medium
{ "lang": "rust", "repo": "nimiq/core-rs-albatross", "path": "/zkp-primitives/pedersen-generators/benches/generate.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// The same as `write_characters`, but wraps the characters in a tag with /// the given name and no attributes. pub fn write_tag_characters<T: std::fmt::Display>( &mut self, tag: &str, value: T, ) -> Result<(), NewEncodeError> { self.write(XmlWriteEvent::st...
code_fim
hard
{ "lang": "rust", "repo": "MisterUncloaked/rbx-dom", "path": "/rbx_xml/src/serializer_core.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MisterUncloaked/rbx-dom path: /rbx_xml/src/serializer_core.rs use std::{fmt::Write as FmtWrite, io::Write}; use xml::writer::{EmitterConfig, EventWriter}; pub use xml::writer::XmlEvent as XmlWriteEvent; use crate::error::{EncodeError as NewEncodeError, EncodeErrorKind}; /// A wrapper around ...
code_fim
hard
{ "lang": "rust", "repo": "MisterUncloaked/rbx-dom", "path": "/rbx_xml/src/serializer_core.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Writes a string slice to the output stream as characters or CDATA. pub fn write_string(&mut self, value: &str) -> Result<(), NewEncodeError> { write_characters_or_cdata(&mut self.inner, value) } /// Writes a value that implements `Display` as characters or CDATA. Resuses /...
code_fim
hard
{ "lang": "rust", "repo": "MisterUncloaked/rbx-dom", "path": "/rbx_xml/src/serializer_core.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: iCodeIN/squarebug path: /src/main.rs use miniquad::*; mod vertices0; mod vertices1; mod vertices2; mod indices0; mod indices1; mod indices2; #[derive(Debug)] #[repr(C)] pub struct Vertex { pub pos: [f32; 2], pub uv: [f32; 2], pub color: [u8; 4], } pub struct Painter { pipelin...
code_fim
hard
{ "lang": "rust", "repo": "iCodeIN/squarebug", "path": "/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // 0-1 linear from 0-255 sRGB vec3 linear_from_srgb(vec3 srgb) { bvec3 cutoff = lessThan(srgb, vec3(10.31475)); vec3 lower = srgb / vec3(3294.6); vec3 higher = pow((srgb + vec3(14.025)) / vec3(269.025), vec3(2.4)); return mix(higher, lower, vec3(cutoff)); } ...
code_fim
hard
{ "lang": "rust", "repo": "iCodeIN/squarebug", "path": "/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Username-Adrian/hyper path: /src/common/str.rs use std::ops::Deref; use std::str; use bytes::Bytes; #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct ByteStr(Bytes); <|fim_suffix|> self.as_str() } } impl<'a> From<&'a str> for ByteStr { fn from(s: &'a str) -> ByteStr { ...
code_fim
hard
{ "lang": "rust", "repo": "Username-Adrian/hyper", "path": "/src/common/str.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[cfg(feature = "compat")] pub fn into_bytes(self) -> Bytes { self.0 } } impl Deref for ByteStr { type Target = str; fn deref(&self) -> &str { self.as_str() } } impl<'a> From<&'a str> for ByteStr { fn from(s: &'a str) -> ByteStr { ByteStr(Bytes::from(s...
code_fim
hard
{ "lang": "rust", "repo": "Username-Adrian/hyper", "path": "/src/common/str.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dalalsunil1986/rust_os path: /src/driver/virtio/virtq.rs use alloc::vec::Vec; use core::mem; use core::ptr; use crate::memory::Page; /// Align upwards to page size pub fn page_align_up(addr: u64) -> u64 { (addr + Page::SIZE - 1) & !(Page::SIZE - 1) } bitflags! { pub struct BufferFlags...
code_fim
hard
{ "lang": "rust", "repo": "dalalsunil1986/rust_os", "path": "/src/driver/virtio/virtq.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let pointer = { unimplemented!("DMA allocator not implmented") // DMA_ALLOCATOR // .lock() // .allocate_blocks((vq_size_bytes / Page::SIZE) as usize) // .expect("Could not allocate DMA buffer for VirtIO") }; V...
code_fim
hard
{ "lang": "rust", "repo": "dalalsunil1986/rust_os", "path": "/src/driver/virtio/virtq.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Set available header pub fn set_available_header(&self, header: AvailableHeader) { unsafe { let p = self .pointer .add(VirtQueue::calc_sizes(self.queue_size).0 as usize); ptr::write_volatile(p as *mut AvailableHeader, header); ...
code_fim
hard
{ "lang": "rust", "repo": "dalalsunil1986/rust_os", "path": "/src/driver/virtio/virtq.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> ) } else { proverb.push_str(format!("And all for the want of a {}.", list[0]).as_str()) } } proverb }<|fim_prefix|>// repo: ralvescosta/rust_exercism path: /proverb/src/lib.rs pub fn build_proverb(list: &[&str]) -> String { let mut proverb = String::new(); ...
code_fim
hard
{ "lang": "rust", "repo": "ralvescosta/rust_exercism", "path": "/proverb/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ralvescosta/rust_exercism path: /proverb/src/lib.rs pub fn build_proverb(list: &[&str]) -> String { let mut proverb = String::new(); for (index, _keyword) in list.into_iter().enumera<|fim_suffix|> ) } else { proverb.push_str(format!("And all for the want of a {}.", ...
code_fim
hard
{ "lang": "rust", "repo": "ralvescosta/rust_exercism", "path": "/proverb/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Tonyce/wasmer-project path: /src/main.rs use wasmer::{imports, Instance, Module, Store, Value}; fn main() -> anyhow::Result<()> { <|fim_suffix|> let store = Store::default(); let module = Module::new(&store, &module_wat)?; // The module doesn't import anything, so we create an empty ...
code_fim
hard
{ "lang": "rust", "repo": "Tonyce/wasmer-project", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }