text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> /// Returns the distance_model property. /// /// Range: a value from the DistanceModel enumeration /// /// Default value: DistanceModel::Linear /// /// Distance models control how quickly sources get quieter as they move away from the listener. /// By default, source...
code_fim
hard
{ "lang": "rust", "repo": "Neurrone/rust-libaudioverse", "path": "/src/nodes/environment_node.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Returns the max_reverb_level property. /// /// Range: [0.0, 1.0] /// /// Default value: 0.6 /// /// The maximum amount of audio to be diverted to reverb sends, if any. /// Behavior is undefined if this property is ever less than Lav_ENVIRONMENT_MIN_REVERB_LEVEL. ...
code_fim
hard
{ "lang": "rust", "repo": "Neurrone/rust-libaudioverse", "path": "/src/nodes/environment_node.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: falconre/falcon-z3 path: /lib/context.rs use std::ffi::CString; use z3_sys; use Ast; use Config; use Sort; pub struct Context { pub(crate) context: z3_sys::Z3_context, } impl Context { pub fn new(config: Config) -> Context { Context { context: unsafe { z3_sys::Z3_mk...
code_fim
hard
{ "lang": "rust", "repo": "falconre/falcon-z3", "path": "/lib/context.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn eq(&self, lhs: &Ast, rhs: &Ast) -> Ast { Ast { ast: unsafe { z3_sys::Z3_mk_eq(self.context, lhs.ast, rhs.ast) }, } } pub fn ite(&self, condition: &Ast, then: &Ast, else_: &Ast) -> Ast { Ast { ast: unsafe { z3_sys::Z3_mk_ite(self.context, ...
code_fim
hard
{ "lang": "rust", "repo": "falconre/falcon-z3", "path": "/lib/context.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>atus() { http::StatusCode::OK => { let rsp_body = rsp.body(); let rsp_value: Vec<OperationsDefinition> = serde_json::from_slice(rsp_body) .map_err(|source| generate_operations::Error::DeserializeError(source, rsp_body.clone()))?; ...
code_fim
hard
{ "lang": "rust", "repo": "JensWalter/azure-sdk-for-rust", "path": "/services/mgmt/providerhub/src/package_2021_06_01_preview/operations.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: JensWalter/azure-sdk-for-rust path: /services/mgmt/providerhub/src/package_2021_06_01_preview/operations.rs status_code => { let rsp_body = rsp.body(); let rsp_value: ErrorResponse = serde_json::from_slice(rsp_body) .map_err(|source| create...
code_fim
hard
{ "lang": "rust", "repo": "JensWalter/azure-sdk-for-rust", "path": "/services/mgmt/providerhub/src/package_2021_06_01_preview/operations.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ciyool/rust_utils path: /src/utils/c_serde_json.rs pub mod c_datetime_format { use chrono::{NaiveDateTime, TimeZone, Utc}; use serde::{self, Deserialize, Deserializer, Serializer}; const FORMAT: &'static str = "%Y-%m-%d %H:%M:%S"; // The signature of a serialize_with function m...
code_fim
hard
{ "lang": "rust", "repo": "ciyool/rust_utils", "path": "/src/utils/c_serde_json.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let payload = dataset.payload.clone(); let decode = Benchmark::new("decode", move |b| { b.iter(|| { for buf in &payload { criterion::black_box(M::decode(buf).unwrap()); } }) }) .throughput(Throughput::Bytes(payload_len as u32)); ...
code_fim
hard
{ "lang": "rust", "repo": "fujiapple852/prost", "path": "/benches/benchmark.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fujiapple852/prost path: /benches/benchmark.rs use std::fs::File; use std::io::Read; use std::result; use criterion::{Benchmark, Criterion, Throughput}; use failure::bail; use prost::Message; use protobuf::benchmarks::{proto2, proto3, BenchmarkDataset}; type Result = result::Result<(), failure...
code_fim
hard
{ "lang": "rust", "repo": "fujiapple852/prost", "path": "/benches/benchmark.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kotapiku/competitive-pg path: /atcoder/typical-dp/b.rs #![allow(unused)] use std::cmp::{max, min, Ordering}; use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque}; use std::io::{stdin, stdout, BufWriter, Write}; use std::iter::{FromIterator, Iterator}; trait Read { ...
code_fim
hard
{ "lang": "rust", "repo": "kotapiku/competitive-pg", "path": "/atcoder/typical-dp/b.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl<A: Read, B: Read, C: Read, D: Read> Read for (A, B, C, D) { fn read(s: &str) -> Self { let tokens: Vec<_> = s.split_whitespace().collect(); (A::read(tokens[0]), B::read(tokens[1]), C::read(tokens[2]), D::read(tokens[3])) } } macro_rules! max{($x:expr)=>{$x};($x:expr,$($xs:tt)+...
code_fim
hard
{ "lang": "rust", "repo": "kotapiku/competitive-pg", "path": "/atcoder/typical-dp/b.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: filecoin-project/zexe path: /snark-gadgets/src/utils.rs use crate::bits::{boolean::Boolean, uint8::UInt8}; use algebra::PairingEngine; use snark::{ConstraintSystem, SynthesisError}; use std::borrow::Borrow; /// If `condition == 1`, then enforces that `self` and `other` are equal; /// otherwise,...
code_fim
hard
{ "lang": "rust", "repo": "filecoin-project/zexe", "path": "/snark-gadgets/src/utils.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<E: PairingEngine, T: Sized + ConditionalEqGadget<E> + CondSelectGadget<E>> ConditionalOrEqualsGadget<E> for T { fn conditional_enforce_equal_or<CS: ConstraintSystem<E>>( mut cs: CS, cond: &Boolean, var: &Self, first: &Self, second: &Self, should...
code_fim
hard
{ "lang": "rust", "repo": "filecoin-project/zexe", "path": "/snark-gadgets/src/utils.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stm32-rs/stm32-rs-nightlies path: /stm32g0/src/stm32g030/dmamux/rgcfr.rs #[doc = "Register `RGCFR` writer"] pub type W = crate::W<RGCFR_SPEC>; #[doc = "Field `COF` writer - Clear trigger event overrun flag Upon setting, this bit clears the corresponding overrun flag OFx in the DMAMUX_RGCSR regis...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32g0/src/stm32g030/dmamux/rgcfr.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>_SPEC { type Ux = u32; } #[doc = "`write(|w| ..)` method takes [`rgcfr::W`](W) writer structure"] impl crate::Writable for RGCFR_SPEC { const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0; const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0; } #[doc = "`reset()` method sets RGCFR to value 0"] impl cr...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32g0/src/stm32g030/dmamux/rgcfr.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: celphase/machinery-rs path: /crates/machinery-macros/src/utils.rs use proc_macro2::{Ident, TokenStream}; use quote::quote; use syn::{FnArg, ImplItem, ItemImpl}; pub fn generate_wrappers(ty_name: &Ident, item: &ItemImpl) -> Vec<(Ident, TokenStream)> { let mut wrappers = Vec::new(); for ...
code_fim
hard
{ "lang": "rust", "repo": "celphase/machinery-rs", "path": "/crates/machinery-macros/src/utils.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Generate an external C wrapper let ident = &method_item.sig.ident; let wrapper_ident = Ident::new(&format!("{}_export", ident), ident.span()); let output = &method_item.sig.output; let wrapper = quote! { unsafe extern "C" fn #wrapper_ident(#(#args_wit...
code_fim
hard
{ "lang": "rust", "repo": "celphase/machinery-rs", "path": "/crates/machinery-macros/src/utils.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Extract the arguments let args_with_types: Vec<_> = method_item .sig .inputs .iter() .filter_map(|input| { if let FnArg::Typed(ref input) = input { Some(input) } else { ...
code_fim
hard
{ "lang": "rust", "repo": "celphase/machinery-rs", "path": "/crates/machinery-macros/src/utils.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[doc(hidden)] __LAST, } use SyntaxKind::*; impl SyntaxKind { /// Returns true if this token is a literal, such as an integer or a string pub fn is_literal(self) -> bool { matches!(self, TOKEN_FLOAT | TOKEN_INTEGER | TOKEN_PATH | TOKEN_URI) } /// Returns true if this toke...
code_fim
hard
{ "lang": "rust", "repo": "nix-community/rnix-parser", "path": "/src/kinds.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nix-community/rnix-parser path: /src/kinds.rs #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] #[repr(u16)] #[allow(non_camel_case_types)] pub enum SyntaxKind { // Internals TOKEN_COMMENT, TOKEN_ERROR, TOKEN_WHITESPACE, // Keywords TOKEN_ASSERT, TO...
code_fim
hard
{ "lang": "rust", "repo": "nix-community/rnix-parser", "path": "/src/kinds.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Returns true if this token should be used as a function argument. /// ```ignore /// Example: /// add 1 2 + 3 /// ^ ^ ^ ^ /// | | | +- false /// | | +- true /// | +- true /// +- true /// ``` pub fn is_fn_arg(self) -> bool { match self { ...
code_fim
hard
{ "lang": "rust", "repo": "nix-community/rnix-parser", "path": "/src/kinds.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>8 = 0x90; pub const ARRAY16: u8 = 0xdc; pub const ARRAY32: u8 = 0xdd; pub const NEGINT: u8 = 0xe0; pub const FIXMAP: u8 = 0x80; pub const MAP16: u8 = 0xde; pub const MAP23: u8 = 0xdf;<|fim_prefix|>// repo: ganmacs/playground path: /rust/msg/src/code.rs pub const POSINT: u8 = 0x00; pub const NIL: u8 = 0x...
code_fim
hard
{ "lang": "rust", "repo": "ganmacs/playground", "path": "/rust/msg/src/code.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ganmacs/playground path: /rust/msg/src/code.rs pub const POSINT: u8 = 0x00; pub const NIL: u8 = 0xc0; pub const FALSE: u8 = 0xc2; pub const TRUE: u8 = 0xc3; pub const UINT8: u8 = 0xcc; pub const UINT16: u8 = 0xcd; pub const UINT32: u8 = 0xce; pub const UINT64: u8 = 0xcf; pub const INT8: u8 = 0xd...
code_fim
medium
{ "lang": "rust", "repo": "ganmacs/playground", "path": "/rust/msg/src/code.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kildevaeld/duktape-rs path: /duktape/src/types/reference.rs use super::super::context::{Context, Idx}; use super::super::error::Result; use super::super::privates::{make_ref, push_ref, unref}; use super::Type; use super::{FromDuktape, ToDuktape}; use duktape_sys as duk; use std::ffi::CStr; use s...
code_fim
hard
{ "lang": "rust", "repo": "kildevaeld/duktape-rs", "path": "/duktape/src/types/reference.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl<'a> FromDuktape<'a> for Ref<'a> { fn from_context(ctx: &'a Context, index: i32) -> Result<Self> { Ok(Ref::new(ctx, index)) } } impl<'a> fmt::Display for Ref<'a> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { // let s = match self.get_type() { // Type...
code_fim
hard
{ "lang": "rust", "repo": "kildevaeld/duktape-rs", "path": "/duktape/src/types/reference.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn get_type(&self) -> Type { unsafe { push_ref(self.ctx.inner, self.refer) }; let ret = self.ctx.get_type(-1); self.ctx.pop(1); ret } pub fn is(&self, t: Type) -> bool { self.get_type() == t } pub fn get<T: FromDuktape<'a>>(&self) -> Result...
code_fim
hard
{ "lang": "rust", "repo": "kildevaeld/duktape-rs", "path": "/duktape/src/types/reference.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tempbottle/fht2p path: /src/tools.rs use url::percent_encoding::{percent_decode, percent_encode, EncodeSet}; use std::borrow::Cow; // 以后应该自己组结构体,Hyper 的 Url new方法都没, md 一个 path 都改不了,只能反复 decode.. pub fn url_for_parent(path: &str) -> String { let req_path_dec = url_path_decode(path); le...
code_fim
hard
{ "lang": "rust", "repo": "tempbottle/fht2p", "path": "/src/tools.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> vec![ ("/", "/"), ("/abc", "/"), ("/abc/", "/"), ("/abc/def", "/abc/"), ("/abc/def/", "/abc/"), ("/abc/def/g", "/abc/def/"), ("/abc/def/g/", "/abc/def/"), ].into_iter() .for_each(|(i, o)| assert_eq!(o.to_string(), url_for_parent(i))) ...
code_fim
hard
{ "lang": "rust", "repo": "tempbottle/fht2p", "path": "/src/tools.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: coriolinus/adventofcode-2016 path: /day15/src/lib.rs use aoclib::{ numbers::chinese_remainder::{chinese_remainder, Constraint}, parse, }; use std::path::Path; // known wrong answers: // // - ~50,000 => too low // - 237235 => too high // // cheating with mathematica: // // In[5]:= sizes...
code_fim
hard
{ "lang": "rust", "repo": "coriolinus/adventofcode-2016", "path": "/day15/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(discs[1].at(0), 1); assert_eq!(discs[1].at(1), 0); assert_eq!(discs[1].at(2), 1); assert_eq!(discs[1].at(3), 0); } // test doesn't work right now and I don't have the patience to debug it #[test] #[ignore] fn test_fallthrough() { // w...
code_fim
hard
{ "lang": "rust", "repo": "coriolinus/adventofcode-2016", "path": "/day15/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // test doesn't work right now and I don't have the patience to debug it #[test] #[ignore] fn test_fallthrough() { // we need a bunch of coprime numbers. I suspect we have some handy. for time_offset in 0..10 { let discs: Vec<_> = std::array::IntoIter::new([3, 5...
code_fim
hard
{ "lang": "rust", "repo": "coriolinus/adventofcode-2016", "path": "/day15/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dillonhicks/struthionidae path: /x001-async-await-and-custom-test-framework/src/main.rs #![feature(async_await)] use log::{self, info}; use spinnaker; <|fim_suffix|> #[cfg(debug_assertions)] { env_logger::init(); } // run_test() // block_on(hello_world()); let mu...
code_fim
easy
{ "lang": "rust", "repo": "dillonhicks/struthionidae", "path": "/x001-async-await-and-custom-test-framework/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[cfg(debug_assertions)] { env_logger::init(); } // run_test() // block_on(hello_world()); let mut pool = futures::executor::ThreadPool::new().unwrap(); let output = pool.run(spinnaker::async_run_postgres_test()); info!("{:?}", output); }<|fim_prefix|>// repo: dillo...
code_fim
easy
{ "lang": "rust", "repo": "dillonhicks/struthionidae", "path": "/x001-async-await-and-custom-test-framework/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests { use super::*; #[test] fn test_dataset_creation() { let mut dataset = IpMapDataset::new(); dataset.insert( SiemIp::from_ip_str("192.168.1.1").unwrap(), Cow::Borrowed("Local IP "), ); assert_eq!( dataset...
code_fim
hard
{ "lang": "rust", "repo": "bigbrobro/u-siem-core", "path": "/src/components/dataset/ip_map.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bigbrobro/u-siem-core path: /src/components/dataset/ip_map.rs use super::super::super::events::field::SiemIp; use crossbeam_channel::Sender; use std::borrow::Cow; use std::collections::BTreeMap; use std::sync::Arc; use serde::Serialize; #[derive(Serialize, Debug)] pub enum UpdateIpMap { Add...
code_fim
hard
{ "lang": "rust", "repo": "bigbrobro/u-siem-core", "path": "/src/components/dataset/ip_map.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Logsig/kusa-monitor path: /src/plotters/mod.rs //! Thanks: this demo is based on <a href="https://github.com/38/plotters/blob/master/examples/wasm-demo" target="a">examples/wasm-demo</a> of <a href="https://github.com/38/plotters" target="a">plotters</a>. pub mod func_plot; pub mod mandelbrot; ...
code_fim
hard
{ "lang": "rust", "repo": "Logsig/kusa-monitor", "path": "/src/plotters/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Type alias for the result of a drawing function. pub type DrawResult<T> = Result<T, Box<dyn std::error::Error>>; /// Type used on the JS side to convert screen coordinates to chart /// coordinates. #[wasm_bindgen] pub struct Chart { convert: Box<dyn Fn((i32, i32)) -> Option<(f64, f64)>>, } /// R...
code_fim
medium
{ "lang": "rust", "repo": "Logsig/kusa-monitor", "path": "/src/plotters/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: songroom2016/katalyst path: /src/authentication/always.rs use crate::authentication::*; use futures::future::ok; #[derive(Default, Debug)] pub struct AlwaysAuthenticatorBuilder {} impl KatalystAuthenticatorBuilder for AlwaysAuthenticatorBuilder { fn name(&self) -> &'static str { <|fim_suff...
code_fim
medium
{ "lang": "rust", "repo": "songroom2016/katalyst", "path": "/src/authentication/always.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Arc::new(AlwaysAuthenticator {}) } } #[derive(Default, Debug)] pub struct AlwaysAuthenticator {} impl KatalystAuthenticator for AlwaysAuthenticator { fn authenticate(&self, mut state: PipelineState) -> AsyncPipelineResult { let mut result = KatalystAuthenticationInfo::default(); ...
code_fim
medium
{ "lang": "rust", "repo": "songroom2016/katalyst", "path": "/src/authentication/always.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> where T: BufMut, { self.type_string().to_owned().encode(dest, version)?; match self { Self::Topic(s) => s.encode(dest, version)?, Self::CustomSpu(s) => s.encode(dest, version)?, Self::SpuGroup(s) => s.encode(dest, version)?, } ...
code_fim
hard
{ "lang": "rust", "repo": "vijaylaxmid/fluvio", "path": "/src/sc-schema/src/objects/delete.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vijaylaxmid/fluvio path: /src/sc-schema/src/objects/delete.rs //! //! # Delete object //! //! use std::io::Error; use std::io::ErrorKind; use tracing::trace; use dataplane::core::Encoder; use dataplane::core::Decoder; use dataplane::core::Version; use dataplane::bytes::{Buf, BufMut}; use data...
code_fim
hard
{ "lang": "rust", "repo": "vijaylaxmid/fluvio", "path": "/src/sc-schema/src/objects/delete.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> match self { Self::Topic(s) => s.encode(dest, version)?, Self::CustomSpu(s) => s.encode(dest, version)?, Self::SpuGroup(s) => s.encode(dest, version)?, } Ok(()) } } impl Decoder for DeleteRequest { fn decode<T>(&mut self, src: &mut T, v...
code_fim
hard
{ "lang": "rust", "repo": "vijaylaxmid/fluvio", "path": "/src/sc-schema/src/objects/delete.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if let Some(trace) = trace1.as_mut() { trace.set_differences(time.clone(), compact); } } } if let Some(mut queue) = inputs2.remove_key(&time) { let radix_sor...
code_fim
hard
{ "lang": "rust", "repo": "druidsbane/differential-dataflow", "path": "/src/operators/join.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: druidsbane/differential-dataflow path: /src/operators/join.rs //! Match pairs of records based on a key, and apply a reduction function. use std::fmt::Debug; use std::default::Default; use std::hash::Hash; use std::collections::HashMap; use std::rc::Rc; use timely::Data; use timely::dataflow::...
code_fim
hard
{ "lang": "rust", "repo": "druidsbane/differential-dataflow", "path": "/src/operators/join.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(parse_binary_tree("y"), Err("unknown char")); assert_eq!(parse_binary_tree("9"), Ok(BinaryTreeNode::Leaf(9))); assert_eq!(parse_binary_tree("[[1,2],3]"), Ok(BinaryTreeNode::Branch(BinaryTreeBranch { left: Box::new(BinaryTreeNode::Branch(BinaryTreeBranch { ...
code_fim
hard
{ "lang": "rust", "repo": "lytedev/advent-of-code", "path": "/2021/rust/day18.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let result = parse_binary_tree(day_input(18).chars()); println!("Snailfish Homework: {:#?}", result); } #[cfg(test)] mod tests { use super::*; #[test] fn parser() { assert_eq!(parse_binary_tree("y"), Err("unknown char")); assert_eq!(parse_binary_tree("9"), Ok(BinaryTr...
code_fim
hard
{ "lang": "rust", "repo": "lytedev/advent-of-code", "path": "/2021/rust/day18.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lytedev/advent-of-code path: /2021/rust/day18.rs #![warn(clippy::all, clippy::pedantic)] mod common; use common::day_input; type ChildNode<T> = Box<BinaryTreeNode<T>>; #[derive(Debug, std::cmp::PartialEq)] struct BinaryTreeBranch<T> { left: ChildNode<T>, right: ChildNode<T>, } #[deri...
code_fim
hard
{ "lang": "rust", "repo": "lytedev/advent-of-code", "path": "/2021/rust/day18.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rukai/brawllib_rs path: /src/script_runner.rs Float (right)) => left != right, (ExprResult::Int (left), ExprResult::Float (right)) => (left as f32) != right, (ExprResult::Float (left), ExprResult::Int (right)) => left ...
code_fim
hard
{ "lang": "rust", "repo": "rukai/brawllib_rs", "path": "/src/script_runner.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rukai/brawllib_rs path: /src/script_runner.rs if (refId < 0 || refId >= _references.Count) // return; // //Get the target reference // ModelVisReference refEntry = _references[refId]; // //Check if the reference and switch id is usable ...
code_fim
hard
{ "lang": "rust", "repo": "rukai/brawllib_rs", "path": "/src/script_runner.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[rustfmt::skip] fn evaluate_expression(&mut self, expression: &Expression) -> ExprResult { match expression { Expression::Nullary (requirement) => { ExprResult::Bool (match requirement { Requirement::CharacterExists => true, ...
code_fim
hard
{ "lang": "rust", "repo": "rukai/brawllib_rs", "path": "/src/script_runner.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: agent-rat/jormungandr path: /jormungandr-integration-tests/src/jcli/transaction/e2e.rs nWrapper}, jormungandr::{ConfigurationBuilder, Starter}, startup, }; use jormungandr_lib::{ crypto::hash::Hash, interfaces::{InitialUTxO, UTxOInfo}, }; use chain_impl_mockchain::fee::LinearFee...
code_fim
hard
{ "lang": "rust", "repo": "agent-rat/jormungandr", "path": "/jormungandr-integration-tests/src/jcli/transaction/e2e.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let config = ConfigurationBuilder::new() .with_funds(vec![InitialUTxO { address: sender.address.parse().unwrap(), value: transfer_amount, }]) .build(); let jormungandr = Starter::new().config(config.clone()).start().unwrap(); let transaction_mes...
code_fim
hard
{ "lang": "rust", "repo": "agent-rat/jormungandr", "path": "/jormungandr-integration-tests/src/jcli/transaction/e2e.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: agent-rat/jormungandr path: /jormungandr-integration-tests/src/jcli/transaction/e2e.rs ss1) .assert_make_witness(&witness2) .assert_add_witness_fail( &witness2, "too many witnesses in transaction to add another: 1, maximum is 1", ); } #[test] pub ...
code_fim
hard
{ "lang": "rust", "repo": "agent-rat/jormungandr", "path": "/jormungandr-integration-tests/src/jcli/transaction/e2e.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let p = SparseVec::<u8>::with_len(20); assert_eq!(next_request_for_view(&p, 0..20), Some(0..20)); } #[test] fn request_half_after() { let mut p = SparseVec::<u8>::with_len(20); p.insert_vec(0, (0..10).collect()); assert_eq!(next_request_for_view(&p, 0..10), Some(10..15)); } #[test] f...
code_fim
hard
{ "lang": "rust", "repo": "platy/longpage", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: platy/longpage path: /src/lib.rs use std::{ ops::{Range, RangeFrom}, usize, }; use sparse_vec::SparseVec; mod sparse_vec; /// Call this on a change to the viewed data or when ready to make a request. The response specifies which range of records should be requested next. Expects that ...
code_fim
hard
{ "lang": "rust", "repo": "platy/longpage", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kaj/rsass path: /rsass/tests/spec/libsass/variable_scoping/lexical_scope.rs //! Tests auto-converted from "sass-spec/spec/libsass/variable-scoping/lexical-scope.hrx" #[allow(unused)] fn runner() -> crate::TestRunner { <|fim_suffix|>#[test] #[ignore] // wrong result fn test() { assert_eq!( ...
code_fim
hard
{ "lang": "rust", "repo": "kaj/rsass", "path": "/rsass/tests/spec/libsass/variable_scoping/lexical_scope.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!( runner().ok("$x: -42;\ \n$y: -84;\ \ndiv {\ \n $x: 42;\ \n $y: 84;\ \n for {\ \n @for $x from 1 through 5 {\ \n $y: $y + 5;\ \n y: $y;\ \n x: $x...
code_fim
hard
{ "lang": "rust", "repo": "kaj/rsass", "path": "/rsass/tests/spec/libsass/variable_scoping/lexical_scope.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sidky/comical-backend path: /src/firebase/auth.rs // extern crate untrusted; // extern crate ring; // use self::jwt::{encode, decode, Header, Validation, Algorithm}; // use self::jwt::errors::ErrorKind; use std::time::{SystemTime, UNIX_EPOCH}; use std::io::{Error, ErrorKind}; use std::sync::Ar...
code_fim
hard
{ "lang": "rust", "repo": "sidky/comical-backend", "path": "/src/firebase/auth.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub struct ConfigVarAuth { var_name: String } impl GoogleAuth for FileAuth { fn service_token(&self) -> Result<ServiceAccountKey, Error> { service_account_key_from_file(&self.file_name) } } impl FileAuth { pub fn new(file_name: String) -> FileAuth { FileAuth { file_name:...
code_fim
hard
{ "lang": "rust", "repo": "sidky/comical-backend", "path": "/src/firebase/auth.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: timsuchanek/prisma-engines path: /introspection-engine/connectors/sql-introspection-connector/src/commenting_out_guardrails.rs use crate::warnings::{ warning_enum_values_with_empty_names, warning_fields_with_empty_names, warning_models_without_identifier, warning_unsupported_types, EnumA...
code_fim
hard
{ "lang": "rust", "repo": "timsuchanek/prisma-engines", "path": "/introspection-engine/connectors/sql-introspection-connector/src/commenting_out_guardrails.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // models without uniques / ids for model in &mut datamodel.models { if model.id_fields.is_empty() && !model .fields .iter() .any(|f| (f.is_id || f.is_unique) && !f.is_commented_out) && !model.indices.iter().any(|i| i....
code_fim
hard
{ "lang": "rust", "repo": "timsuchanek/prisma-engines", "path": "/introspection-engine/connectors/sql-introspection-connector/src/commenting_out_guardrails.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: damienmg/cargo-raze path: /impl/src/context.rs // Copyright 2018 Google Inc. // // 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 // // http://www.apache.org/licen...
code_fim
hard
{ "lang": "rust", "repo": "damienmg/cargo-raze", "path": "/impl/src/context.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Serialize)] pub struct WorkspaceContext { /** * The bazel path prefix to the vendor directory */ pub workspace_path: String, /** * The compilation target triple. */ pub platform_triple: String, /** * The generated new_http_l...
code_fim
hard
{ "lang": "rust", "repo": "damienmg/cargo-raze", "path": "/impl/src/context.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: betseg/aoc20 path: /src/day10.rs use std::collections::HashMap; #[aoc_generator(day10)] pub fn input_generator(input: &str) -> Vec<usize> { let mut input = input .lines() .map(str::parse) .map(Result::unwrap) .collect::<Vec<_>>(); input.push(0); input...
code_fim
hard
{ "lang": "rust", "repo": "betseg/aoc20", "path": "/src/day10.rs", "mode": "psm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn example2_1() { assert_eq!( solve_part2(&input_generator( "16\n\ 10\n\ 15\n\ 5\n\ 1\n\ 11\n\ 7\n\ 19\n\ ...
code_fim
hard
{ "lang": "rust", "repo": "betseg/aoc20", "path": "/src/day10.rs", "mode": "spm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn example2_2() { assert_eq!( solve_part2(&input_generator( "28\n\ 33\n\ 18\n\ 42\n\ 31\n\ 14\n\ 46\n\ 20\n\ ...
code_fim
hard
{ "lang": "rust", "repo": "betseg/aoc20", "path": "/src/day10.rs", "mode": "spm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alexcrichton/wasmtime path: /crates/wasi-common/cap-std-sync/src/clocks.rs use cap_std::time::{Duration, Instant, SystemTime}; use cap_std::{ambient_authority, AmbientAuthority}; use cap_time_ext::{MonotonicClockExt, SystemClockExt}; use wasi_common::clocks::{WasiClocks, WasiMonotonicClock, Wasi...
code_fim
hard
{ "lang": "rust", "repo": "alexcrichton/wasmtime", "path": "/crates/wasi-common/cap-std-sync/src/clocks.rs", "mode": "psm", "license": "LLVM-exception", "source": "the-stack-v2" }
<|fim_suffix|>pub fn clocks_ctx() -> WasiClocks { let system = Box::new(SystemClock::new(ambient_authority())); let monotonic = cap_std::time::MonotonicClock::new(ambient_authority()); let creation_time = monotonic.now(); let monotonic = Box::new(MonotonicClock(monotonic)); WasiClocks { syst...
code_fim
hard
{ "lang": "rust", "repo": "alexcrichton/wasmtime", "path": "/crates/wasi-common/cap-std-sync/src/clocks.rs", "mode": "spm", "license": "LLVM-exception", "source": "the-stack-v2" }
<|fim_suffix|> let mut result = HashMap::new(); for module in &mcu.modules { for register_group in &module.register_groups { for register in &register_group.registers { // Check if we've already seen this register. // Remove it if so an...
code_fim
hard
{ "lang": "rust", "repo": "Logarithmus/avrd", "path": "/build.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Logarithmus/avrd path: /build.rs extern crate avr_mcu; use std::path::Path; fn main() { let crate_root = Path::new(env!("CARGO_MANIFEST_DIR")); let mcus = match cfg!(feature = "all_mcus") { true => avr_mcu::microcontrollers().to_owned(), false => vec![avr_mcu::current:...
code_fim
hard
{ "lang": "rust", "repo": "Logarithmus/avrd", "path": "/build.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let register_names: HashSet<&str> = registers.iter().map(|r| &r.name[..]).collect(); // A hash map of bitfield names to possible instantiations. let mut history: HashMap<&str, Vec<(&Register, &Bitfield)>> = HashMap::new(); for register in registers { for bitfi...
code_fim
hard
{ "lang": "rust", "repo": "Logarithmus/avrd", "path": "/build.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // self.turn += 1; // if self.turn % 100 == 0 { // log::debug!("[REM] TestBucket turn #{}", self.turn); // } } fn handle_message(&mut self, message: BucketMessage) { log::debug!("[REM] TestBucket received a message: {:?}", str::from_utf8(&message.get_co...
code_fim
medium
{ "lang": "rust", "repo": "WisartArfun/Divisionaries", "path": "/src/prog/bucket/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: WisartArfun/Divisionaries path: /src/prog/bucket/mod.rs use std::str; use bucketer::bucket::{Bucket, BucketMessage}; pub struct TestBucket { turn: i64, } impl TestBucket { pub fn new() -> Self { Self { turn: 0, } } } impl Bucket for TestBucket { f...
code_fim
medium
{ "lang": "rust", "repo": "WisartArfun/Divisionaries", "path": "/src/prog/bucket/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn handle_message(&mut self, message: BucketMessage) { log::debug!("[REM] TestBucket received a message: {:?}", str::from_utf8(&message.get_content())); } }<|fim_prefix|>// repo: WisartArfun/Divisionaries path: /src/prog/bucket/mod.rs use std::str; use bucketer::bucket::{Bucket, BucketM...
code_fim
hard
{ "lang": "rust", "repo": "WisartArfun/Divisionaries", "path": "/src/prog/bucket/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zrthxn/RustSHA path: /src/main.rs #[allow(unused_variables)] #[allow(unused_mut)] #[allow(dead_code)] #[allow(unused_parens)] mod core; <|fim_suffix|> core::hash("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890+/".to_string()); }<|fim_middle|>fn main() {
code_fim
easy
{ "lang": "rust", "repo": "zrthxn/RustSHA", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> core::hash("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890+/".to_string()); }<|fim_prefix|>// repo: zrthxn/RustSHA path: /src/main.rs #[allow(unused_variables)] #[allow(unused_mut)] #[allow(dead_code)] #[allow(unused_parens)] mod core; <|fim_middle|>fn main() {
code_fim
easy
{ "lang": "rust", "repo": "zrthxn/RustSHA", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: elmurci/xpring-rs path: /examples/ilp.rs use anyhow::Error; use fehler::throws; use xpring::Ilp; <|fim_suffix|> // Get Balance let balance = ilp.get_balance()?; println!("Get Balance {:#?}", balance); // Send Payment let payment = ilp.send_to("$money.ilpv4.dev/sdk_account2",...
code_fim
medium
{ "lang": "rust", "repo": "elmurci/xpring-rs", "path": "/examples/ilp.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Get Balance let balance = ilp.get_balance()?; println!("Get Balance {:#?}", balance); // Send Payment let payment = ilp.send_to("$money.ilpv4.dev/sdk_account2", 13, 10)?; println!("\nILP Payment {:#?}", payment); }<|fim_prefix|>// repo: elmurci/xpring-rs path: /examples/ilp.rs...
code_fim
medium
{ "lang": "rust", "repo": "elmurci/xpring-rs", "path": "/examples/ilp.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Modal for DialogData { fn is_closed(&self) -> Option<Command> { match self { DialogData::NewFileSettings(it) if it.state == DialogState::Closed => { Some(Command::new(NEW_IMAGE_ACTION, it.kind.clone(), Target::Auto)) } _ => None, ...
code_fim
hard
{ "lang": "rust", "repo": "paintr-rs/paintr", "path": "/crates/paintr/src/dialogs.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: paintr-rs/paintr path: /crates/paintr/src/dialogs.rs use druid::{ lens::{self, LensExt}, Color, Command, Data, Env, Lens, Target, Widget, }; use druid::{ widget::{Button, Flex, Label, LabelText, LensWrap, Parse, TextBox, WidgetExt}, TextAlignment, }; use crate::commands::NEW_IMA...
code_fim
hard
{ "lang": "rust", "repo": "paintr-rs/paintr", "path": "/crates/paintr/src/dialogs.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Data, Eq, PartialEq, Clone, Lens, Debug, Default)] pub struct NewFileSettings { pub width: Option<u32>, pub height: Option<u32>, } fn make_label<T: Data + 'static>(text: impl Into<LabelText<T>>) -> impl Widget<T> { let row_padding = (10.0, 2.5); Label::new(text).with_text_alignme...
code_fim
hard
{ "lang": "rust", "repo": "paintr-rs/paintr", "path": "/crates/paintr/src/dialogs.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>ap(k as usize, j as usize); j -= 1; }else{ k += 1; } } } }<|fim_prefix|>// repo: rainliu/leetcode path: /src/075SortColors/075SortColors.rs impl Solution { pub fn sort_colors(nums: &mut Vec<i32>) { let (mut i, mut j) = (0 as ...
code_fim
hard
{ "lang": "rust", "repo": "rainliu/leetcode", "path": "/src/075SortColors/075SortColors.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rainliu/leetcode path: /src/075SortColors/075SortColors.rs impl Solution { pub fn sort_colors(nums: &mut Vec<i32>) { let (mut i, mut j) = (0 as i32, nums.len() as i32 - 1);<|fim_suffix|>ap(k as usize, j as usize); j -= 1; }else{ k += 1; ...
code_fim
hard
{ "lang": "rust", "repo": "rainliu/leetcode", "path": "/src/075SortColors/075SortColors.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>s usize); i += 1; k += 1; }else if nums[k as usize] > 1 { nums.swap(k as usize, j as usize); j -= 1; }else{ k += 1; } } } }<|fim_prefix|>// repo: rainliu/leetcode path: /src/075...
code_fim
hard
{ "lang": "rust", "repo": "rainliu/leetcode", "path": "/src/075SortColors/075SortColors.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub unsafe fn with_translated_value_result<F, T>(error: *mut ExternError, callback: F) -> T where F: FnOnce() -> Result<T>, T: Default { try_translate_result(callback(), error).unwrap_or_default() } pub unsafe fn with_translated_string_result<F>(error: *mut ExternError, callback: F) -> *mut c_char wh...
code_fim
hard
{ "lang": "rust", "repo": "carolkng/application-services", "path": "/sync15/passwords/ffi/src/error.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: carolkng/application-services path: /sync15/passwords/ffi/src/error.rs // Copyright 2018 Mozilla // // 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 http://www.apache....
code_fim
hard
{ "lang": "rust", "repo": "carolkng/application-services", "path": "/sync15/passwords/ffi/src/error.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub unsafe fn try_translate_result<T>(result: Result<T>, error: *mut ExternError) -> Option<T> { // TODO: can't unwind across FFI... assert!(!error.is_null(), "Error output parameter is not optional"); let error = &mut *error; error.message = ptr::null_mut(); match result { Ok(...
code_fim
hard
{ "lang": "rust", "repo": "carolkng/application-services", "path": "/sync15/passwords/ffi/src/error.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hatchling13/rmdprep path: /src/main.rs mod args; fn main() { let m = args::new(); <|fim_suffix|> for name in names { println!("{}", name); } }<|fim_middle|> let mut input = String::new(); if m.is_present("INPUT") { input = m.value_of("INPUT").unwrap().to_stri...
code_fim
hard
{ "lang": "rust", "repo": "hatchling13/rmdprep", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if m.is_present("INPUT") { input = m.value_of("INPUT").unwrap().to_string(); } // Can receive multiple filename at once let names = input.split(','); for name in names { println!("{}", name); } }<|fim_prefix|>// repo: hatchling13/rmdprep path: /src/main.rs mod ar...
code_fim
easy
{ "lang": "rust", "repo": "hatchling13/rmdprep", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for name in names { println!("{}", name); } }<|fim_prefix|>// repo: hatchling13/rmdprep path: /src/main.rs mod args; fn main() { let m = args::new(); let mut input = String::new(); <|fim_middle|> if m.is_present("INPUT") { input = m.value_of("INPUT").unwrap().to_stri...
code_fim
medium
{ "lang": "rust", "repo": "hatchling13/rmdprep", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[ffi_export] pub fn x25519_sk_diffie_hellman(secret: &mut X25519Secret, pk: *const u8) -> *const u8 { let pk: [u8; 32] = unsafe { slice::from_raw_parts(pk, 32) }.try_into().unwrap(); return const_u8(*secret.s.diffie_hellman(&PublicKey::from(pk)).as_bytes()); }<|fim_prefix|>// repo: rmw-dart/ffi path...
code_fim
medium
{ "lang": "rust", "repo": "rmw-dart/ffi", "path": "/src/x25519.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rmw-dart/ffi path: /src/x25519.rs use crate::const_u8::const_u8; use core::slice; use safer_ffi::prelude::*; use std::convert::TryInto; use x25519_dalek::{PublicKey, StaticSecret}; #[derive_ReprC] #[ReprC::opaque] pub struct X25519Secret { pub s: StaticSecret, } <|fim_suffix|>#[ffi_export] p...
code_fim
hard
{ "lang": "rust", "repo": "rmw-dart/ffi", "path": "/src/x25519.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> z = match context.eval(&iter)? { Value::Complex(z) => z, _ => { return Err(Error { message: "Iter did not evaluate to a complex number", position: init.position, }); ...
code_fim
hard
{ "lang": "rust", "repo": "htrefil/multiman", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: htrefil/multiman path: /src/main.rs #![feature(process_exitcode_placeholder)] mod ast; mod error; mod eval; mod lex; mod parser; use error::Error; use eval::{Context, Value}; use image::{Rgb, RgbImage}; use num_complex::Complex; use std::cmp; use std::env; use std::num::NonZeroU32; use std::pat...
code_fim
hard
{ "lang": "rust", "repo": "htrefil/multiman", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: goyox86/algorithms path: /week1/percolation/src/main.rs // Copyright 2014 Jose Narvaez. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache...
code_fim
hard
{ "lang": "rust", "repo": "goyox86/algorithms", "path": "/week1/percolation/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> ((i - 1) * self.n) + (j - 1) } } struct PercolationStats { n: uint, t: uint, tresholds: Vec<f64> } impl PercolationStats { fn new(n: uint, t: uint) -> PercolationStats { let mut obj = PercolationStats { n: n, t: t, tresholds: Vec::with_capacity(t) }; obj } ...
code_fim
hard
{ "lang": "rust", "repo": "goyox86/algorithms", "path": "/week1/percolation/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> total / (self.t as f64) } fn stddev(&self) -> f64 { let mut total = 0.0f64; let mean = self.mean(); for i in range(0u, self.t) { total += (self.tresholds[i] - mean) * (self.tresholds[i] - mean); } total / ((self.t - 1) as f64) } fn confidence_lo(&self) -> f64 { ...
code_fim
hard
{ "lang": "rust", "repo": "goyox86/algorithms", "path": "/week1/percolation/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: linebender/runebender path: /runebender-lib/src/virtual_font.rs use druid::kurbo::Shape; use norad::{GlyphName, Ufo}; use crate::data::Workspace; use std::convert::TryInto; pub type GlyphId = u16; /// An object that acts like a font loaded from disk. /// /// This lets us interact with harfbu...
code_fim
hard
{ "lang": "rust", "repo": "linebender/runebender", "path": "/runebender-lib/src/virtual_font.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>struct HorizontalHeader { version: (u16, u16), ascender: i16, descender: i16, line_gap: i16, advance_width_max: u16, left_side_bearing_min: i16, right_side_bearing_min: i16, max_x_extent: i16, caret_slope_rise: i16, caret_slope_run: i16, caret_offset: i16, r...
code_fim
hard
{ "lang": "rust", "repo": "linebender/runebender", "path": "/runebender-lib/src/virtual_font.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn just_string_id(s: String) -> Irep { Irep::just_id(IrepId::from_string(s)) } pub fn just_sub(sub: Vec<Irep>) -> Irep { Irep { id: IrepId::EmptyString, sub: sub, named_sub: BTreeMap::new() } } pub fn nil() -> Irep { Irep::just_id(IrepId::Nil) } p...
code_fim
hard
{ "lang": "rust", "repo": "bdalrhm/rmc", "path": "/compiler/rustc_codegen_llvm/src/gotoc/cbmc/irep/irep.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }