text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: adamnemecek/tgtracker path: /specs/src/frontend/editor/song_editor.rs //@ # song editor //@ //@ The 'song editor' is a tracker-style interface for editing patterns of note data. //@ //@ - [ ] Use glyph_brush and rusttype for font rendering //@ - [ ] Pattern scroll (as opposed to piano roll) i.e....
code_fim
hard
{ "lang": "rust", "repo": "adamnemecek/tgtracker", "path": "/specs/src/frontend/editor/song_editor.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lilith645/Maat-Graphics path: /src/extra/new_gltf_loader.rs use std::collections::HashMap; pub fn texture_label(texture: &gltf::Texture) -> String { format!("Texture{}", texture.index()) } pub fn material_label(material: &gltf::Material) -> String { if let Some(index) = material.index() { ...
code_fim
hard
{ "lang": "rust", "repo": "lilith645/Maat-Graphics", "path": "/src/extra/new_gltf_loader.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for buffer in gltf.buffers() { match buffer.source() { gltf::buffer::Source::Uri(uri) => { println!("Uri: {}", uri); } gltf::buffer::Source::Bin => { println!("Bin"); if let Some(blob) = gltf.blob.as_deref() { buffer_data.push(blob.into()); ...
code_fim
hard
{ "lang": "rust", "repo": "lilith645/Maat-Graphics", "path": "/src/extra/new_gltf_loader.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: wezm/dslite2svd path: /crates/tm4c129x/src/sysctl/altclkcfg/mod.rs #[doc = r" Value read from the register"] pub struct R { bits: u32, } #[doc = r" Value to write to the register"] pub struct W { bits: u32, } impl super::ALTCLKCFG { #[doc = r" Modifies the contents of the register"] ...
code_fim
hard
{ "lang": "rust", "repo": "wezm/dslite2svd", "path": "/crates/tm4c129x/src/sysctl/altclkcfg/mod.rs", "mode": "psm", "license": "0BSD", "source": "the-stack-v2" }
<|fim_suffix|> self.variant(ALTCLKW::LFIOSC) } #[doc = r" Writes raw bits to the field"] #[inline] pub unsafe fn bits(self, value: u8) -> &'a mut W { const MASK: u8 = 15; const OFFSET: u8 = 0; self.w.bits &= !((MASK as u32) << OFFSET); self.w.bits |= ((value & MASK)...
code_fim
hard
{ "lang": "rust", "repo": "wezm/dslite2svd", "path": "/crates/tm4c129x/src/sysctl/altclkcfg/mod.rs", "mode": "spm", "license": "0BSD", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Globidev/corewa-rs path: /corewa-rs/src/vm/decoder.rs use super::types::*; use crate::spec::*; pub trait Read: std::ops::Index<usize, Output = u8> { fn read_i32(&self, at: usize) -> i32; fn read_i16(&self, at: usize) -> i16; } pub trait Decode: Read { fn decode_op(&self, idx: usize...
code_fim
hard
{ "lang": "rust", "repo": "Globidev/corewa-rs", "path": "/corewa-rs/src/vm/decoder.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn op_from_code(code: u8) -> Option<OpType> { use OpType::*; let op_type = match code { 1 => Live, 2 => Ld, 3 => St, 4 => Add, 5 => Sub, 6 => And, 7 => Or, 8 => Xor, 9 => Zjmp, 10 => Ldi, 11 => Sti, 12...
code_fim
hard
{ "lang": "rust", "repo": "Globidev/corewa-rs", "path": "/corewa-rs/src/vm/decoder.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> while begin <= end { tmp = comp.nuc2nuc(seq.as_mut_vec()[begin] as char); seq.as_mut_vec()[begin] = comp.nuc2nuc(seq.as_mut_vec()[end] as char) as u8; seq.as_mut_vec()[end] = tmp as u8; begin += 1; end -= 1; } } return s...
code_fim
medium
{ "lang": "rust", "repo": "dridk/bench_rev_comp", "path": "/rust/src/rev/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut rev_comp = String::with_capacity(seq.len()); for ord in seq.chars().rev() { rev_comp.push(comp.nuc2nuc(ord)); } return rev_comp; } pub fn switch<C: comp::Base>(mut seq: String, comp: &C) -> String { let mut tmp: char; unsafe { let mut begin = 0; ...
code_fim
hard
{ "lang": "rust", "repo": "dridk/bench_rev_comp", "path": "/rust/src/rev/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dridk/bench_rev_comp path: /rust/src/rev/mod.rs /* standard use */ use std::string::String; use super::comp; pub fn naif<C: comp::Base>(seq: String, comp: &C) -> String { let mut rev_comp = String::new(); for nuc in seq.chars().rev() { rev_comp.push(comp.nuc2nuc(nuc)); }...
code_fim
medium
{ "lang": "rust", "repo": "dridk/bench_rev_comp", "path": "/rust/src/rev/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lars-t-hansen/swat2 path: /src/ast.rs dItem { Var(Box<GlobalDef>), Fn(Box<FunctionDef>), Struct(Box<StructDef>) } #[derive(Debug)] pub struct GlobalDef { pub mutable: bool, pub imported: bool, pub exported: bool, pub name: Id, pub ty: Type, pub ini...
code_fim
hard
{ "lang": "rust", "repo": "lars-t-hansen/swat2", "path": "/src/ast.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Introduced by flattening. GetLocal{name: Id}, GetGlobal{name: Id}, SetLocal{name: Id, value: Box<Expr>}, SetGlobal{name: Id, value: Box<Expr>}, GetField{base: Box<Expr>, field: Id}, SetField{base: Box<Expr>, field: Id, value: Box<Expr>}, Sequence{ty: Option<Type>, body: ...
code_fim
hard
{ "lang": "rust", "repo": "lars-t-hansen/swat2", "path": "/src/ast.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub fn match_parameters(formals:&Vec<Type>, actuals:&Vec<Box<Expr>>) -> bool { if actuals.len() != formals.len() { return false; } for i in 0..actuals.len() { if !is_assignable_type(Some(formals[i]), actuals[i].ty) { return false; } } true } pub fn ...
code_fim
hard
{ "lang": "rust", "repo": "lars-t-hansen/swat2", "path": "/src/ast.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let region_id = 8; let stats = Arc::new(GlobalStats::default()); let mut memtable = MemTable::new(region_id, stats.clone()); // [5, 10) file_num = 1 // [10, 20) file_num = 2 let ents_idx = generate_entry_indexes(5, 10, LogQueue::Append, 1.into()); m...
code_fim
hard
{ "lang": "rust", "repo": "hanxueming126/raft-engine", "path": "/src/memtable.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hanxueming126/raft-engine path: /src/memtable.rs scending indexes. entries_index: VecDeque<EntryIndex>, // The amount of rewritten entries. This can be used to index appended entries // because rewritten entries are always at front. rewrite_count: usize, // key -> (value, qu...
code_fim
hard
{ "lang": "rust", "repo": "hanxueming126/raft-engine", "path": "/src/memtable.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jtescher/rust-postgres path: /postgres-shared/src/params/url.rs // Copyright 2012-2014 The Rust Project Developers. 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-AP...
code_fim
hard
{ "lang": "rust", "repo": "jtescher/rust-postgres", "path": "/postgres-shared/src/params/url.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Err("url: Scheme must be terminated with a colon.".to_owned()) } // returns userinfo, host, port, and unparsed part, or an error fn get_authority(rawurl: &str) -> DecodeResult<(Option<UserInfo>, &str, Option<u16>, &str)> { enum State { Start, // starting state PassHostPort, // cou...
code_fim
hard
{ "lang": "rust", "repo": "jtescher/rust-postgres", "path": "/postgres-shared/src/params/url.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: JakeSCahill/chronicle.rs path: /chronicle-api/src/api/endpoint.rs use super::router::handle; use chronicle_common::{ actor, traits::{ launcher::LauncherTx, shutdown::ShutdownTx, }, }; use hyper::{ server::Server, service::{ make_service_fn, ser...
code_fim
hard
{ "lang": "rust", "repo": "JakeSCahill/chronicle.rs", "path": "/chronicle-api/src/api/endpoint.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> self.0.send(()).unwrap(); } } impl Endpoint { pub async fn run(mut self) { let service = make_service_fn(|_conn| async { Ok::<_, Infallible>(service_fn(handle)) }); let server = Server::bind(&self.addr).serve(service); let (tx, rx) = tokio::sync::oneshot::channel::<...
code_fim
hard
{ "lang": "rust", "repo": "JakeSCahill/chronicle.rs", "path": "/chronicle-api/src/api/endpoint.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ZippyMagician/Arn path: /src/utils/consts.rs // An easier way to create the precedence and operator global constants macro_rules! operators { ($($chr:literal : $prec:literal; $left_rank:literal - $right_rank:literal),*) => { #[derive(Clone)] pub struct Operators { ...
code_fim
hard
{ "lang": "rust", "repo": "ZippyMagician/Arn", "path": "/src/utils/consts.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>// REWORKS/PATCHES NEEDED: `;`, `\`, `@` // REMOVED: `n_` // UNUSED: `!!` // NEEDS CHANGING: numbers // Little macro I created to make the global Operators class much nicer. // First number is precedence, second is left # of args, third is right # of args operators! { '.': 11; 1-1, '^': ...
code_fim
hard
{ "lang": "rust", "repo": "ZippyMagician/Arn", "path": "/src/utils/consts.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: storiqaamericanteam/Autotests path: /functional-tests/src/query/introspection.rs use failure::Error as FailureError; use graphql_client::GraphQLQuery; use graphql_client::Response; use request::GraphqlRequest; #[derive(GraphQLQuery)] #[graphql( schema_path = "graphql/queries/introspection/...
code_fim
hard
{ "lang": "rust", "repo": "storiqaamericanteam/Autotests", "path": "/functional-tests/src/query/introspection.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl GraphqlRequest for IntrospectionInput { type Output = GraphqlRequestOutput; fn response(body: serde_json::Value) -> Result<GraphqlRequestOutput, FailureError> { let response_body: Response<ResponseData> = serde_json::from_value(body)?; match (response_body.data, response_body...
code_fim
hard
{ "lang": "rust", "repo": "storiqaamericanteam/Autotests", "path": "/functional-tests/src/query/introspection.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn build_op<T>(s: &[u8], op: T, start: usize) -> (Option<Expr>, usize) where T: Fn(Rc<Expr>, Rc<Expr>) -> Expr { let mut i = 0; while s[i] == b' ' { i += 1; } let (maybe_a, len1) = (parse(&s[i..])); i += len1; while s[i] == b' ' { i += 1; } let (maybe_b, len2) = (parse(&s[i..])); ...
code_fim
hard
{ "lang": "rust", "repo": "ksqsf/toys", "path": "/codewars/Rust/SymbolicDifferentiationOfPrefixExpressions.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ksqsf/toys path: /codewars/Rust/SymbolicDifferentiationOfPrefixExpressions.rs //! https://www.codewars.com/kata/584daf7215ac503d5a0001ae use std::rc::Rc; use std::str; #[derive(Debug, PartialEq)] enum Expr { X, Num(f64), Add(Rc<Expr>, Rc<Expr>), Sub(Rc<Expr>, Rc<Expr>), Mul...
code_fim
hard
{ "lang": "rust", "repo": "ksqsf/toys", "path": "/codewars/Rust/SymbolicDifferentiationOfPrefixExpressions.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let e = Rc::new(Mul(Rc::new(X), Rc::new(Num(2.0)))); println!("{}", e.to_string()); println!("{}", e.diff().to_string()); println!("{}", diff("(+ x x)")); println!("{}", diff("(- x x)")); println!("{}", diff("(* x 2)")); println!("{}", diff("(/ x 2)")); println!...
code_fim
hard
{ "lang": "rust", "repo": "ksqsf/toys", "path": "/codewars/Rust/SymbolicDifferentiationOfPrefixExpressions.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn invoke_breakpoint() { x86_64::instructions::interrupts::int3(); } pub fn hlt_loop() -> ! { loop { x86_64::instructions::hlt(); } } pub fn test_runner(tests: &[&dyn Fn()]) { serial_println!("Running {} tests", tests.len()); for test in tests { test(); } ...
code_fim
medium
{ "lang": "rust", "repo": "rarescosma/blog_os", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rarescosma/blog_os path: /src/lib.rs // initialize test framework #![no_std] #![cfg_attr(test, no_main)] #![feature(custom_test_frameworks)] #![test_runner(crate::test_runner)] #![reexport_test_harness_main = "test_main"] #![feature(abi_x86_interrupt)] use core::panic::PanicInfo; pub mod vga_b...
code_fim
hard
{ "lang": "rust", "repo": "rarescosma/blog_os", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn panic_handler(info: &PanicInfo) -> ! { println!("[failed]\n"); println!("Error: {}\n", info); hlt_loop(); } /// Entry point for `cargo xtest` #[cfg(test)] #[no_mangle] pub extern "C" fn _start() -> ! { init(); test_main(); hlt_loop(); } #[cfg(test)] #[panic_handler] fn pan...
code_fim
hard
{ "lang": "rust", "repo": "rarescosma/blog_os", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Find a node pub fn find(&self, find_value: T) -> bool { match self { Node::Leaf { ref value, ref left, ref right, } => match find_value.cmp(value) { Ordering::Less => left.find(find_value), ...
code_fim
hard
{ "lang": "rust", "repo": "remipetitjean/dtree", "path": "/src/bst.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: remipetitjean/dtree path: /src/bst.rs //! Simple implementation of Binary Search Node use std::cmp::Ord; use std::cmp::Ordering; #[derive(Debug)] pub enum Node<T: Ord> { /// Node structure. Empty for a null value, or a leaf with left and right children nodes Leaf { value: T, ...
code_fim
medium
{ "lang": "rust", "repo": "remipetitjean/dtree", "path": "/src/bst.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: melotic/docx-rs path: /src/formatting/table_width.rs use strong_xml::{XmlRead, XmlWrite}; use crate::{__string_enum, __xml_test_suites}; /// Table Width /// /// ```rust /// use docx::formatting::*; /// /// let width = TableWidth::from(42usize); /// let width = TableWidth::from(TableWidthUnit::...
code_fim
hard
{ "lang": "rust", "repo": "melotic/docx-rs", "path": "/src/formatting/table_width.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl From<(usize, TableWidthUnit)> for TableWidth { fn from(val: (usize, TableWidthUnit)) -> Self { TableWidth { value: Some(val.0), unit: Some(val.1), } } } #[derive(Debug)] #[cfg_attr(test, derive(PartialEq))] pub enum TableWidthUnit { Auto, Dxa, ...
code_fim
medium
{ "lang": "rust", "repo": "melotic/docx-rs", "path": "/src/formatting/table_width.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug)] #[cfg_attr(test, derive(PartialEq))] pub enum TableWidthUnit { Auto, Dxa, Nil, Pct, } __string_enum! { TableWidthUnit { Auto = "auto", Dxa = "dxa", Nil = "nil", Pct = "pct", } } __xml_test_suites!( TableWidth, TableWidth::d...
code_fim
medium
{ "lang": "rust", "repo": "melotic/docx-rs", "path": "/src/formatting/table_width.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: juanibiapina/lish-poc path: /src/shell/eval.rs use std::process::Command; use shell::command_line::CommandLine; use error::Error; use lisp::reader::read; use lisp::env::{Env, env_get_export}; <|fim_suffix|> let result = try!(value.apply(args)); println!("{}", result.print(fals...
code_fim
hard
{ "lang": "rust", "repo": "juanibiapina/lish-poc", "path": "/src/shell/eval.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Ok(()) } else { let mut child = match Command::new(&command_line.command) .args(&command_line.args) .spawn() { Ok(child) => child, Err(_) => return Err(Error::CommandNotFound(command_line.command.to_string())), }; ...
code_fim
medium
{ "lang": "rust", "repo": "juanibiapina/lish-poc", "path": "/src/shell/eval.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> unsafe { libc::ioctl(0, libc::TIOCSCTTY, 1); } unistd::tcsetpgrp(0, pid).expect("tcsetpgrp failed"); unistd::execv(&(CString::new("/bin/ion").unwrap()), &[CString::new("ion").unwrap()]).expect("execv failed"); }<|fim_prefix|>// repo: mesalock-linux/mgetty path: /src/main.rs // Copyright (c)...
code_fim
hard
{ "lang": "rust", "repo": "mesalock-linux/mgetty", "path": "/src/main.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mesalock-linux/mgetty path: /src/main.rs // Copyright (c) 2017, The MesaLock Linux Project Contributors // All rights reserved. // // This work is licensed under the terms of the BSD 3-Clause License. // For a copy, see the LICENSE file. extern crate nix; extern crate libc; use nix::fcntl; us...
code_fim
medium
{ "lang": "rust", "repo": "mesalock-linux/mgetty", "path": "/src/main.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let pid = unistd::getpid(); unistd::setsid().expect("setsid failed"); open_tty(); ndelay_off(0); if unistd::dup2(0, 1).expect("dup2 1 failed") != 1 { panic!("dup2 failed"); } if unistd::dup2(0, 2).expect("dup2 2 failed") != 2 { panic!("dup2 failed")...
code_fim
hard
{ "lang": "rust", "repo": "mesalock-linux/mgetty", "path": "/src/main.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>/// Write a message to the buffer used to communicate with the host. You should /// never need to call this directly. pub fn write_message<U>(message: &U) -> i32 where U: serde::Serialize, { let buf = unsafe { &mut MESSAGE_BUFFER }; let message: Vec<u8> = bincode::serialize(message).unwrap(); ...
code_fim
hard
{ "lang": "rust", "repo": "TheRawMeatball/wasm_plugin", "path": "/guest/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Read a message from the buffer used to communicate with the host. You should /// never need to call this directly. pub fn read_message<T: serde::de::DeserializeOwned>() -> T { let buf = unsafe { &mut MESSAGE_BUFFER }; bincode::deserialize(buf).unwrap() } /// Write a message to the buffer used...
code_fim
hard
{ "lang": "rust", "repo": "TheRawMeatball/wasm_plugin", "path": "/guest/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TheRawMeatball/wasm_plugin path: /guest/src/lib.rs #![doc(html_root_url = "https://docs.rs/wasm_plugin_guest/0.1.0")] #![deny(missing_docs)] //! A low-ish level tool for easily writing WASM based plugins to be hosted by //! wasm_plugin_host. //! //! The goal of wasm_plugin is to make communicat...
code_fim
hard
{ "lang": "rust", "repo": "TheRawMeatball/wasm_plugin", "path": "/guest/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jjfiv/fastrank path: /src/random_forest.rs , RankingDataset}; use crate::evaluators::SetEvaluator; use crate::model::{ModelEnum, TreeNode, WeightedEnsemble}; use crate::normalizers::FeatureStats; use crate::sampling::DatasetSampling; use crate::stats; use crate::Scored; use crate::{FeatureId, In...
code_fim
hard
{ "lang": "rust", "repo": "jjfiv/fastrank", "path": "/src/random_forest.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut instance_feature: Vec<Scored<InstanceId>> = instances .iter() .cloned() .map(|i| Scored::new(dataset.get_feature_value(i, fid).unwrap_or(0.0), i)) .collect(); instance_feature.sort_unstable(); let scores: Vec<NotNan<f64>> = instance_feature.iter().map(|...
code_fim
hard
{ "lang": "rust", "repo": "jjfiv/fastrank", "path": "/src/random_forest.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jjfiv/fastrank path: /src/random_forest.rs r; use crate::model::{ModelEnum, TreeNode, WeightedEnsemble}; use crate::normalizers::FeatureStats; use crate::sampling::DatasetSampling; use crate::stats; use crate::Scored; use crate::{FeatureId, InstanceId}; use oorandom::Rand64; use ordered_float::N...
code_fim
hard
{ "lang": "rust", "repo": "jjfiv/fastrank", "path": "/src/random_forest.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: path0509/contracts path: /packages/valkyrie/src/campaign_manager/execute_msgs.rs use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use cosmwasm_std::{Decimal, Uint128, Binary}; use crate::common::Denom; #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] pub str...
code_fim
hard
{ "lang": "rust", "repo": "path0509/contracts", "path": "/packages/valkyrie/src/campaign_manager/execute_msgs.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] pub struct CampaignInstantiateMsg { pub governance: String, pub campaign_manager: String, pub admin: String, pub creator: String, pub config_msg: Binary, pub deposit_denom: Option<Denom>, pub deposit_amount:...
code_fim
hard
{ "lang": "rust", "repo": "path0509/contracts", "path": "/packages/valkyrie/src/campaign_manager/execute_msgs.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: YosiSF/EinsteinDB path: /causets/query_builder.rs locale); } } if let Some(types) = types { for (variable, value_type) in types { self.types.insert(variable, value_type); } } let mut causet_locales = BTreeMap::...
code_fim
hard
{ "lang": "rust", "repo": "YosiSF/EinsteinDB", "path": "/causets/query_builder.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn bind_instant(&mut self, var: &str, causet_locale: i64) -> &mut Self { self.causet_locales.insert(Variable::from_valid_name(var), causetq_TV::instant(causet_locale)); self } // pub fn bind_type(&mut self, var: &str, causet_locale_type: ValueType) -> &mut Self { // ...
code_fim
hard
{ "lang": "rust", "repo": "YosiSF/EinsteinDB", "path": "/causets/query_builder.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: YosiSF/EinsteinDB path: /causets/query_builder.rs <'a> Queryable for CausetQ<'a> { fn bind_causet_locales<T>(&self, causet_locales: T) -> Self{ CausetQ { query: self.query.clone(), causet_locales, types: self.types.clone(), store: self...
code_fim
hard
{ "lang": "rust", "repo": "YosiSF/EinsteinDB", "path": "/causets/query_builder.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn dereference_all(&self) -> String { format!("ALL[{}] -> | PATH: {:?} \n\t | ALL: {:?} \n\t | SIZE: {} ", self.all.len() - 1, self.all[self.all.len()-1].path, self.all[self.all.len()-1].all, self.all[self.all.len()-1].all.len()) } fn dereference_info(&self) -> String { ...
code_fim
hard
{ "lang": "rust", "repo": "MocaCDev/Learning-Rust", "path": "/hmm.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MocaCDev/Learning-Rust path: /hmm.rs use std::path::PathBuf; #[derive(Debug, Clone)] struct Info { path: PathBuf, all: Vec<Info> } #[derive(Debug)] enum FileErrors { FileNotExists(String) } #[allow(unreachable_patterns)] // For derefernece_error impl FileErrors { fn new_file_e...
code_fim
hard
{ "lang": "rust", "repo": "MocaCDev/Learning-Rust", "path": "/hmm.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: makoto-kg/rust_knock_100 path: /src/knocks/knock023.rs use super::knock020::*; use std::path::Path; use std::io::BufReader; use std::fs::File; use regex::Regex; <|fim_suffix|> let article: Article = serde_json::from_reader(reader).unwrap(); let result = sections(&article); println!("{:?...
code_fim
hard
{ "lang": "rust", "repo": "makoto-kg/rust_knock_100", "path": "/src/knocks/knock023.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let article: Article = serde_json::from_reader(reader).unwrap(); let result = sections(&article); println!("{:?}", result); }<|fim_prefix|>// repo: makoto-kg/rust_knock_100 path: /src/knocks/knock023.rs use super::knock020::*; use std::path::Path; use std::io::BufReader; use std::fs::File; use r...
code_fim
hard
{ "lang": "rust", "repo": "makoto-kg/rust_knock_100", "path": "/src/knocks/knock023.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>f.bits >> 6) & 0x01) != 0) } #[doc = "Bit 7 - SOF Received - R/WC"] #[inline(always)] pub fn sri(&self) -> SRI_R { SRI_R::new(((self.bits >> 7) & 0x01) != 0) } #[doc = "Bit 8 - DCSuspend - R/WC"] #[inline(always)] pub fn sli(&self) -> SLI_R { SLI_R::new(((se...
code_fim
hard
{ "lang": "rust", "repo": "Shock-1/teensy4-rs", "path": "/imxrt1062-pac/imxrt1062-usb1/src/usbsts.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Shock-1/teensy4-rs path: /imxrt1062-pac/imxrt1062-usb1/src/usbsts.rs = crate::R<u32, super::USBSTS>; #[doc = "Writer for register USBSTS"] pub type W = crate::W<u32, super::USBSTS>; #[doc = "Register USBSTS `reset()`'s with value 0"] impl crate::ResetValue for super::USBSTS { type Type = u3...
code_fim
hard
{ "lang": "rust", "repo": "Shock-1/teensy4-rs", "path": "/imxrt1062-pac/imxrt1062-usb1/src/usbsts.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: darkdarkfruit/url_encoded_data path: /examples/mutating_example.rs use url_encoded_data::UrlEncodedData; fn main() { // note: the library will not check the validity of the url, it just searchs for url-encoded-data, eg: string after first '?' and then s.trim_start('?') let url = "https:...
code_fim
medium
{ "lang": "rust", "repo": "darkdarkfruit/url_encoded_data", "path": "/examples/mutating_example.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // something like: https://google.com/?b=2&b=3&q=rust-lang&a=1&hello=world&vector=1&vector=2&whole=world&whole=%E4%B8%96%E7%95%8C println!("{}", q.to_final_string()); // https://google.com/?q=rust-lang&b=2&b=3&a=1&hello=world&vector=1&vector=2&whole=world&whole=%E4%B8%96%E7%95%8C println!...
code_fim
hard
{ "lang": "rust", "repo": "darkdarkfruit/url_encoded_data", "path": "/examples/mutating_example.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // q.keys() // performant assert_eq!(q.keys_of_original_order()[0].as_ref(), "q"); // something like: https://google.com/?b=2&b=3&q=rust-lang&a=1&hello=world&vector=1&vector=2&whole=world&whole=%E4%B8%96%E7%95%8C println!("{}", q.to_final_string()); // https://google.com/?q=rust-lang...
code_fim
hard
{ "lang": "rust", "repo": "darkdarkfruit/url_encoded_data", "path": "/examples/mutating_example.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn contains(&mut self, v: A) -> bool { let old_root = mem::replace(&mut self.root, TreeNode(TreeF::Empty)); let find_loc = find(old_root, &v); let result = match find_loc.here { TreeNode(TreeF::Empty) => false, TreeNode(TreeF::Branch { .. }) => true, ...
code_fim
hard
{ "lang": "rust", "repo": "bhamrick/rust_splay", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let old_root = mem::replace(&mut self.root, BitRangeNode::Empty); let zipper = find_index(old_root, index); let result = match zipper.here { BitRangeNode::Empty => None, BitRangeNode::Branch { here, .. } => Some(here), }; self.root = zip_tree...
code_fim
hard
{ "lang": "rust", "repo": "bhamrick/rust_splay", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bhamrick/rust_splay path: /src/main.rs }) = path.pop() { match direction { Direction::Left => { node = TreeAlgebra::combine(TreeF::Branch { val: val, left: left, ...
code_fim
hard
{ "lang": "rust", "repo": "bhamrick/rust_splay", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> struct SnakePlayer { body_parts: VecDeque<GameBlock>, set_grow: bool } enum Direction { UP, DOWN, LEFT, RIGHT } impl SnakePlayer { //Player movement done by popping tail and making new head fn move_player(&mut self, direction: &Direction) { match direction { ...
code_fim
hard
{ "lang": "rust", "repo": "AntoonBeres/Rust-Snake-sdl2", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AntoonBeres/Rust-Snake-sdl2 path: /src/main.rs extern crate sdl2; use sdl2::pixels::Color; use sdl2::event::Event; use sdl2::keyboard::Keycode; use sdl2::rect::Rect; use std::time::{Duration, Instant}; use std::collections::VecDeque; use rand::{thread_rng, Rng}; // Set game variables const BL...
code_fim
hard
{ "lang": "rust", "repo": "AntoonBeres/Rust-Snake-sdl2", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: connorskees/grass path: /crates/compiler/src/interner.rs use lasso::{Rodeo, Spur}; use std::cell::RefCell; use std::fmt::{self, Display}; thread_local!(static STRINGS: RefCell<Rodeo<Spur>> = RefCell::new(Rodeo::default())); #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Ord, PartialOrd)] p...
code_fim
hard
{ "lang": "rust", "repo": "connorskees/grass", "path": "/crates/compiler/src/interner.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // todo: no need for unsafe here pub fn resolve_ref<'a>(self) -> &'a str { unsafe { STRINGS.with(|interner| interner.as_ptr().as_ref().unwrap().resolve(&self.0)) } } } impl Display for InternedString { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { STRINGS.with...
code_fim
hard
{ "lang": "rust", "repo": "connorskees/grass", "path": "/crates/compiler/src/interner.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> bench_decode(c, "decode/inc", |input_len| { (1..=input_len).map(|x| x as u8).collect() }); } fn bench_decode_zeros(c: &mut Criterion) { bench_decode(c, "decode/zero", |input_len| { (1..=input_len).map(|_| 0u8).collect() }); } criterion_group!( benches, bench_encod...
code_fim
hard
{ "lang": "rust", "repo": "ajfrantz/stuff-it", "path": "/benches/cobs_performance.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ajfrantz/stuff-it path: /benches/cobs_performance.rs use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Throughput}; use stuff_it::cobs::{decode, encode}; const INPUT_SIZES: &[usize] = &[1, 32, 64, 256, 512, 768, 1024]; fn bench_encode(c: &mut Criterion, name: &str, input...
code_fim
hard
{ "lang": "rust", "repo": "ajfrantz/stuff-it", "path": "/benches/cobs_performance.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> /// tests for the presence of a few UID constants #[test] fn uids_constants_available() { use crate::uids::*; assert_eq!(EXPLICIT_VR_LITTLE_ENDIAN, "1.2.840.10008.1.2.1"); assert_eq!(VERIFICATION, "1.2.840.10008.1.1"); assert_eq!(HOT_IRON_PALETTE, "1.2.840.10008...
code_fim
hard
{ "lang": "rust", "repo": "Enet4/dicom-rs", "path": "/dictionary-std/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Enet4/dicom-rs path: /dictionary-std/src/lib.rs //! This crate implements standard DICOM dictionaries and constants. //! //! ## Run-time dictinaries //! //! The following modules provide definitions for dictionaries //! which can be queried during a program's lifetime: //! //! - [`data_element...
code_fim
medium
{ "lang": "rust", "repo": "Enet4/dicom-rs", "path": "/dictionary-std/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> use crate::tags::*; assert_eq!(PATIENT_NAME, Tag(0x0010, 0x0010)); assert_eq!(MODALITY, Tag(0x0008, 0x0060)); assert_eq!(PIXEL_DATA, Tag(0x7FE0, 0x0010)); assert_eq!(STATUS, Tag(0x0000, 0x0900)); } /// tests for the presence of a few UID constants #[tes...
code_fim
hard
{ "lang": "rust", "repo": "Enet4/dicom-rs", "path": "/dictionary-std/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> assert!(file.set_len(0).is_ok()); assert_eq!(file.metadata().unwrap().len(), 0); assert!(file.set_len(5).is_ok()); assert_eq!(file.metadata().unwrap().len(), 5); assert!(file.set_len(25).is_ok()); assert_eq!(file.metadata().unwrap().len(), 25); assert!(file.set_len(0).is_ok()); assert_e...
code_fim
medium
{ "lang": "rust", "repo": "khronosproject/wasi-test", "path": "/src/bin/std_fs_file_set_len.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: khronosproject/wasi-test path: /src/bin/std_fs_file_set_len.rs // { // "preopens": { // "fixtures": "fixtures" // } // } <|fim_suffix|> assert!(file.set_len(0).is_ok()); assert_eq!(file.metadata().unwrap().len(), 0); assert!(file.set_len(5).is_ok()); assert_eq!(file.meta...
code_fim
medium
{ "lang": "rust", "repo": "khronosproject/wasi-test", "path": "/src/bin/std_fs_file_set_len.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>table! { #[sql_name="labs_messages"] messages(message_id) { message_id -> Integer, from_user_id -> Integer, to_user_id -> Integer, in_reply_to -> Integer, message_state -> Integer, message_date -> Integer, message_subj -> Varchar, mes...
code_fim
hard
{ "lang": "rust", "repo": "qbit-org-ua/dots-wamp-api-server", "path": "/src/schema.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: qbit-org-ua/dots-wamp-api-server path: /src/schema.rs // This file is generated with `diesel print-schema` and edited with vim: // %s:labs_\([^ ,]*\) :#[sql_name="labs_\1"]\r \1: // %s:labs_\([^ ,]*\),:\1,: table! { #[sql_name="labs_cache"] cache(cache_key) { cache_key -> Var...
code_fim
hard
{ "lang": "rust", "repo": "qbit-org-ua/dots-wamp-api-server", "path": "/src/schema.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fabianschuiki/moore path: /src/vhdl/ty2/range.rs // Copyright (c) 2016-2021 Fabian Schuiki //! Dealing with types in an abstract manner. use std::fmt::{self, Display}; use std::ops::{Add, Sub}; pub use num::BigInt; use num::One; /// A directed range of values. /// /// `Range<T>` has the same...
code_fim
hard
{ "lang": "rust", "repo": "fabianschuiki/moore", "path": "/src/vhdl/ty2/range.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Return the direction of the range. /// /// # Example /// /// ``` /// use moore_vhdl::ty2::{IntegerRange, RangeDir}; /// /// let a = IntegerRange::ascending(0, 42); /// let b = IntegerRange::descending(42, 0); /// /// assert_eq!(a.dir(), RangeDir::To); //...
code_fim
hard
{ "lang": "rust", "repo": "fabianschuiki/moore", "path": "/src/vhdl/ty2/range.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Normalize expected_output let expected_output_wasm = wat::parse_str(expected_output).unwrap(); let expected_output_wat = wasmprinter::print_bytes(&expected_output_wasm).unwrap(); assert_eq!(expected_output_wat, output_wat); } } fn run_test(input: &str) -> Vec<u8> {...
code_fim
hard
{ "lang": "rust", "repo": "doytsujin/lunatic", "path": "/tests/patching.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: doytsujin/lunatic path: /tests/patching.rs // This test patches all WASM files in the ./patching folder and compares them to the expected output. // TODO: Pretty print diff errors. use std::path::{Path, PathBuf}; use std::fs::read_to_string; use lunatic::patching::patch; fn main() { let m...
code_fim
hard
{ "lang": "rust", "repo": "doytsujin/lunatic", "path": "/tests/patching.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn run_tests(tests: Vec<PathBuf>) { for test in tests { let test_content = read_to_string(&test).unwrap(); let input_expected_output: Vec<_> = test_content.split("EXPECTED-RESULT:").collect(); let input = input_expected_output.first().unwrap(); let expected_output = inp...
code_fim
hard
{ "lang": "rust", "repo": "doytsujin/lunatic", "path": "/tests/patching.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut h: HashMap<Vec<u8>, Bencode> = HashMap::new(); for &(ref k, ref v) in pairs { h.insert(k.clone(),v.clone()); } return h; } named!(bdict<&[u8], (HashMap<Vec<u8>,Bencode>)>, chain!(tag!("d") ~ kvs: many0!(pair!(bstring, bencode)) ~ tag!("e"...
code_fim
hard
{ "lang": "rust", "repo": "lobo84/bencode_parser", "path": "/src/parser/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lobo84/bencode_parser path: /src/parser/mod.rs use nom::*; use std::error::Error; use std::fs::File; use std::io::prelude::*; use std::path::Path; use std::collections::HashMap; use std::str; use std::env; use std::process::exit; #[derive(Clone,Debug,PartialEq)] pub enum Bencode { BInt(i64)...
code_fim
hard
{ "lang": "rust", "repo": "lobo84/bencode_parser", "path": "/src/parser/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kjvalencik/aoc-2020 path: /day-06/src/main.rs use aoc_common::*; fn parse_answers(input: &str) -> [bool; 26] { input.trim().chars().fold([false; 26], |mut acc, c| { acc[c as usize - 'a' as usize] = true; acc }) } fn parse_group(input: &str) -> Vec<[bool; 26]> { <|fim_suffix|> input .it...
code_fim
hard
{ "lang": "rust", "repo": "kjvalencik/aoc-2020", "path": "/day-06/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> count_groups(input, false, |x, y| x || y) } fn part2(input: &[Vec<[bool; 26]>]) -> usize { count_groups(input, true, |x, y| x && y) } fn main() -> Result<(), Box<dyn std::error::Error>> { let input = read_stdin()?; let input = input .trim() .split("\n\n") .map(parse_group) .collect::<Vec<_>>...
code_fim
hard
{ "lang": "rust", "repo": "kjvalencik/aoc-2020", "path": "/day-06/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: scrogson/franz path: /native/franz/src/atoms.rs rustler::atoms! { ok, error, pre_rebalance, <|fim_suffix|> assignments, beginning, end, stored, invalid, offset, topic, partition, committed, }<|fim_middle|> post_rebalance, poll_ready, revoke...
code_fim
easy
{ "lang": "rust", "repo": "scrogson/franz", "path": "/native/franz/src/atoms.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>lid, offset, topic, partition, committed, }<|fim_prefix|>// repo: scrogson/franz path: /native/franz/src/atoms.rs rustler::atoms! { ok, error, pre_rebalance, post_rebalance, poll_ready, revoke, assign, <|fim_middle|> assignments, beginning, end, ...
code_fim
easy
{ "lang": "rust", "repo": "scrogson/franz", "path": "/native/franz/src/atoms.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DTibbs/simon path: /src/util.rs use std::fmt::{self, Display}; #[derive(Debug, PartialEq, Eq)] pub enum Either<L, R> { Left(L), Right(R), } <|fim_suffix|>#[derive(Debug)] pub enum EitherOrBoth<L, R> { Either(Either<L, R>), Both(L, R), } #[derive(Debug, PartialEq, Eq)] pub enum...
code_fim
hard
{ "lang": "rust", "repo": "DTibbs/simon", "path": "/src/util.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Never { pub fn result_ok<T>(r: Result<T, Never>) -> T { match r { Ok(t) => t, Err(_) => unreachable!(), } } } impl Display for Never { fn fmt(&self, _f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match self { _ => unreacha...
code_fim
medium
{ "lang": "rust", "repo": "DTibbs/simon", "path": "/src/util.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> path.to_string_lossy().chars() .filter(|c| c.is_alphanumeric() || c.is_whitespace() || *c == '_') .collect::<String>() .split_whitespace() .collect::<Vec<&str>>() .join("_") .to_lowercase() }<|fim_prefix|>// repo: pnadon/snake_caser path: /src/...
code_fim
medium
{ "lang": "rust", "repo": "pnadon/snake_caser", "path": "/src/main.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pnadon/snake_caser path: /src/main.rs use std::{env, fs, path::Path}; fn main() { let args = env::args().collect::<Vec<String>>(); if args.len() < 2 { panic!("Incorrect number of parameters: specify a single path"); } for entry in args[1..].iter() { let path = Pa...
code_fim
medium
{ "lang": "rust", "repo": "pnadon/snake_caser", "path": "/src/main.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ze/rotmg-server-change path: /src/registry.rs use std::io; use winreg::{ enums::{HKEY_CURRENT_USER, KEY_WRITE, REG_BINARY}, RegKey, RegValue, }; pub const PROD_SERVERS: [&str; 26] = [ "USWest", "USWest2", "USWest3", "USWest4", "USSouth", "USSouth2", "USSouth3...
code_fim
hard
{ "lang": "rust", "repo": "ze/rotmg-server-change", "path": "/src/registry.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let null_terminated = value.to_owned() + "\u{0}"; let data = RegValue { vtype: REG_BINARY, bytes: null_terminated.into_bytes(), }; exalt.set_raw_value(name, &data)?; Ok(()) }<|fim_prefix|>// repo: ze/rotmg-server-change path: /src/registry.rs use std::io; use winreg::...
code_fim
hard
{ "lang": "rust", "repo": "ze/rotmg-server-change", "path": "/src/registry.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn get_server_value() -> io::Result<(String, RegValue)> { let hkcu = RegKey::predef(HKEY_CURRENT_USER); let exalt = hkcu.open_subkey(REGISTRY_PATH)?; for name in exalt.enum_values() { let (key, value) = name?; if key.starts_with("preferredServer") { return Ok((...
code_fim
medium
{ "lang": "rust", "repo": "ze/rotmg-server-change", "path": "/src/registry.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> , signature : b"u\0" as * const u8 as * const c_char , types : unsafe { & types_null as * const _ } , } , wl_message { name : b"failed\0" as * const u8 as * const c_char , signature : b"\0" as * const u8 as * const c_char , types : unsafe { & types_null as * const _ } , } , ] ; pub static mut zwlr_gamma_...
code_fim
hard
{ "lang": "rust", "repo": "pappgeri096/rust_snake", "path": "/game/target/debug/build/wayland-protocols-2efe24f781889194/out/wlr-gamma-control-v1_c_interfaces.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nickray/lpc55-pac path: /src/usart0/cfg.rs elf.w.bits = (self.w.bits & !(0x03 << 4)) | (((value as u32) & 0x03) << 4); self.w } } #[doc = "Number of stop bits appended to transmitted data. Only a single stop bit is required for received data.\n\nValue on reset: 0"] #[derive(Clone, Co...
code_fim
hard
{ "lang": "rust", "repo": "nickray/lpc55-pac", "path": "/src/usart0/cfg.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> variant as u8 != 0 } } #[doc = "Reader of field `AUTOADDR`"] pub type AUTOADDR_R = crate::R<bool, AUTOADDR_A>; impl AUTOADDR_R { #[doc = r"Get enumerated values variant"] #[inline(always)] pub fn variant(&self) -> AUTOADDR_A { match self.bits { false => AUTOADDR...
code_fim
hard
{ "lang": "rust", "repo": "nickray/lpc55-pac", "path": "/src/usart0/cfg.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut world = HitableList { spheres: Vec::new() }; // "the ground" world.spheres.push(Sphere { center: Vec3::new(0., -1000., 0.), radius: 1000., material: Material::Lambertian { albedo: Vec3::new(0.5, 0.5, 0.5) } }); // little spheres for a in -11..11 { for b in -11..11 { ...
code_fim
hard
{ "lang": "rust", "repo": "ajfrantz/in1weekend", "path": "/src/main.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ajfrantz/in1weekend path: /src/main.rs extern crate rand; extern crate rayon; mod camera; mod hitable; mod hitable_list; mod material; mod ray; mod sphere; mod vec3; use rand::prelude::*; use rayon::prelude::*; use self::camera::Camera; use self::hitable::Hitable; use self::hitable_list::Hita...
code_fim
hard
{ "lang": "rust", "repo": "ajfrantz/in1weekend", "path": "/src/main.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> let nx = 1920; let ny = 1080; let ns = 100; print!("P3\n{} {}\n255\n", nx, ny); let world = random_scene(); let lookfrom = Vec3::new(13., 2., 3.); let lookat = Vec3::new(0., 0., 0.); let up = Vec3::new(0., 1., 0.); let dist_to_focus = 10.0; let aperature = 0.1; ...
code_fim
hard
{ "lang": "rust", "repo": "ajfrantz/in1weekend", "path": "/src/main.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: romatthe/remoc path: /remoc_macro/src/method.rs //! Method parsing and generation. use proc_macro2::TokenStream; use quote::{quote, TokenStreamExt}; use syn::{ parenthesized, parse::{Parse, ParseStream}, punctuated::Punctuated, spanned::Spanned, token::Comma, Attribute, ...
code_fim
hard
{ "lang": "rust", "repo": "romatthe/remoc", "path": "/remoc_macro/src/method.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }