text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> for i in 0..1000usize { let repo = repo.clone(); handlers.push(tokio::task::spawn(async move { repo.fetch(i) })); // handlers.push(tokio::task::spawn_blocking(move || repo.fetch(i))); } join_all(handlers).await; println!("All threads finished."); }<|fim_prefix|>/...
code_fim
medium
{ "lang": "rust", "repo": "daCapricorn/sync-async-tracing-experiments", "path": "/src/routines.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: paulosuzart/transactions path: /src/contract.rs use cosmwasm_std::to_binary; use crate::state::ChargeId; use crate::state::Transaction; use crate::state::TRANS; use cosmwasm_std::{entry_point, Deps, Binary, DepsMut, Env, MessageInfo, Response, StdResult}; use crate::error::ContractError; use c...
code_fim
hard
{ "lang": "rust", "repo": "paulosuzart/transactions", "path": "/src/contract.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[entry_point] pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<Binary> { match msg { QueryMsg::GetCharge { id } => to_binary(&get_charge(deps, id)?), } } pub fn get_charge(deps: Deps, id: ChargeId) -> StdResult<Transaction> { let state = TRANS.load(deps.storage, id.as_...
code_fim
hard
{ "lang": "rust", "repo": "paulosuzart/transactions", "path": "/src/contract.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>per ISO 7816 specification, minimum value of F/D is 5"] #[inline(always)] pub fn divisor_value_2(self) -> &'a mut W { self.variant(DIVISOR_VALUE_A::DIVISOR_VALUE_2) } #[doc = "Invalid. As per ISO 7816 specification, minimum value of F/D is 5"] #[inline(always)] pub fn divisor_value_3(self)...
code_fim
hard
{ "lang": "rust", "repo": "rv32m1-rust/rv32m1_ri5cy-pac", "path": "/src/emvsim0/divisor.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rv32m1-rust/rv32m1_ri5cy-pac path: /src/emvsim0/divisor.rs #[doc = "Reader of register DIVISOR"] pub type R = crate::R<u32, super::DIVISOR>; #[doc = "Writer for register DIVISOR"] pub type W = crate::W<u32, super::DIVISOR>; #[doc = "Register DIVISOR `reset()`'s with value 0x0174"] impl crate::Re...
code_fim
hard
{ "lang": "rust", "repo": "rv32m1-rust/rv32m1_ri5cy-pac", "path": "/src/emvsim0/divisor.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cisen/sericum path: /src/ir/const_folding.rs use crate::{ basic_block::BasicBlockId, ir::{ builder::IRBuilder, function::Function, module::Module, opcode::{Instruction, Opcode}, remove_unreachable_block::RemoveUnreachableBlockOnFunction, va...
code_fim
hard
{ "lang": "rust", "repo": "cisen/sericum", "path": "/src/ir/const_folding.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<'a> ConstantFoldingOnFunction<'a> { fn fold_phi(&mut self) -> bool { let mut changed = false; let mut remove_list = vec![]; for &id in &self.cur_func.basic_blocks.order { let bb = &self.cur_func.basic_blocks.arena[id]; for &inst_id in &*bb.iseq_ref...
code_fim
hard
{ "lang": "rust", "repo": "cisen/sericum", "path": "/src/ir/const_folding.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn read_pci_u8(&self, _segment: u16, _bus: u8, device: u8, _function: u8, _offset: u16) -> u8 { unimplemented!() } fn read_pci_u16(&self, _segment: u16, _bus: u8, device: u8, _function: u8, _offset: u16) -> u16 { unimplemented!() } fn read_pci_u32(&self, _segment: u16, ...
code_fim
hard
{ "lang": "rust", "repo": "rust-osdev/acpi", "path": "/aml/src/test_utils.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-osdev/acpi path: /aml/src/test_utils.rs use crate::{parser::Propagate, AmlContext, AmlValue, Handler}; use alloc::boxed::Box; struct TestHandler; impl Handler for TestHandler { fn read_u8(&self, _address: usize) -> u8 { unimplemented!() } fn read_u16(&self, _address: u...
code_fim
hard
{ "lang": "rust", "repo": "rust-osdev/acpi", "path": "/aml/src/test_utils.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: HexColors60/llforth path: /lib/src/lib.rs extern crate rustyline; extern crate atty; extern crate libc; extern crate clap; use libc::c_char; use std::ffi::{CString, CStr}; use std::slice; use std::mem::transmute; use clap::{App, Arg}; mod reader; use reader::{Reader, Input}; <|fim_suffix|>#[n...
code_fim
hard
{ "lang": "rust", "repo": "HexColors60/llforth", "path": "/lib/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[no_mangle] pub extern fn read_word_from_reader(ptr: *mut Reader, inbuf_ptr: *mut c_char, max_len: i64) -> i64 { let mut _reader = unsafe { &mut *ptr }; let inbuf = unsafe { slice::from_raw_parts_mut(inbuf_ptr, max_len as usize) }; let input = _reader.read(); match input { Input::...
code_fim
hard
{ "lang": "rust", "repo": "HexColors60/llforth", "path": "/lib/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>// Deliberately does not store state for Wemos because their state is // temperamental and can be controlled by other apps which do not sync well // without polling pub struct WemoManager {} impl WemoManager { pub fn new() -> Self { // Check to see if ouimeaux is installed let output ...
code_fim
medium
{ "lang": "rust", "repo": "bridger-herman/led-foot", "path": "/src/wemo_manager.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bridger-herman/led-foot path: /src/wemo_manager.rs //! Manager for Belkin WeMo devices //! //! Uses Python library ouimeaux (https://github.com/iancmcc/ouimeaux) which is //! technically deprecated but works for these purposes. //! //! Assumes that you have the `wemo` command installed (pip3 ins...
code_fim
medium
{ "lang": "rust", "repo": "bridger-herman/led-foot", "path": "/src/wemo_manager.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> &self.prefix } } impl Actor for LightingImpl { type Context = Context<Self>; } use super::light::*; pub struct CreateLight { pub index: u8, pub name: String, } impl Message for CreateLight { type Result = Addr<LightImpl>; ...
code_fim
hard
{ "lang": "rust", "repo": "AnickaBurova/macro-bug", "path": "/manual.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AnickaBurova/macro-bug path: /manual.rs #![feature(prelude_import)] #![no_std] #[prelude_import] use std::prelude::v1::*; #[macro_use] extern crate std as std; #[macro_use] mod misc {} mod light { use crate::light_impl::*; use actix::prelude::*; pub struct Light { inner: Addr...
code_fim
hard
{ "lang": "rust", "repo": "AnickaBurova/macro-bug", "path": "/manual.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Conversion<u64, Seconds> for Days { fn conversion_factor() -> u64 { Hours::conversion_factor() * 24 } } #[derive(Default, Debug, PartialEq, Eq, Clone, Copy)] struct Hours(u64); impl Display for Hours { fn fmt(&self, f: &mut Formatter) -> fmt::Result { write!(f, "{}h", se...
code_fim
hard
{ "lang": "rust", "repo": "alilleybrinker/dcalc", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Ok(Hours(parse_duration(s, "hours", "h")?)) } } impl Conversion<u64, Seconds> for Hours { fn conversion_factor() -> u64 { Minutes::conversion_factor() * 60 } } #[derive(Default, Debug, PartialEq, Eq, Clone, Copy)] struct Minutes(u64); impl FromStr for Minutes { type Err ...
code_fim
hard
{ "lang": "rust", "repo": "alilleybrinker/dcalc", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alilleybrinker/dcalc path: /src/main.rs use anyhow::{anyhow, bail, Error, Result}; use std::default::Default; use std::env; use std::fmt::{self, Display, Formatter}; use std::ops::Not as _; use std::process::exit; use std::str::FromStr; const EXIT_FAILURE: i32 = 1; fn main() { if let Err(e...
code_fim
hard
{ "lang": "rust", "repo": "alilleybrinker/dcalc", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>extern "C" { pub fn TPM_Manufacture(firstTime: c_int) -> c_int; pub fn _plat__SetNvAvail(); pub fn _plat__Signal_PowerOn() -> c_int; pub fn _TPM_Init(); pub fn ExecuteCommand( requestSize: c_uint, request: *mut c_uchar, responseSize: *mut c_uint, respons...
code_fim
medium
{ "lang": "rust", "repo": "danielverkamp/crosvm", "path": "/tpm2-sys/src/lib.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: danielverkamp/crosvm path: /tpm2-sys/src/lib.rs // Copyright 2019 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. //! Bindings for the TPM2 simulator library. <|fim_suffix|>extern "C" { pub fn TPM_Manufacture(fi...
code_fim
medium
{ "lang": "rust", "repo": "danielverkamp/crosvm", "path": "/tpm2-sys/src/lib.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> if module.is_null() { return None; } let handle = libloaderapi::GetProcAddress( module, winuser::MAKEINTRESOURCEA(UXTHEME_SHOULDAPPSUSEDARKMODE_ORDINAL), ); if hand...
code_fim
hard
{ "lang": "rust", "repo": "r-o-b-o-t-o/winit", "path": "/src/platform_impl/windows/dark_mode.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: r-o-b-o-t-o/winit path: /src/platform_impl/windows/dark_mode.rs /// This is a simple implementation of support for Windows Dark Mode, /// which is inspired by the solution in https://github.com/ysc3839/win32-darkmode use std::ffi::OsStr; use std::os::windows::ffi::OsStrExt; use winapi::{ sh...
code_fim
hard
{ "lang": "rust", "repo": "r-o-b-o-t-o/winit", "path": "/src/platform_impl/windows/dark_mode.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // 布尔类型 // true false // 字符类型 // unicode 字符 四个字节 ‘’ 表示 // 单元类型 // () 作为一个值来占位,但是不占用内存 // 字符串类型 // 字符串字面量和字符串切片 } // 函数定义 fn add(a: i32, b: i32) -> i32 { // return 可以省略,表达式不加分号 a + b }<|fim_prefix|>// repo: VainJoker/Notes path: /Rust/basic.rs // 程序从此开始 // 对于typ...
code_fim
hard
{ "lang": "rust", "repo": "VainJoker/Notes", "path": "/Rust/basic.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: VainJoker/Notes path: /Rust/basic.rs // 程序从此开始 // 对于type-level的构造使用驼峰命名法,对于value-level的构造使用蛇形命名法. fn main() { // 使用let声明变量,默认不可变 let a = 0; // 可以使用类型推断,mut可变 let mut b = 1; // 默认整形为i32,可以显示指定类型 let c: i32 = 2; // 语句以;结尾,不可以省略 // println!是宏调用,{}是占位符,可以使用多个占位符 /...
code_fim
medium
{ "lang": "rust", "repo": "VainJoker/Notes", "path": "/Rust/basic.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // 字符类型 // unicode 字符 四个字节 ‘’ 表示 // 单元类型 // () 作为一个值来占位,但是不占用内存 // 字符串类型 // 字符串字面量和字符串切片 } // 函数定义 fn add(a: i32, b: i32) -> i32 { // return 可以省略,表达式不加分号 a + b }<|fim_prefix|>// repo: VainJoker/Notes path: /Rust/basic.rs // 程序从此开始 // 对于type-level的构造使用驼峰命名法,对于value-level...
code_fim
hard
{ "lang": "rust", "repo": "VainJoker/Notes", "path": "/Rust/basic.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: imorph/vector path: /src/api/schema/components/mod.rs (Debug, Clone, Interface)] #[graphql( field(name = "name", type = "String"), field(name = "component_type", type = "String") )] pub enum Component { Source(source::Source), Transform(transform::Transform), Sink(sink::Sink)...
code_fim
hard
{ "lang": "rust", "repo": "imorph/vector", "path": "/src/api/schema/components/mod.rs", "mode": "psm", "license": "MPL-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let filter = ComponentsFilter { name: Some(vec![filter::StringFilter { equals: Some("gen1".to_string()), ..Default::default() }]), component_kind: Some(vec![filter::EqualityFilter { equals: Some(ComponentKind::Sour...
code_fim
hard
{ "lang": "rust", "repo": "imorph/vector", "path": "/src/api/schema/components/mod.rs", "mode": "spm", "license": "MPL-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: imorph/vector path: /src/api/schema/components/mod.rs ig::Config, filter_check, }; use async_graphql::{Enum, InputObject, Interface, Object, Subscription}; use lazy_static::lazy_static; use std::{ cmp, collections::{HashMap, HashSet}, }; use tokio_stream::{wrappers::BroadcastStream, ...
code_fim
hard
{ "lang": "rust", "repo": "imorph/vector", "path": "/src/api/schema/components/mod.rs", "mode": "psm", "license": "MPL-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[macro_export] macro_rules! apply_string_creator { ($data_type: expr, $creator: ident, $creator_fn: ident, $display_name: expr, $arguments: expr) => {{ match $data_type { DataType::Utf8 => $creator::<String>::$creator_fn($display_name, $arguments), other => Err(ErrorCo...
code_fim
hard
{ "lang": "rust", "repo": "alvarlaigna/datafuse", "path": "/common/functions/src/aggregates/macros.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[macro_export] macro_rules! apply_numeric_creator_with_largest_type { ($data_type: expr, $creator: ident, $creator_fn: ident, $display_name: expr, $arguments: expr) => {{ match $data_type { DataType::UInt8 => $creator::<u8, u64>::$creator_fn($display_name, $arguments), ...
code_fim
hard
{ "lang": "rust", "repo": "alvarlaigna/datafuse", "path": "/common/functions/src/aggregates/macros.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alvarlaigna/datafuse path: /common/functions/src/aggregates/macros.rs // Copyright 2020 Datafuse Labs. // // 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 // // ht...
code_fim
hard
{ "lang": "rust", "repo": "alvarlaigna/datafuse", "path": "/common/functions/src/aggregates/macros.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: matsutake-eg/atcoder path: /rust/abc189/src/bin/d.rs #![allow(unused_imports)] use itertools::Itertools; use itertools_num::ItertoolsNum as _; use num_integer::*; use petgraph::*; use proconio::marker::*; use std::cmp::*; use std::collections::*; use std::f64::consts::*; // CAUTION: fastout has...
code_fim
medium
{ "lang": "rust", "repo": "matsutake-eg/atcoder", "path": "/rust/abc189/src/bin/d.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn dfs(s: &[String]) -> usize { let l = s.len(); if l == 0 { return 1; } dfs(&s[..(l - 1)]) + match s[l - 1].as_str() { "OR" => 1 << l, _ => 0, } }<|fim_prefix|>// repo: matsutake-eg/atcoder path: /rust/abc189/src/bin/d.rs #![allow(unused_i...
code_fim
hard
{ "lang": "rust", "repo": "matsutake-eg/atcoder", "path": "/rust/abc189/src/bin/d.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aidan-coward/rust path: /project_euler/problem_9/src/main.rs fn main() { let mut perf_squares: Vec<u32> = Vec::new(); for c in 1..1000 { perf_squares.push(c*c); } <|fim_suffix|>b*b) as f32).sqrt() as u32) + a + b == 1000 { println!("a: {}, b: {}, c: {}", a, ...
code_fim
medium
{ "lang": "rust", "repo": "aidan-coward/rust", "path": "/project_euler/problem_9/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>b*b) as f32).sqrt() as u32) + a + b == 1000 { println!("a: {}, b: {}, c: {}", a, b, (((a*a + b*b) as f32).sqrt() as u32)); println!("{}", (((a*a + b*b) as f32).sqrt() as u32) * a * b); } } } }<|fim_prefix|>// repo: aidan-coward/rust path: /project_e...
code_fim
medium
{ "lang": "rust", "repo": "aidan-coward/rust", "path": "/project_euler/problem_9/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> rng.gen_range(1..100); println!("{}", b); }<|fim_prefix|>// repo: amm834/rust-lang-the-complete-beginner-guide path: /src/random.rs use rand::{thread_rng, Rng}; pub fn run() { <|fim_middle|> let mut rng = thread_rng(); let a: u32 = rng.gen(); println!("{}", a); let b: u32 =
code_fim
medium
{ "lang": "rust", "repo": "amm834/rust-lang-the-complete-beginner-guide", "path": "/src/random.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>g.gen(); println!("{}", a); let b: u32 = rng.gen_range(1..100); println!("{}", b); }<|fim_prefix|>// repo: amm834/rust-lang-the-complete-beginner-guide path: /src/random.rs use rand::{thread_rng, Rng}; pub fn run() { <|fim_middle|> let mut rng = thread_rng(); let a: u32 = rn
code_fim
easy
{ "lang": "rust", "repo": "amm834/rust-lang-the-complete-beginner-guide", "path": "/src/random.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: amm834/rust-lang-the-complete-beginner-guide path: /src/random.rs use rand::{thread_rng, Rng}; pub fn run() { let mut rng = thread_rng(); let a: u32 = rn<|fim_suffix|> rng.gen_range(1..100); println!("{}", b); }<|fim_middle|>g.gen(); println!("{}", a); let b: u32 =
code_fim
easy
{ "lang": "rust", "repo": "amm834/rust-lang-the-complete-beginner-guide", "path": "/src/random.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /third_party/rust_crates/vendor/crypto-bigint-0.3.2/src/limb/bit_xor.rs //! Limb bit xor operations. use super::Limb; use core::ops::BitXor; impl Limb { /// Calculates `a ^ b`. pub const fn bitxor(self, rhs: Self) -> Self { Limb(self.0 ^ rhs.0) } } <...
code_fim
easy
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/third_party/rust_crates/vendor/crypto-bigint-0.3.2/src/limb/bit_xor.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn bitxor(self, rhs: Self) -> Self::Output { self.bitxor(rhs) } }<|fim_prefix|>// repo: gnoliyil/fuchsia path: /third_party/rust_crates/vendor/crypto-bigint-0.3.2/src/limb/bit_xor.rs //! Limb bit xor operations. use super::Limb; use core::ops::BitXor; impl Limb { /// Calculates `a ^...
code_fim
easy
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/third_party/rust_crates/vendor/crypto-bigint-0.3.2/src/limb/bit_xor.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: eribertto/formatted_print path: /src/main.rs // all about formatted print syntax // https://doc.rust-lang.org/std/fmt/index.html fn main() { // in general the {} will be auto replaced with any arguments. These will be stringified. println!("{} days", 31); // number is i32 by default println!(...
code_fim
hard
{ "lang": "rust", "repo": "eribertto/formatted_print", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // try to print the struct // println!("This struct `{}` won't print...", Structure(3)); println!("This special formatter can now print {:?}!", Structure(3)); }<|fim_prefix|>// repo: eribertto/formatted_print path: /src/main.rs // all about formatted print syntax // https://doc.rust-lang.org/std/fmt/...
code_fim
medium
{ "lang": "rust", "repo": "eribertto/formatted_print", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // you can right-align text with specified width. this will output spaces or depending on the specified width println!("space padding {number:>width$}", number=1, width=6); println!("zero padding {number:>0width$}", number=1, width=6); println!("My name is {0}, {1} {0}", "Bond", "James"); // create ...
code_fim
medium
{ "lang": "rust", "repo": "eribertto/formatted_print", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: EmbarkStudios/tonic path: /examples/src/json-codec/common.rs //! This module defines common request/response types as well as the JsonCodec that is used by the //! json.helloworld.Greeter service which is defined manually (instead of via proto files) by the //! `build_json_codec_service` functio...
code_fim
medium
{ "lang": "rust", "repo": "EmbarkStudios/tonic", "path": "/examples/src/json-codec/common.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug)] pub struct JsonDecoder<U>(PhantomData<U>); impl<U: serde::de::DeserializeOwned> Decoder for JsonDecoder<U> { type Item = U; type Error = Status; fn decode(&mut self, buf: &mut DecodeBuf<'_>) -> Result<Option<Self::Item>, Self::Error> { if !buf.has_remaining() { ...
code_fim
hard
{ "lang": "rust", "repo": "EmbarkStudios/tonic", "path": "/examples/src/json-codec/common.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jianantian/polygon-rs path: /src/base/vector.rs use super::EPSILON; use std::iter::Sum; use std::fmt; use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign}; use wasm_bindgen::prelude::*; #[wasm_bindgen] #[derive(Debug, Clone, PartialEq)] pub struct Vector2 { x:...
code_fim
hard
{ "lang": "rust", "repo": "jianantian/polygon-rs", "path": "/src/base/vector.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl fmt::Display for Vector2 { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "({}, {})", self.x, self.y) } } // use macro to reuse code impl Neg for Vector2 { type Output = Vector2; fn neg(self) -> Self::Output { Vector2 { x: -self.x, ...
code_fim
hard
{ "lang": "rust", "repo": "jianantian/polygon-rs", "path": "/src/base/vector.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> bye::say_bye(); bye::main(); }<|fim_prefix|>// repo: l1lhu1hu1/rust-practice path: /else/relearn-module/src/sayonara.rs use crate::bye; // 下のコードはエラーになる // use relearn_module::bye; pub fn say_sayona<|fim_middle|>ra() { println!("sayonara called");
code_fim
easy
{ "lang": "rust", "repo": "l1lhu1hu1/rust-practice", "path": "/else/relearn-module/src/sayonara.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: l1lhu1hu1/rust-practice path: /else/relearn-module/src/sayonara.rs use crate::bye; // 下のコードはエラーになる // use<|fim_suffix|>ra() { println!("sayonara called"); bye::say_bye(); bye::main(); }<|fim_middle|> relearn_module::bye; pub fn say_sayona
code_fim
easy
{ "lang": "rust", "repo": "l1lhu1hu1/rust-practice", "path": "/else/relearn-module/src/sayonara.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_challenge_result(12, 2, "51249") }<|fim_prefix|>// repo: jjmark15/advent-of-code-2020 path: /tests/challenges/day_12.rs use crate::challenges::assert_challenge_result; <|fim_middle|>#[test] fn part_1() { assert_challenge_result(12, 1, "757") } #[test] fn part_2() {
code_fim
medium
{ "lang": "rust", "repo": "jjmark15/advent-of-code-2020", "path": "/tests/challenges/day_12.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_challenge_result(12, 1, "757") } #[test] fn part_2() { assert_challenge_result(12, 2, "51249") }<|fim_prefix|>// repo: jjmark15/advent-of-code-2020 path: /tests/challenges/day_12.rs use crate::challenges::assert_challenge_result; <|fim_middle|>#[test] fn part_1() {
code_fim
easy
{ "lang": "rust", "repo": "jjmark15/advent-of-code-2020", "path": "/tests/challenges/day_12.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jjmark15/advent-of-code-2020 path: /tests/challenges/day_12.rs use crate::challenges::assert_challenge_result; <|fim_suffix|> assert_challenge_result(12, 1, "757") } #[test] fn part_2() { assert_challenge_result(12, 2, "51249") }<|fim_middle|>#[test] fn part_1() {
code_fim
easy
{ "lang": "rust", "repo": "jjmark15/advent-of-code-2020", "path": "/tests/challenges/day_12.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lucas-miranda/tree_decorator path: /tests/test_no_handler_output.rs use tree_decorator::{ close_tree_item, decorator::Entry, DecoratorBuilder, tree_item }; #[test] fn test_no_handler_output() { DecoratorBuilder::default() .build(); <|fim_suffix|> ass...
code_fim
hard
{ "lang": "rust", "repo": "lucas-miranda/tree_decorator", "path": "/tests/test_no_handler_output.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!("Root", format!("{}Root", tree_item!(block))); assert_eq!("├ Item A", format!("{}Item A", tree_item!(entry))); assert_eq!("│ Small Description", format!("{}Small Description", tree_item!(entry: Entry::None))); assert_eq!("┊- Other Small Description", format!("{}Other Small Des...
code_fim
medium
{ "lang": "rust", "repo": "lucas-miranda/tree_decorator", "path": "/tests/test_no_handler_output.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let res = self.db.connect().ok().and_then(|mut connection| { diesel::insert_into(songs::table) .values(&self.new_songs) .execute(&mut *connection) // TODO https://github.com/diesel-rs/diesel/issues/1822 .ok() }); if res.is_none() { error!("Could not insert new songs in database"); ...
code_fim
hard
{ "lang": "rust", "repo": "agersant/polaris", "path": "/src/app/index/update/inserter.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl Inserter { pub fn new(db: DB, receiver: Receiver<Item>) -> Self { let new_directories = Vec::with_capacity(INDEX_BUILDING_INSERT_BUFFER_SIZE); let new_songs = Vec::with_capacity(INDEX_BUILDING_INSERT_BUFFER_SIZE); Self { receiver, new_directories, new_songs, db, } } pub fn ins...
code_fim
hard
{ "lang": "rust", "repo": "agersant/polaris", "path": "/src/app/index/update/inserter.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: agersant/polaris path: /src/app/index/update/inserter.rs use crossbeam_channel::Receiver; use diesel::prelude::*; use log::error; use crate::db::{directories, songs, DB}; const INDEX_BUILDING_INSERT_BUFFER_SIZE: usize = 1000; // Insertions in each transaction #[derive(Debug, Insertable)] #[di...
code_fim
hard
{ "lang": "rust", "repo": "agersant/polaris", "path": "/src/app/index/update/inserter.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: samrg472/rru path: /crates/renamer/src/archive_org.rs use crate::Report; use rru_common::XmlDoc; use std::{ fs, io::{Read, Write}, mem, path::{Path, PathBuf}, sync::Arc, sync::Mutex, }; use termcolor::{Color, ColorSpec, StandardStream, WriteColor}; pub struct ArchiveOrgC...
code_fim
hard
{ "lang": "rust", "repo": "samrg472/rru", "path": "/crates/renamer/src/archive_org.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut stdout = self.stdout.lock().unwrap(); stdout .set_color(ColorSpec::new().set_fg(Some(status_color))) .unwrap(); write!(stdout, "{}", status).unwrap(); stdout.reset().unwrap(); match new { Some(new) => { wri...
code_fim
hard
{ "lang": "rust", "repo": "samrg472/rru", "path": "/crates/renamer/src/archive_org.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn from_f32(id: u16, val: f32) -> Attribute { let mut result = Attribute { id: id, value: vec!(), }; result.value.write_f32::<LE>(val).ok().expect("Error writing f32 value to attribute."); result } pub fn from_str(id: u16, val: &str) -> Attribute { Attribute { ...
code_fim
hard
{ "lang": "rust", "repo": "zusitools/rust_zusi_tcp", "path": "/src/node.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zusitools/rust_zusi_tcp path: /src/node.rs extern crate byteorder; use std::io::Cursor; use std::io::Read; use std::string::FromUtf8Error; use self::byteorder::{WriteBytesExt, ReadBytesExt}; type LE = self::byteorder::LittleEndian; pub struct Node { pub id: u16, pub attributes: Vec<Attrib...
code_fim
hard
{ "lang": "rust", "repo": "zusitools/rust_zusi_tcp", "path": "/src/node.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn from_u32(id: u16, val: u32) -> Attribute { let mut result = Attribute { id: id, value: vec!(), }; result.value.write_u32::<LE>(val).ok().expect("Error writing u32 value to attribute."); result } pub fn from_i16(id: u16, val: i16) -> Attribute { let mut result ...
code_fim
hard
{ "lang": "rust", "repo": "zusitools/rust_zusi_tcp", "path": "/src/node.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/fonts/tools/manifest_generator/src/font_sets.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. //! Deserialization for pairs of `.all_fonts.json` and ...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/fonts/tools/manifest_generator/src/font_sets.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> let all_fonts_contents = json!(["a.ttf", "b.ttf", "c.ttf", "d.ttf", "e.ttf", "f.ttf"]).to_string(); let mut all_fonts_file = NamedTempFile::new()?; all_fonts_file.write_all(all_fonts_contents.as_bytes())?; let local_fonts_contents = json!(["a.ttf", "b.ttf", "c....
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/fonts/tools/manifest_generator/src/font_sets.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> /// Creates a new `FontSets` collection from a map of font file names to [`FontSet`] values, /// as generated in [`FontSets::load_from_all_and_local_paths`]. /// /// _Visible for tests only._ pub(crate) fn new(map: BTreeMap<String, FontSet>) -> Self { Self { map } } pu...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/fonts/tools/manifest_generator/src/font_sets.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: FrancisMurillo/bevy_ggrs path: /src/lib.rs //! bevy_ggrs is a bevy plugin for the P2P rollback networking library GGRS. #![forbid(unsafe_code)] // let us try use bevy::{ ecs::schedule::{IntoSystemDescriptor, ShouldRun, Stage}, prelude::*, reflect::{FromType, GetTypeRegistration}, };...
code_fim
hard
{ "lang": "rust", "repo": "FrancisMurillo/bevy_ggrs", "path": "/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Adds the given `ggrs::P2PSession` to your app. fn with_p2p_session(&mut self, sess: P2PSession) -> &mut Self; /// Adds the given `ggrs::P2PSpectatorSession` to your app. fn with_p2p_spectator_session(&mut self, sess: P2PSpectatorSession) -> &mut Self; /// Sets the run criteria f...
code_fim
hard
{ "lang": "rust", "repo": "FrancisMurillo/bevy_ggrs", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Vengarioth/midibase path: /src/obs/obs_websocket.rs use websocket::{ClientBuilder, Message, sync::Writer}; use anyhow::Error; use std::net::TcpStream; use crossbeam_channel::unbounded; use super::api::*; pub struct ObsWebsocket { receiver: crossbeam_channel::Receiver<websocket::OwnedMessag...
code_fim
hard
{ "lang": "rust", "repo": "Vengarioth/midibase", "path": "/src/obs/obs_websocket.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let request = SetCurrentSceneRequest::new(scene_name.into(), message_id); let serialized = serde_json::to_string(&request)?; self.writer.send_message(&Message::text(serialized))?; Ok(()) } pub fn poll(&self) -> Option<String> { if let Ok(message) = self.re...
code_fim
hard
{ "lang": "rust", "repo": "Vengarioth/midibase", "path": "/src/obs/obs_websocket.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: creativcoder/forest path: /utils/bitfield/src/iter/combine.rs // Copyright 2020 ChainSafe Systems // SPDX-License-Identifier: Apache-2.0, MIT //! Combining two range iterators into a single new range iterator. //! //! This file contains the inner workings of the `BitField` combinators like //! ...
code_fim
hard
{ "lang": "rust", "repo": "creativcoder/forest", "path": "/utils/bitfield/src/iter/combine.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Self::advance(rhs, lhs) } fn advance_lhs_tail(&mut self, lhs: Range<usize>) -> Option<Range<usize>> { // the symmetric difference of a range and an empty range is just that range Some(lhs) } fn advance_rhs_tail(&mut self, rhs: Range<usize>) -> Option<Range<usize>>...
code_fim
hard
{ "lang": "rust", "repo": "creativcoder/forest", "path": "/utils/bitfield/src/iter/combine.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: danielspang/AoC2018 path: /aoc1_2/src/main.rs use std::collections::HashSet; use std::io::{self, BufRead}; fn main() { let stdin = io::stdin(); let lines = stdin .lock() .lines() <|fim_suffix|> *sum += x; Some(*sum) }).scan(HashSet::n...
code_fim
medium
{ "lang": "rust", "repo": "danielspang/AoC2018", "path": "/aoc1_2/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> *sum += x; Some(*sum) }).scan(HashSet::new(), |set, x| match set.contains(&x) { true => Some(Some(x)), false => { set.insert(x); Some(None) } }).filter(Option::is_some); println!("{}", iter.next...
code_fim
medium
{ "lang": "rust", "repo": "danielspang/AoC2018", "path": "/aoc1_2/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Based on https://github.com/rustwasm/wasm-bindgen/blob/603d5742eeca2a7a978f13614de9282229d1835e/examples/request-animation-frame/src/lib.rs let f = Rc::new(RefCell::new(None)); let g = f.clone(); *g.borrow_mut() = Some(Closure::wrap(Box::new(move || { run_for_milliseconds(MILLI...
code_fim
hard
{ "lang": "rust", "repo": "Giovan/lumen", "path": "/lumen_web/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Giovan/lumen path: /lumen_web/src/lib.rs #![deny(warnings)] pub mod document; pub mod element; pub mod event; pub mod html_form_element; pub mod html_input_element; pub mod math; pub mod node; pub mod wait; pub mod window; use std::any::Any; use std::cell::RefCell; use std::rc::Rc; use wasm_b...
code_fim
hard
{ "lang": "rust", "repo": "Giovan/lumen", "path": "/lumen_web/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> atom_unchecked("error") } fn ok() -> Term { atom_unchecked("ok") } fn ok_tuple(process: &Process, value: Box<dyn Any>) -> Result<Term, Alloc> { let ok = ok(); let resource_term = process.resource(value)?; process.tuple_from_slice(&[ok, resource_term]) } fn option_to_ok_tuple_or_err...
code_fim
hard
{ "lang": "rust", "repo": "Giovan/lumen", "path": "/lumen_web/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: truchi/snake-rs path: /src/physics/path.rs use super::{Moving, PathFragment, Point}; use std::time::Duration; /// A `Path` type to represent the progress along a sequence of `PathFragment`. #[derive(Copy, Clone, PartialEq, Debug)] pub struct Path<T: Iterator<Item = PathFragment>> { /// The ...
code_fim
hard
{ "lang": "rust", "repo": "truchi/snake-rs", "path": "/src/physics/path.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn new() { let fragments = fragments_data(); let path = Path::new(fragments.iter().cloned()); assert_eq!(path.position, Point::new(0.0, 0.0)); assert_eq!(path.current, Some(fragments[0])); // NOTE: std::iter::Cloned does not impl PartialEq, ... ...
code_fim
hard
{ "lang": "rust", "repo": "truchi/snake-rs", "path": "/src/physics/path.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub struct LightSource { pub position: Vector4f, pub ambient: Vector3f, pub diffuse: Vector3f, pub specular: Vector3f, } pub struct Material { pub ambient: Vector3f, pub diffuse: Vector3f, pub specular: Vector3f, pub shininess: f32, }<|fim_prefix|>// repo: dennisss/dacha ...
code_fim
easy
{ "lang": "rust", "repo": "dennisss/dacha", "path": "/pkg/graphics/src/lighting.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dennisss/dacha path: /pkg/graphics/src/lighting.rs use math::matrix::{Vector3f, Vector4f}; // These should match the shaders <|fim_suffix|> pub ambient: Vector3f, pub diffuse: Vector3f, pub specular: Vector3f, } pub struct Material { pub ambient: Vector3f, pub diffuse: Vect...
code_fim
medium
{ "lang": "rust", "repo": "dennisss/dacha", "path": "/pkg/graphics/src/lighting.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub const MAX_LIGHTS: usize = 4; pub struct LightSource { pub position: Vector4f, pub ambient: Vector3f, pub diffuse: Vector3f, pub specular: Vector3f, } pub struct Material { pub ambient: Vector3f, pub diffuse: Vector3f, pub specular: Vector3f, pub shininess: f32, }<|fi...
code_fim
easy
{ "lang": "rust", "repo": "dennisss/dacha", "path": "/pkg/graphics/src/lighting.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ddboline/programming_tests path: /rust/project_euler/src/large_sum.rs use std::fs::File; use std::io::BufReader; use std::io::prelude::*; #[derive(Debug)] struct LargeSum { v: Vec<u8>, } impl LargeSum { fn new() -> LargeSum { LargeSum { v: Vec::new() } } fn from_string...
code_fim
hard
{ "lang": "rust", "repo": "ddboline/programming_tests", "path": "/rust/project_euler/src/large_sum.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let sum = b.lines().fold(LargeSum::new(), |s, l| { s.add(&LargeSum::from_string(l.unwrap())) }); sum.get_first_ten_digits() } #[test] fn test() { assert_eq!(large_sum(), "5537376230"); }<|fim_prefix|>// repo: ddboline/programming_tests path: /rust/project_euler/src/large_sum.rs u...
code_fim
hard
{ "lang": "rust", "repo": "ddboline/programming_tests", "path": "/rust/project_euler/src/large_sum.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: WilsonGiese/restmote-control-rs path: /keyboard/src/keyboard.rs ///! Abstraction over the `CGEvents` lib to route virtual keyboard presses to an application using ///! its pid use core_graphics::event::CGEvent; use core_graphics::event_source::{CGEventSource,CGEventSourceStateID}; use super::{...
code_fim
hard
{ "lang": "rust", "repo": "WilsonGiese/restmote-control-rs", "path": "/keyboard/src/keyboard.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Amount of time the thread will sleep before posting a keyboard event. /// This isn't required according to any documentation for the `CGEvents` API, but without this /// some events posted do not appear to make it to the target application (pid). Tuning seems /// required for individua...
code_fim
hard
{ "lang": "rust", "repo": "WilsonGiese/restmote-control-rs", "path": "/keyboard/src/keyboard.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mathw/adventofcode path: /aoc2017/day22/src/grid.rs use std::collections::HashMap; use std::str::FromStr; /// A coordinate /// We consider north to be -y, south to be +y, east to be +x, west to be -x #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct Coord { x: isize, y: isiz...
code_fim
hard
{ "lang": "rust", "repo": "mathw/adventofcode", "path": "/aoc2017/day22/src/grid.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl FromStr for Grid { type Err = (); fn from_str(s: &str) -> Result<Grid, Self::Err> { let mut map = HashMap::new(); for (y, line) in s.lines().enumerate() { for (x, cell) in line.chars().enumerate() { match cell { '#' => map.inser...
code_fim
hard
{ "lang": "rust", "repo": "mathw/adventofcode", "path": "/aoc2017/day22/src/grid.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut expected_map = HashMap::new(); expected_map.insert(Coord::new(0, 0), NodeState::Infected); expected_map.insert(Coord::new(1, 0), NodeState::Clean); expected_map.insert(Coord::new(0, 1), NodeState::Clean); expected_map.insert(Coord::new(1, 1), NodeState::Infe...
code_fim
hard
{ "lang": "rust", "repo": "mathw/adventofcode", "path": "/aoc2017/day22/src/grid.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> generate_conditional_branch(program, ast, fnc, &cond); } Statement::Loop(ident, from, to, body) => { generate_expr(program, &ast, fnc, &from); if let Some(_) = program.data.global_symbols.get(&ident.item) { panic!("Don't use a global in a loop"); } else { // loop index var fnc...
code_fim
hard
{ "lang": "rust", "repo": "Nyrox/motokigo", "path": "/src/compiler/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Nyrox/motokigo path: /src/compiler/mod.rs use crate::{ast::*, vm::*}; pub mod program_data; pub mod resolve_types; use program_data::{FuncMeta, ProgramData, SymbolMeta}; pub fn compile(mut ast: Program) -> VMProgram { let mut program_data = ProgramData::new(); resolve_types::resolve(&mut a...
code_fim
hard
{ "lang": "rust", "repo": "Nyrox/motokigo", "path": "/src/compiler/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for i in 0..(t.as_ref().unwrap().size() / 4) { program .code .push(MemoryCell::with_data(OpCode::Load4, (so + (i * 4)) as u16)) } } TypeKind::Vector(_, _)...
code_fim
hard
{ "lang": "rust", "repo": "Nyrox/motokigo", "path": "/src/compiler/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let opt = Opt::from_args(); let source = fs::read_to_string(&opt.input).expect("Invalid input file path."); if let Some(asm) = compile(&source, opt) { fs::write("main.asm", asm).expect("Fail to write the output assembly file."); Command::new("ml64") .stdout(Stdio::i...
code_fim
hard
{ "lang": "rust", "repo": "pastchick3/eac-compiler", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pastchick3/eac-compiler path: /src/main.rs use eac_compiler::{compile, Opt}; use std::fs; use std::process::{Command, Stdio}; use structopt::StructOpt; <|fim_suffix|> let opt = Opt::from_args(); let source = fs::read_to_string(&opt.input).expect("Invalid input file path."); if let So...
code_fim
hard
{ "lang": "rust", "repo": "pastchick3/eac-compiler", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Delete text from the editor /// /// Can panic on unwrap if pos is not valid. /// Can panic if pos+len is invalid. /// Use valid_index to check both beforehand! /// Can also panic if all pieces have length zero. /// Check this with `len > 0 && valid_index(pos + len)`. pu...
code_fim
hard
{ "lang": "rust", "repo": "ohomburg/avian", "path": "/src/pt.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ohomburg/avian path: /src/pt.rs use std::fmt; pub struct PieceTable { /// Editor contents buffer. This only ever grows, unless garbage-collected. /// Unlike usual piece-table implementations, this one only uses one buffer. /// This simplifies parts of the source code, and does not i...
code_fim
hard
{ "lang": "rust", "repo": "ohomburg/avian", "path": "/src/pt.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> {}", _i); }, Err(_e) => { println!("{}: Not a valid integer!", input); } }; }<|fim_prefix|>// repo: mactsouk/introRustLC path: /day1/S3/result_option.rs fn main() { let mut input = "123"; let _i = match input.parse::<i32>() { Ok(_i) => { println!("i:...
code_fim
medium
{ "lang": "rust", "repo": "mactsouk/introRustLC", "path": "/day1/S3/result_option.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mactsouk/introRustLC path: /day1/S3/result_option.rs fn main() { let mut input = "123"; let _i = match input.parse::<i32>() { Ok(_i) => { pr<|fim_suffix|> } }; input = "abc"; let _i = match input.parse::<i32>() { Ok(_i) => { println!("i: {}", _i); ...
code_fim
medium
{ "lang": "rust", "repo": "mactsouk/introRustLC", "path": "/day1/S3/result_option.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ngtkana/aribook path: /crates/chap4_3/popular_cows/src/main.rs #![allow(clippy::many_single_char_names)] use chap4_3_scc::Scc; use proconio::{input, marker::Usize1}; fn main() { input!(n: usize, m: usize, ab: [(Usize1, Usize1); m]); let mut scc = Scc::with_len(n); let mut reverse_gr...
code_fim
medium
{ "lang": "rust", "repo": "ngtkana/aribook", "path": "/crates/chap4_3/popular_cows/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Feature missing. print_feature(&client, Point::new()); // Looking for features between 40, -75 and 42, -73. let mut rect = Rectangle::new(); rect.hi = SingularPtrField::some({ let mut point = Point::new(); point.latitude = 400000000; point.longitude = -75000...
code_fim
hard
{ "lang": "rust", "repo": "perdumonocle/grpc-rust", "path": "/grpc-examples/route_guide/src/bin/route_guide_client.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: perdumonocle/grpc-rust path: /grpc-examples/route_guide/src/bin/route_guide_client.rs // https://github.com/grpc/grpc-go/blob/master/examples/route_guide/client/client.go extern crate env_logger; extern crate futures; extern crate grpc; extern crate grpc_examples_route_guide; extern crate proto...
code_fim
hard
{ "lang": "rust", "repo": "perdumonocle/grpc-rust", "path": "/grpc-examples/route_guide/src/bin/route_guide_client.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }