text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> ::std::borrow::Cow::Borrowed(#gql_typename) } fn create_type_info(registry: &mut #crate_name::registry::Registry) -> ::std::string::String { registry.create_input_type::<#self_ty, _>(|_| #crate_name::registry::MetaType::Scalar { ...
code_fim
hard
{ "lang": "rust", "repo": "villekalliomaki/async-graphql", "path": "/derive/src/scalar.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> print!("barbervisor: {:#x} vbox: {:#x}\n\n", data.rip, vbox.rip); // if data != vbox { if data.rip != vbox.rip { println!("barbervisor:"); data.print(); println!(""); println!("vbox:"); vbox.print(); println!(...
code_fim
hard
{ "lang": "rust", "repo": "fengjixuchui/Barbervisor", "path": "/diverge/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fengjixuchui/Barbervisor path: /diverge/src/main.rs // extern crate regex; use regex::Regex; use std::convert::TryInto; use std::fs::File; use std::io::{Read, BufReader, BufRead}; /// Returns the virtual addresses and the virt to phys tranlations mapping from /// the data of a vbox core file p...
code_fim
hard
{ "lang": "rust", "repo": "fengjixuchui/Barbervisor", "path": "/diverge/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>,所以不需要进行声明。 // 在结构体中的使用方式也类似就不再次举例了。 fn max_num(x: &'static i32, y: &'static i32) -> &'static i32 { if x > y { &x } else { &y } }<|fim_prefix|>// repo: liweilijie/rust path: /basic/lifetime/src/static_lifetime.rs pub fn static_lifetime_default() { // 所有的字符串字面值都是 'static 生命...
code_fim
medium
{ "lang": "rust", "repo": "liweilijie/rust", "path": "/basic/lifetime/src/static_lifetime.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: liweilijie/rust path: /basic/lifetime/src/static_lifetime.rs pub fn static_lifetime_default() { // 所有的字符串字面值都是 'static 生命周期,例如: let s: &'static str = "codercat is a static lifetime."; // 上面代码中的生命周期参数可以省略,就变成如下形式: let s: &str = "codercat is a static lifetime."; // 还有static变量的生...
code_fim
medium
{ "lang": "rust", "repo": "liweilijie/rust", "path": "/basic/lifetime/src/static_lifetime.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for f in ar::Reader::new(&contents).expect("valid archive header") { println!("{} {} {} {} {} {}", f.name().expect("valid utf8"), f.contents().len(), f.modified_timestamp(), f.owner_id(), f.group_id(), f.file_mode()); } }<|fim_prefix|>// repo: joshuawarner32/rust-ar path: /examples/list_f...
code_fim
hard
{ "lang": "rust", "repo": "joshuawarner32/rust-ar", "path": "/examples/list_files.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: joshuawarner32/rust-ar path: /examples/list_files.rs extern crate ar; use std::env; use std::fs::File; use std::io::Read; fn main() { <|fim_suffix|> let mut contents = Vec::new(); File::open(&args[1]).expect("readable file").read_to_end(&mut contents).expect("read succeeds"); for f...
code_fim
medium
{ "lang": "rust", "repo": "joshuawarner32/rust-ar", "path": "/examples/list_files.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> /// Returns the name of the column at the specified index. fn fieldname(&self, field_idx: usize) -> Option<&str>; /// A _provided method_ that translates a resultset into a given rust type /// that implements `serde::de::Deserialize`. /// /// The type of the target variable needs ...
code_fim
hard
{ "lang": "rust", "repo": "windoze/rust-serde_db", "path": "/src/de/deserializable_resultset.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// A _provided method_ that translates a resultset into a given rust type /// that implements `serde::de::Deserialize`. /// /// The type of the target variable needs to be specified explicitly, so that /// `into_typed()` can derive the type it needs to serialize into: /// /// ...
code_fim
hard
{ "lang": "rust", "repo": "windoze/rust-serde_db", "path": "/src/de/deserializable_resultset.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: windoze/rust-serde_db path: /src/de/deserializable_resultset.rs use crate::de::rs_deserializer::RsDeserializer; use crate::de::{DeserializableRow, DeserializationError, DeserializationResult}; use std::marker::Sized; /// Interface for a database resultset to support deserialization. pub trait D...
code_fim
hard
{ "lang": "rust", "repo": "windoze/rust-serde_db", "path": "/src/de/deserializable_resultset.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> e } /// Remove `val` from the tumbler. Returns whether it was removed. pub fn remove(&mut self, val: &T) -> bool { // NOTE(invariant): if present in any ring, val is equivalent in all rings. let mut entry = false; for ring in 0..self.rings.len() { l...
code_fim
hard
{ "lang": "rust", "repo": "hellertime/blip", "path": "/src/collections/tumbler.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hellertime/blip path: /src/collections/tumbler.rs // Copyright 2020 nytopop (Eric Izoita) // // Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or // http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or // http://opensource.org/licenses/MIT>, at your option....
code_fim
hard
{ "lang": "rust", "repo": "hellertime/blip", "path": "/src/collections/tumbler.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Returns an iterator over every trailing edge of `e`, across all rings. /// /// ```text /// where e: 3 /// | /// [ 0, 4, 3, 1, 2, 5 ] ring: 0 /// [ 0, 2, 1, 5, 3, 4 ] ring: 1 /// [ 1, 0, 3, 4, 5, 2 ] ring: 2 /// [ ...
code_fim
hard
{ "lang": "rust", "repo": "hellertime/blip", "path": "/src/collections/tumbler.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ywzjackal/soapysdr.rs path: /src/kwargs.rs use std; use super::error::*; use super::sys; pub struct Kwargs { pub(crate) inner: sys::SoapySDRKwargs, } pub struct KwargsList<'a> { pub(crate) inner: &'a[sys::SoapySDRKwargs], } impl Kwargs { pub fn empty() -> Self { Kwargs { inner...
code_fim
hard
{ "lang": "rust", "repo": "ywzjackal/soapysdr.rs", "path": "/src/kwargs.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Kwargs{inner} } } impl <'a>From<(usize, *mut sys::SoapySDRKwargs)> for KwargsList<'a> { fn from((length, inner): (usize, *mut sys::SoapySDRKwargs)) -> KwargsList<'a> { use libc; let rt = KwargsList { inner: unsafe { std::slice::from_raw_parts(inner, length) } }; unsafe { lib...
code_fim
hard
{ "lang": "rust", "repo": "ywzjackal/soapysdr.rs", "path": "/src/kwargs.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn with_role(id: impl ToString, token: impl ToString, role: UserRole) -> Self { Self { id: id.to_string(), token: token.to_string(), role, } } }<|fim_prefix|>// repo: apache/incubator-teaclave path: /rpc/src/interceptor.rs // Licensed to the...
code_fim
hard
{ "lang": "rust", "repo": "apache/incubator-teaclave", "path": "/rpc/src/interceptor.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: apache/incubator-teaclave path: /rpc/src/interceptor.rs // Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this ...
code_fim
hard
{ "lang": "rust", "repo": "apache/incubator-teaclave", "path": "/rpc/src/interceptor.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ttencate/rustyknife path: /rustyknife/src/decoder.rs 0x09 => Instruction::RemoveObj(operand), 0x0a => Instruction::PrintObj(operand), 0x0b => Instruction::Ret(operand), 0x0c => Instruction::Jump(operand), ...
code_fim
hard
{ "lang": "rust", "repo": "ttencate/rustyknife", "path": "/rustyknife/src/decoder.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ttencate/rustyknife path: /rustyknife/src/decoder.rs (&operand_types)?; match opcode_number { 0x01 => Instruction::Je(var_operands, self.read_branch()?), 0x02 => Instruction::Jl(var_operands, self.read_branch()?), 0x03 =...
code_fim
hard
{ "lang": "rust", "repo": "ttencate/rustyknife", "path": "/rustyknife/src/decoder.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> fn next_u8(&mut self) -> Result<u8, RuntimeError> { let b = self.mem.bytes().get_u8(self.next_addr) .or(Err(RuntimeError::ProgramCounterOutOfRange(self.loc())))?; self.next_addr += 1; Ok(b) } fn next_u16(&mut self) -> Result<u16, RuntimeError> { let...
code_fim
hard
{ "lang": "rust", "repo": "ttencate/rustyknife", "path": "/rustyknife/src/decoder.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sicspe/polars path: /polars/src/lazy/logical_plan/optimizer/simplify_expr.rs use crate::lazy::prelude::*; use crate::prelude::*; pub struct SimplifyExpr {} // Evaluates x + y if possible fn eval_plus(left: &Expr, right: &Expr) -> Option<Expr> { match (left, right) { (Expr::Literal(...
code_fim
hard
{ "lang": "rust", "repo": "sicspe/polars", "path": "/polars/src/lazy/logical_plan/optimizer/simplify_expr.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match expr { BinaryExpr { left, right, .. } => { exprs.push(&mut *left); exprs.push(&mut *right); } Alias(expr, ..) => { exprs.pus...
code_fim
hard
{ "lang": "rust", "repo": "sicspe/polars", "path": "/polars/src/lazy/logical_plan/optimizer/simplify_expr.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut changed = true; // run loop until reaching fixed point while changed { // recurse into sub plans and expressions and apply rules changed = false; let mut plans = vec![&mut *logical_plan]; let mut exprs = vec![]; ...
code_fim
hard
{ "lang": "rust", "repo": "sicspe/polars", "path": "/polars/src/lazy/logical_plan/optimizer/simplify_expr.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> use std::fs; use std::io; use std::path::PathBuf; /// create and delete a temp file to get a tmp location. fn tmp_path() -> PathBuf { NamedTempFile::new().unwrap().into_temp_path().to_owned() } #[test] fn smoke() { let path = tmp_path(); let lockfi...
code_fim
hard
{ "lang": "rust", "repo": "derekdreery/lockfile-rs", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: derekdreery/lockfile-rs path: /src/lib.rs //! This crate provides a lockfile struct that marks a location in the filesystem as locked. //! //! A lock is conceptually created when the file is created, and released when it is deleted. //! //! If the file is already present, the `create` function w...
code_fim
hard
{ "lang": "rust", "repo": "derekdreery/lockfile-rs", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ogrisel/tract path: /core/src/ops/nn/maxpool.rs use crate::ops::prelude::*; use ndarray::prelude::*; use super::{DataFormat, PaddingSpec, Patch}; #[derive(Debug, Clone, new, Default)] pub struct MaxPool { data_fmt: DataFormat, kernel_shape: TVec<usize>, padding: PaddingSpec, st...
code_fim
hard
{ "lang": "rust", "repo": "ogrisel/tract", "path": "/core/src/ops/nn/maxpool.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl InferenceRulesOp for MaxPool { fn rules<'r, 'p: 'r, 's: 'r>( &'s self, s: &mut Solver<'r>, inputs: &'p SharedTensorsProxy, outputs: &'p SharedTensorsProxy, ) -> InferenceResult { s.equals(&outputs.len, self.noutputs() as i32)?; s.equals(&outputs...
code_fim
hard
{ "lang": "rust", "repo": "ogrisel/tract", "path": "/core/src/ops/nn/maxpool.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// A service that may be orchestratable. /// /// This service has several stronger requirements, mainly required moving and sharing a service /// instance among threads. pub trait OrchestratableService: ServiceInstance { fn clone_box(&self) -> Box<dyn OrchestratableService>; fn as_service(&self)...
code_fim
medium
{ "lang": "rust", "repo": "Cargill/splinter", "path": "/libsplinter/src/service/instance/orchestrator/service.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn as_service(&self) -> &dyn ServiceInstance; } impl Clone for Box<dyn OrchestratableService> { fn clone(&self) -> Self { self.clone_box() } }<|fim_prefix|>// repo: Cargill/splinter path: /libsplinter/src/service/instance/orchestrator/service.rs // Copyright 2018-2022 Cargill Incorp...
code_fim
hard
{ "lang": "rust", "repo": "Cargill/splinter", "path": "/libsplinter/src/service/instance/orchestrator/service.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Cargill/splinter path: /libsplinter/src/service/instance/orchestrator/service.rs // Copyright 2018-2022 Cargill Incorporated // // 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 L...
code_fim
hard
{ "lang": "rust", "repo": "Cargill/splinter", "path": "/libsplinter/src/service/instance/orchestrator/service.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>unsafe impl SdaPin<I2C1> for PA10<AF1> {} unsafe impl SdaPin<I2C1> for PA13<AF3> {} unsafe impl SdaPin<I2C1> for PB7<AF1> {}<|fim_prefix|>// repo: thenewwazoo/stm32l0x1-hal path: /src/i2c/stm32l011x3_4.rs use crate::i2c::SclPin; use crate::i2c::SdaPin; <|fim_middle|>use crate::gpio::AF::{AF1, AF3, AF4};...
code_fim
hard
{ "lang": "rust", "repo": "thenewwazoo/stm32l0x1-hal", "path": "/src/i2c/stm32l011x3_4.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>unsafe impl SclPin<I2C1> for PA4<AF3> {} unsafe impl SclPin<I2C1> for PA9<AF1> {} unsafe impl SclPin<I2C1> for PB6<AF1> {} unsafe impl SclPin<I2C1> for PB8<AF4> {} unsafe impl SdaPin<I2C1> for PA10<AF1> {} unsafe impl SdaPin<I2C1> for PA13<AF3> {} unsafe impl SdaPin<I2C1> for PB7<AF1> {}<|fim_prefix|>// ...
code_fim
medium
{ "lang": "rust", "repo": "thenewwazoo/stm32l0x1-hal", "path": "/src/i2c/stm32l011x3_4.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: thenewwazoo/stm32l0x1-hal path: /src/i2c/stm32l011x3_4.rs use crate::i2c::SclPin; use crate::i2c::SdaPin; <|fim_suffix|>unsafe impl SclPin<I2C1> for PA4<AF3> {} unsafe impl SclPin<I2C1> for PA9<AF1> {} unsafe impl SclPin<I2C1> for PB6<AF1> {} unsafe impl SclPin<I2C1> for PB8<AF4> {} unsafe imp...
code_fim
medium
{ "lang": "rust", "repo": "thenewwazoo/stm32l0x1-hal", "path": "/src/i2c/stm32l011x3_4.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: swc-project/swc path: /crates/swc_ecma_minifier/src/compress/util/tests.rs use swc_common::{util::take::Take, FileName, Mark, SyntaxContext}; use swc_ecma_ast::*; use swc_ecma_parser::parse_file_as_expr; use swc_ecma_transforms_base::fixer::fixer; use swc_ecma_utils::ExprCtx; use swc_ecma_visit:...
code_fim
hard
{ "lang": "rust", "repo": "swc-project/swc", "path": "/crates/swc_ecma_minifier/src/compress/util/tests.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn negate_cost_6_2() { assert_negate_cost( " !((list = config.blacklist) && list.some(function(item) { return Object.keys(item).every(function(key) { return item[key] === codeResult2[key]; }); }))", true, false, ...
code_fim
hard
{ "lang": "rust", "repo": "swc-project/swc", "path": "/crates/swc_ecma_minifier/src/compress/util/tests.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> assert_negate_cost( " !((list = config.blacklist) && list.some(function(item) { return Object.keys(item).every(function(key) { return item[key] === codeResult2[key]; }); }))", true, false, -1, ); } #[test] #[i...
code_fim
hard
{ "lang": "rust", "repo": "swc-project/swc", "path": "/crates/swc_ecma_minifier/src/compress/util/tests.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> let get_hand_position_for_ms = |milliseconds_since_start: i32| -> f32 { C::StrokeTimer::hand_position(&settings, milliseconds_since_start) }; for _ in 0..10 { C::StrokeVisualizer::draw(get_hand_position_for_ms); } dbg!(C::StrokeVisualizer::make_svg()); }<|fim_prefix|>//...
code_fim
hard
{ "lang": "rust", "repo": "syncjack/syncjack", "path": "/src/impure/hub.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: syncjack/syncjack path: /src/impure/hub.rs use crate::impure::stroke_visualizer::StrokeVisualizerTrait; use crate::impure::websocket_adaptor::WebSocketAdaptorTrait; use crate::pure::message_handler::MessageHandlerTrait; use crate::pure::models::DEFAULT_PATTERN; use crate::pure::models::Message; ...
code_fim
hard
{ "lang": "rust", "repo": "syncjack/syncjack", "path": "/src/impure/hub.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>let adapter = MongoAdapter::new(/* config what makes sense ONLY for Mongo */) fn some_fn<A: SaveData>(adapter: SaveData) { .. } //! BUT [GIST] it's should be USE-CASE ORIENTED .. SO .. //! -== Traits help us don't write specific fns for every type .. //! .. WHEN those fns do exactly the same -==...
code_fim
hard
{ "lang": "rust", "repo": "olehdevua/text", "path": "/journal_arch.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: olehdevua/text path: /journal_arch.rs // I think data data-mapping(ala ORM) will be usefull in my "journal" // .. BUT .. not "general purpose" - because of it's "leak abstraction" (like // many people don't like Waterline(from Sails.js)) .. SO .. my "ORM" will be // my-app-specific, it's like in...
code_fim
hard
{ "lang": "rust", "repo": "olehdevua/text", "path": "/journal_arch.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>// NOTE: since in JS we have not Traits, we just use Duck-typing .. good exmp of that is // implementation of Node's in - "Immutable.js"<|fim_prefix|>// repo: olehdevua/text path: /journal_arch.rs // I think data data-mapping(ala ORM) will be usefull in my "journal" // .. BUT .. not "general purpose" - b...
code_fim
medium
{ "lang": "rust", "repo": "olehdevua/text", "path": "/journal_arch.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> second . poll_next ( cx ) } fn size_hint ( & self ) - > ( usize Option < usize > ) { if let Some ( first ) = & self . first { let ( first_lower first_upper ) = first . size_hint ( ) ; let ( second_lower second_upper ) = self . second . size_hint ( ) ; let lower = first_lower . saturating_add ( second_low...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/futures-util/src/stream/stream/chain.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>mpl < St1 St2 > Stream for Chain < St1 St2 > where St1 : Stream St2 : Stream < Item = St1 : : Item > { type Item = St1 : : Item ; fn poll_next ( self : Pin < & mut Self > cx : & mut Context < ' _ > ) - > Poll < Option < Self : : Item > > { let mut this = self . project ( ) ; if let Some ( first ) = this ....
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/futures-util/src/stream/stream/chain.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/futures-util/src/stream/stream/chain.rs use core : : pin : : Pin ; use futures_core : : ready ; use futures_core : : stream : : { FusedStream Stream } ; use futures_core : : task : : { Context Poll } ; use pin_project_lite : : pin_project ; pin...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/futures-util/src/stream/stream/chain.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: usmanzaheer1995/piaic-assignments path: /2/q1/src/main.rs fn main() { // let num1 = 4; // let num2 = 2; // println!("Addition: {}", num1 + num2); // println!("Subtraction: {}", num1 - num2); // println!("Multiplication: {}", num1 * num2); // println!("Division: {}", num1...
code_fim
medium
{ "lang": "rust", "repo": "usmanzaheer1995/piaic-assignments", "path": "/2/q1/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let decimal: u8 = 55; println!("Decimal: {}", decimal); println!("It's binary is: {:b}", decimal); println!("It's octal is: {:o}", decimal); println!("It's hexadecimal is: {:X}", decimal); let byte: u8 = b'A'; println!("Decimal: {}", byte); println!("Binary: {:b}", byte); ...
code_fim
medium
{ "lang": "rust", "repo": "usmanzaheer1995/piaic-assignments", "path": "/2/q1/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> try_w!(func.indented_line(), "try!(write!(writer, \"{{}}\", val));"); try_w!(func, "}}"); }, Some((_, Some((_ty, _)))) => { return Err...
code_fim
hard
{ "lang": "rust", "repo": "Ogeon/symbiosis", "path": "/src/rust/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Ogeon/symbiosis path: /src/rust/mod.rs }; mod types; macro_rules! try_w_s { ($w: expr, $fmt: tt, $($arg: expr),*) => (try_w!($w, $fmt, $(Sanitized($arg)),*)) } #[derive(Debug)] pub enum Error { UnknownType(String), UndefinedPlaceholder(String), CannotBeRendered(String), Un...
code_fim
hard
{ "lang": "rust", "repo": "Ogeon/symbiosis", "path": "/src/rust/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> try_w!(w, "}}"); w.unindent(); write!(w, "}}").map_err(|e| e.into()) } fn build_module<W, F>(&self, w: &mut Writer<W>, build_templates: F) -> Result<(), Error> where W: Write, F: FnOnce(&mut Writer<W>) -> Result<(), Error> { if let Some((ref mo...
code_fim
hard
{ "lang": "rust", "repo": "Ogeon/symbiosis", "path": "/src/rust/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: azriel91/autexousious path: /crate/input_reaction_loading/src/irs_loader.rs use std::{convert::AsRef, default::Default, marker::PhantomData}; use amethyst::assets::{AssetStorage, Loader}; use game_input_model::config::{Axis, ControlAction}; use input_reaction_model::{ config::{ self...
code_fim
hard
{ "lang": "rust", "repo": "azriel91/autexousious", "path": "/crate/input_reaction_loading/src/irs_loader.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Device button press. Self::push_button_reactions( input_reactions_default, input_reactions_sequence, input_reactions_frame, sequence_id_mappings, &mut input_reactions_loaded, ); let input_reactions = InputReact...
code_fim
hard
{ "lang": "rust", "repo": "azriel91/autexousious", "path": "/crate/input_reaction_loading/src/irs_loader.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub trait Sensor { type Data; fn init(&mut self); fn get_value(&mut self) -> Self::Data; fn shutdown(&mut self); }<|fim_prefix|>// repo: BBScholar/hwctrl-rs path: /src/hardware_traits.rs #[derive(Eq, PartialEq, Ord, PartialOrd, Debug)] pub struct HardwareId(u32); pub trait PeriodicUpdate...
code_fim
medium
{ "lang": "rust", "repo": "BBScholar/hwctrl-rs", "path": "/src/hardware_traits.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: BBScholar/hwctrl-rs path: /src/hardware_traits.rs #[derive(Eq, PartialEq, Ord, PartialOrd, Debug)] pub struct HardwareId(u32); pub trait PeriodicUpdate { fn update(&mut self); } pub trait CanEnabled { fn can_callback(&mut self); fn can_id(&self) -> u32; } pub trait SpiEnabled { ...
code_fim
hard
{ "lang": "rust", "repo": "BBScholar/hwctrl-rs", "path": "/src/hardware_traits.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub trait Motor { type Setpoint; fn init(&mut self); fn set(&mut self, setpoint: Self::Setpoint); fn stop(&mut self); } pub trait Calibrate { fn calibrate(&mut self); } pub trait Sensor { type Data; fn init(&mut self); fn get_value(&mut self) -> Self::Data; fn shutdow...
code_fim
hard
{ "lang": "rust", "repo": "BBScholar/hwctrl-rs", "path": "/src/hardware_traits.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug, Deserialize)] pub struct Card { pub id: String, pub address_city: Option<String>, pub address_country: Option<String>, pub address_line1: Option<String>, pub address_line1_check: Option<String>, pub address_line2: Option<String>, pub address_state: Option<String...
code_fim
hard
{ "lang": "rust", "repo": "spotlease/stripe-rust", "path": "/src/models/card.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: spotlease/stripe-rust path: /src/models/card.rs use serde::{Deserialize, Serialize}; use super::Metadata; #[derive(Debug, Default, Serialize)] pub struct CardCreateParams<'a> { pub number: &'a str, pub exp_month: u32, pub exp_year: u32, #[serde(skip_serializing_if = "Option::is_...
code_fim
hard
{ "lang": "rust", "repo": "spotlease/stripe-rust", "path": "/src/models/card.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl<C> JwtHandler<C> where C: DeserializeOwned + Sync + Send + 'static, { pub fn new(config: JwtConfig<C>) -> JwtHandler<C> { JwtHandler { config } } pub fn decode(&self, token: &str) -> Result<TokenData<C>, JwtError> { decode::<C>( &token, &Decodin...
code_fim
hard
{ "lang": "rust", "repo": "yingheio/salvo", "path": "/extra/src/jwt_auth/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yingheio/salvo path: /extra/src/jwt_auth/mod.rs use async_trait::async_trait; pub use jsonwebtoken::errors::Error as JwtError; pub use jsonwebtoken::{decode, Algorithm, DecodingKey, TokenData, Validation}; use serde::de::DeserializeOwned; use std::marker::PhantomData; use salvo_core::http::erro...
code_fim
hard
{ "lang": "rust", "repo": "yingheio/salvo", "path": "/extra/src/jwt_auth/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub struct FormExtractor(String); impl FormExtractor { pub fn new<T: Into<String>>(name: T) -> Self { FormExtractor(name.into()) } } #[async_trait] impl JwtExtractor for FormExtractor { async fn get_token(&self, req: &mut Request) -> Option<String> { req.get_form(&self.0).await...
code_fim
hard
{ "lang": "rust", "repo": "yingheio/salvo", "path": "/extra/src/jwt_auth/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: exercism/rust path: /exercises/practice/luhn/.meta/example.rs pub fn is_valid(candidate: &str) -> bool { if candidate.chars().filter(|c| c.is_digit(10)).take(2).count() <= 1 || c<|fim_suffix|>filter_map(|c| c.to_digit(10)) .rev() .enumerate() .map(|(index, dig...
code_fim
medium
{ "lang": "rust", "repo": "exercism/rust", "path": "/exercises/practice/luhn/.meta/example.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> { digit * 2 }) .map(|digit| if digit > 9 { digit - 9 } else { digit }) .sum::<u32>() % 10 == 0 }<|fim_prefix|>// repo: exercism/rust path: /exercises/practice/luhn/.meta/example.rs pub fn is_valid(candidate: &str) -> bool { if candidate.chars().filter(|c| c.is_digit(1...
code_fim
medium
{ "lang": "rust", "repo": "exercism/rust", "path": "/exercises/practice/luhn/.meta/example.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: andoriyu/material-design-icons-rs path: /src/materialiconsround/places/icon_houseboat.rs pub struct IconHouseboat { props: crate::Props, } impl yew::Component for IconHouseboat { type Properties = crate::Props; type Message = (); fn create(props: Self::Properties, _: yew::prelude::...
code_fim
medium
{ "lang": "rust", "repo": "andoriyu/material-design-icons-rs", "path": "/src/materialiconsround/places/icon_houseboat.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jeandudey/cc13x2-rs path: /src/aux_tdc/ctl.rs #[doc = "Reader of register CTL"] pub type R = crate::R<u32, super::CTL>; #[doc = "Writer for register CTL"] pub type W = crate::W<u32, super::CTL>; #[doc = "Register CTL `reset()`'s with value 0"] impl crate::ResetValue for super::CTL { type Typ...
code_fim
hard
{ "lang": "rust", "repo": "jeandudey/cc13x2-rs", "path": "/src/aux_tdc/ctl.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>:RUN_SYNC_START) } #[doc = "Clear STAT.SAT, STAT.DONE, and RESULT.VALUE. This is not needed as prerequisite for a measurement. Reliable clear is only guaranteed from IDLE state."] #[inline(always)] pub fn clr_result(self) -> &'a mut W { self.variant(CMD_A::CLR_RESULT) } #[d...
code_fim
hard
{ "lang": "rust", "repo": "jeandudey/cc13x2-rs", "path": "/src/aux_tdc/ctl.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sile/stun_codec path: /src/rfc5389/mod.rs //! [RFC 5389(STUN)][RFC 5389] specific components. //! //! [RFC 5389]: https://tools.ietf.org/html/rfc5389 use self::attributes::*; <|fim_suffix|>define_attribute_enums!( Attribute, AttributeDecoder, AttributeEncoder, [ MappedAd...
code_fim
medium
{ "lang": "rust", "repo": "sile/stun_codec", "path": "/src/rfc5389/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>define_attribute_enums!( Attribute, AttributeDecoder, AttributeEncoder, [ MappedAddress, Username, MessageIntegrity, ErrorCode, UnknownAttributes, Realm, Nonce, XorMappedAddress, XorMappedAddress2, Software, ...
code_fim
medium
{ "lang": "rust", "repo": "sile/stun_codec", "path": "/src/rfc5389/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: makers-for-life/makair-control-ui path: /src/locale/preset.rs // MakAir Control UI // // Copyright: 2021, Makers For Life // License: Public Domain License <|fim_suffix|>pub fn age_to_locale(age: &SettingsPresetAge) -> String { let locale_key = match age { SettingsPresetAge::Child =...
code_fim
hard
{ "lang": "rust", "repo": "makers-for-life/makair-control-ui", "path": "/src/locale/preset.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|>use crate::APP_I18N; pub fn gender_to_locale(gender: &SettingsPresetGender) -> String { let locale_key = match gender { SettingsPresetGender::Male => "male", SettingsPresetGender::Female => "female", }; APP_I18N.t(&format!("modal-preset-gender-{}", locale_key)) } pub fn age_...
code_fim
medium
{ "lang": "rust", "repo": "makers-for-life/makair-control-ui", "path": "/src/locale/preset.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> pub fn get_slice(&self) -> Vec<T> { self.buf[self.start..self.current].to_vec() } pub fn commit(&mut self) { self.start = self.current; } }<|fim_prefix|>// repo: jhamill34/notion-formula-parser path: /lookahead_buffer/src/lib.rs pub struct LookaheadBuffer<T: Clone> { ...
code_fim
hard
{ "lang": "rust", "repo": "jhamill34/notion-formula-parser", "path": "/lookahead_buffer/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jhamill34/notion-formula-parser path: /lookahead_buffer/src/lib.rs pub struct LookaheadBuffer<T: Clone> { buf: Vec<T>, start: usize, current: usize, } impl<T: Clone> LookaheadBuffer<T> { pub fn new(buffer: Vec<T>) -> Self { LookaheadBuffer { buf: buffer, ...
code_fim
medium
{ "lang": "rust", "repo": "jhamill34/notion-formula-parser", "path": "/lookahead_buffer/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.current = self.current + 1; } pub fn get_slice(&self) -> Vec<T> { self.buf[self.start..self.current].to_vec() } pub fn commit(&mut self) { self.start = self.current; } }<|fim_prefix|>// repo: jhamill34/notion-formula-parser path: /lookahead_buffer/src/li...
code_fim
medium
{ "lang": "rust", "repo": "jhamill34/notion-formula-parser", "path": "/lookahead_buffer/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: saritag2020/rules_rust path: /examples/per_platform_printer/lib.rs mod print_generic; #[cfg(target_os = "linux")] mod print_linux; #[cfg(target_os = "macos")] mod print_osx; pub fn print() -> Vec<String> { let mut outs = vec![print_generic::print()]; #[cfg(target_os = "linux")] o...
code_fim
medium
{ "lang": "rust", "repo": "saritag2020/rules_rust", "path": "/examples/per_platform_printer/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!( outs, vec![ "Hello Generic!", #[cfg(target_os = "linux")] "Hello Linux!", #[cfg(target_os = "macos")] "Hello OSX!", ] ); } }<|fim_prefix|>// repo: saritag2020...
code_fim
hard
{ "lang": "rust", "repo": "saritag2020/rules_rust", "path": "/examples/per_platform_printer/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> for line in lines { let parsed_input = line .unwrap() .split_whitespace() .map(str::parse::<f32>) .filter_map(std::result::Result::ok) .collect::<Vec<f32>>(); let beats = parsed_input[0]; let time = parsed_input[1]; ...
code_fim
hard
{ "lang": "rust", "repo": "lancelafontaine/coding-challenges", "path": "/kattis/heartrate/rust/heartrate/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lancelafontaine/coding-challenges path: /kattis/heartrate/rust/heartrate/src/main.rs use std::io::{self, BufRead, Write}; type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>; fn main() -> Result<()> { <|fim_suffix|> let mut lines = stdin_handle.lines(); let _ = lines.nex...
code_fim
medium
{ "lang": "rust", "repo": "lancelafontaine/coding-challenges", "path": "/kattis/heartrate/rust/heartrate/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #( #ensure_method_name::<#field_types>(); )* #extra } } }<|fim_prefix|>// repo: rust-secure-code/mem-markers path: /crates/macros/src/utils.rs use proc_macro2::{Ident, TokenStream}; use quote::quote; /// Get the types of all fields of a str...
code_fim
hard
{ "lang": "rust", "repo": "rust-secure-code/mem-markers", "path": "/crates/macros/src/utils.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-secure-code/mem-markers path: /crates/macros/src/utils.rs use proc_macro2::{Ident, TokenStream}; use quote::quote; /// Get the types of all fields of a struct pub(crate) fn struct_field_types(s: &syn::DataStruct) -> Vec<&syn::Type> { match &s.fields { syn::Fields::Named(n) => n...
code_fim
hard
{ "lang": "rust", "repo": "rust-secure-code/mem-markers", "path": "/crates/macros/src/utils.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: winksaville/fuchsia path: /garnet/public/rust/fuchsia-vfs/pseudo-fs/src/file/mod.rs // Copyright 2019 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. <|fim_suffix|>/// POSIX emulation layer access ...
code_fim
hard
{ "lang": "rust", "repo": "winksaville/fuchsia", "path": "/garnet/public/rust/fuchsia-vfs/pseudo-fs/src/file/mod.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>/// POSIX emulation layer access attributes set by default for files created with read_only(). pub const DEFAULT_READ_ONLY_PROTECTION_ATTRIBUTES: u32 = S_IRUSR; /// POSIX emulation layer access attributes set by default for files created with write_only(). pub const DEFAULT_WRITE_ONLY_PROTECTION_ATTRIBUT...
code_fim
hard
{ "lang": "rust", "repo": "winksaville/fuchsia", "path": "/garnet/public/rust/fuchsia-vfs/pseudo-fs/src/file/mod.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stefansundin/hax path: /projecteuler.net/p022.rs // Using names.txt (right click and 'Save Link/Target As...'), a 46K text file containing over five-thousand first names, begin by sorting it into alphabetical order. Then working out the alphabetical value for each name, multiply this value by it...
code_fim
hard
{ "lang": "rust", "repo": "stefansundin/hax", "path": "/projecteuler.net/p022.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: martingallagher/minibot-rust path: /crates/server/src/net/ws.rs use futures::prelude::*; use gotham::{ hyper::{ self, header::{HeaderValue, CONNECTION, SEC_WEBSOCKET_ACCEPT, SEC_WEBSOCKET_KEY, UPGRADE}, upgrade::Upgraded, Body, HeaderMap, Response, StatusCode,...
code_fim
hard
{ "lang": "rust", "repo": "martingallagher/minibot-rust", "path": "/crates/server/src/net/ws.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> const WS_GUID: &[u8] = b"258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; let mut sha1 = Sha1::default(); sha1.update(key); sha1.update(WS_GUID); base64::encode(&sha1.digest().bytes()) } pub fn upgrade_required_response() -> Response<Body> { Response::builder() .header(UPGRADE, PROT...
code_fim
medium
{ "lang": "rust", "repo": "martingallagher/minibot-rust", "path": "/crates/server/src/net/ws.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(get_previous(&vec![1,2,3,4,5], 4, 3), vec![2,3,4]); } #[test] fn test_previous_adds_to_current() { assert_eq!(previous_add_to_current(&vec![1,2,3,4,5], 4, 3), true); assert_eq!(previous_add_to_current(&vec![1,2,3,4,5], 4, 2), false); } fn sample_input() -> Vec<String> { ...
code_fim
hard
{ "lang": "rust", "repo": "joshatron/AdventOfCode-2020", "path": "/src/days/day_9.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: joshatron/AdventOfCode-2020 path: /src/days/day_9.rs use crate::days::Day; use crate::days; pub struct Day9 {} impl Day9 { pub fn new() -> Day9 { Day9{} } } impl Day for Day9 { fn day_num(&self) -> usize { 9 } fn puzzle_1(&self, input: &Vec<String>) -> String { let nums...
code_fim
hard
{ "lang": "rust", "repo": "joshatron/AdventOfCode-2020", "path": "/src/days/day_9.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_get_previous() { assert_eq!(get_previous(&vec![1,2,3,4,5], 4, 3), vec![2,3,4]); } #[test] fn test_previous_adds_to_current() { assert_eq!(previous_add_to_current(&vec![1,2,3,4,5], 4, 3), true); assert_eq!(previous_add_to_current(&vec![1,2,3,4,5], 4, 2), false); } ...
code_fim
hard
{ "lang": "rust", "repo": "joshatron/AdventOfCode-2020", "path": "/src/days/day_9.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mesalock-linux/crates-sgx path: /vendor/ring/tests/aead_tests.rs tice appear in all copies. // // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUT...
code_fim
hard
{ "lang": "rust", "repo": "mesalock-linux/crates-sgx", "path": "/vendor/ring/tests/aead_tests.rs", "mode": "psm", "license": "OpenSSL", "source": "the-stack-v2" }
<|fim_suffix|> algorithm: &'static aead::Algorithm, key: &[u8], nonce: aead::Nonce, aad: aead::Aad<&[u8]>, in_out: &'a mut [u8], ciphertext_and_tag: RangeFrom<usize>, ) -> Result<&'a mut [u8], error::Unspecified> { let key = make_less_safe_key(algorithm, key); key.open_within(nonce, aad, ...
code_fim
hard
{ "lang": "rust", "repo": "mesalock-linux/crates-sgx", "path": "/vendor/ring/tests/aead_tests.rs", "mode": "spm", "license": "OpenSSL", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mesalock-linux/crates-sgx path: /vendor/ring/tests/aead_tests.rs ute this software for any // purpose with or without fee is hereby granted, provided that the above // copyright notice and this permission notice appear in all copies. // // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAI...
code_fim
hard
{ "lang": "rust", "repo": "mesalock-linux/crates-sgx", "path": "/vendor/ring/tests/aead_tests.rs", "mode": "psm", "license": "OpenSSL", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sbnair/moebius path: /solana/moebius/program/src/state.rs //! State transition types use arrayref::{array_mut_ref, array_ref, array_refs, mut_array_refs}; use solana_program::{ program_error::ProgramError, program_pack::{IsInitialized, Pack, Sealed}, pubkey::Pubkey, }; /// Moebius ...
code_fim
hard
{ "lang": "rust", "repo": "sbnair/moebius", "path": "/solana/moebius/program/src/state.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let dst = array_mut_ref![dst, 0, 33]; let (is_initialized_dst, authority_dst) = mut_array_refs![dst, 1, 32]; let &Moebius { is_initialized, ref authority, } = self; authority_dst.copy_from_slice(authority.as_ref()); is_initialized_dst...
code_fim
hard
{ "lang": "rust", "repo": "sbnair/moebius", "path": "/solana/moebius/program/src/state.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> } } decl_event! { pub enum Event { }; } /// tests for this module #[cfg(test)] mod tests { use super::*; use frame_support::{assert_ok, assert_err, impl_outer_origin, parameter_types, weights::Weight}; use sp_runtime::{testing::Header, traits::IdentityLookup, Perbill}; use ...
code_fim
hard
{ "lang": "rust", "repo": "aoikurokawa/sub-utxo", "path": "/runtime/src/utxo.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aoikurokawa/sub-utxo path: /runtime/src/utxo.rs use super::Aura; use codec::{Decode, Encode}; use frame_support::{ decl_event, decl_module, decl_storage, dispatch::{DispatchResult, Vec}, ensure, }; use sp_core::{H256, H512}; #[cfg(feature = "std")] use serde::{Deserialize, Serializ...
code_fim
hard
{ "lang": "rust", "repo": "aoikurokawa/sub-utxo", "path": "/runtime/src/utxo.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: coogie/rs-caesar-cipher path: /src/main.rs use std::io::{self, Write}; // `main` is our mandatory function, and is run when we run our application. fn main() { println!(""); println!("┌───────────────────────────┐"); println!("│ ✨ RUST CAESAR CIPHER ✨ │"); println!("└──────────...
code_fim
hard
{ "lang": "rust", "repo": "coogie/rs-caesar-cipher", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if entered.is_empty() { break; } let first = buf.to_ascii_lowercase().chars().next().unwrap(); if first == 'e' || first == 'd' { direction = first; break; } } direction } /** * This is how our functions can recieve bor...
code_fim
hard
{ "lang": "rust", "repo": "coogie/rs-caesar-cipher", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// Creates an `ID3D11Buffer`. fn create_buffer<T>( device: &Device, data: &[T], usage: d3d11::D3D11_USAGE, bind: d3d11::D3D11_BIND_FLAG, cpu_access: d3d11::D3D11_CPU_ACCESS_FLAG, misc: d3d11::D3D11_RESOURCE_MISC_FLAG, type_string: &'static str, ) -> Result<ComPtr<d3d11::ID3D11...
code_fim
hard
{ "lang": "rust", "repo": "kb10uy/derky", "path": "/derky/src/d3d11/buffer.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> comptrize!(uav); uav }; Ok(RwBuffer { buffer, staging, view, inner_type: Default::default(), }) } /// Updates its content. pub fn set(&self, context: &Context, data: &T) { unsafe { ...
code_fim
hard
{ "lang": "rust", "repo": "kb10uy/derky", "path": "/derky/src/d3d11/buffer.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kb10uy/derky path: /derky/src/d3d11/buffer.rs //! Contains types for any Buffer. use crate::{ comptrize, d3d11::{ com_support::{ComPtr, HresultErrorExt}, context::{Context, Device}, vertex::D3d11Vertex, }, null, }; use std::{ ffi::c_void, marker:...
code_fim
hard
{ "lang": "rust", "repo": "kb10uy/derky", "path": "/derky/src/d3d11/buffer.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: HerringtonDarkholme/leetcode path: /src/593_valid_square.rs impl Solution { pub fn valid_square(p1: Vec<i32>, p2: Vec<i32>, p3: Vec<i32>, p4: Vec<i32>) -> bool { let p12 = len(&p1, &p2); let p13 = len(&p1, &p3); let p14 = len(&p1, &p4); if p12 == 0 || p13 == 0...
code_fim
hard
{ "lang": "rust", "repo": "HerringtonDarkholme/leetcode", "path": "/src/593_valid_square.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let p12x = p1[0] - p2[0]; let p13x = p1[0] - p3[0]; let p12y = p1[1] - p2[1]; let p13y = p1[1] - p3[1]; (p12x * p13x + p12y * p13y) == 0 }<|fim_prefix|>// repo: HerringtonDarkholme/leetcode path: /src/593_valid_square.rs impl Solution { pub fn valid_square(p1: Vec<i32>, p2: Vec<i3...
code_fim
hard
{ "lang": "rust", "repo": "HerringtonDarkholme/leetcode", "path": "/src/593_valid_square.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn test_sign_hsmcl_ggm(lam: &usize, message: &BigInt) -> (BigInt, BigInt) { let ec_key1: Signer_EcKeyPair = Signer_EcKeyPair::s1_generate_K1(); // K1 and k1 let K1 = ec_key1.public_share; let k1 = ec_key1.secret_share.to_big_int(); let ec_key2: User_EcKeyPair = User_EcKeyPair::s2_gener...
code_fim
hard
{ "lang": "rust", "repo": "darrenhdc/Blind-ECDSA", "path": "/bld_sig/src/protocols/blind_ecdsa/test_sign.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }