text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: ssmylh/try_rust path: /src/borrowing.rs fn immutable_reference() { // イミュータブルな参照は同時に複数存在可能。 let x = "x".to_string(); let y = &x; let z = &x; } <|fim_suffix|> immutable_reference(); mutable_reference(); use_resource_after_frees(); }<|fim_middle|>fn mutable_reference() ...
code_fim
hard
{ "lang": "rust", "repo": "ssmylh/try_rust", "path": "/src/borrowing.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> immutable_reference(); mutable_reference(); use_resource_after_frees(); }<|fim_prefix|>// repo: ssmylh/try_rust path: /src/borrowing.rs fn immutable_reference() { // イミュータブルな参照は同時に複数存在可能。 let x = "x".to_string(); let y = &x; let z = &x; } fn mutable_reference() { // ミュータブ...
code_fim
medium
{ "lang": "rust", "repo": "ssmylh/try_rust", "path": "/src/borrowing.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let traits_set = arg.trait_bounds.iter().collect::<HashSet<_>>(); for &trait_bound in &tp.trait_bounds { if !traits_set.contains(&trait_bound) { self.fail_trait_bound(trait_bound, arg_ty); succeeded = false; } } succe...
code_fim
hard
{ "lang": "rust", "repo": "mrnugget/dora", "path": "/dora/src/semck/typeparamck.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> succeeded } fn type_against_definition(&self, tp: &TypeParam, ty: BuiltinType) -> bool { let mut succeeded = true; for &trait_bound in &tp.trait_bounds { if !ty.implements_trait(self.vm, trait_bound) { self.fail_trait_bound(trait_bound, ty); ...
code_fim
hard
{ "lang": "rust", "repo": "mrnugget/dora", "path": "/dora/src/semck/typeparamck.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mrnugget/dora path: /dora/src/semck/typeparamck.rs use dora_parser::lexer::position::Position; use std::collections::hash_set::HashSet; use crate::error::msg::SemError; use crate::ty::{BuiltinType, TypeList}; use crate::vm::{FileId, TraitId, TypeParam, VM}; pub fn check_type(vm: &VM, file: Fi...
code_fim
hard
{ "lang": "rust", "repo": "mrnugget/dora", "path": "/dora/src/semck/typeparamck.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: shurizzle/tomography path: /src/platform/macos/power.rs use crate::types::power::*; use core_foundation::array::{CFArray, CFArrayRef}; use core_foundation::base::{CFType, CFTypeRef, TCFType}; use core_foundation::boolean::{CFBoolean, CFBooleanRef}; use core_foundation::dictionary::{CFDictionary...
code_fim
hard
{ "lang": "rust", "repo": "shurizzle/tomography", "path": "/src/platform/macos/power.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn batteries(i: &CFType) -> Option<Vec<Battery>> { match list(i) { None => None, Some(list) => Some( list.iter() .map(|x| description(i, &x)) .filter(|x| x.is_some()) .map(|x| x.unwrap()) .collect(), ),...
code_fim
hard
{ "lang": "rust", "repo": "shurizzle/tomography", "path": "/src/platform/macos/power.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl FieldMutability { pub(crate) fn is_none(&self) -> bool { matches!(self, Self::None) } } impl Default for FieldMutability { fn default() -> Self { Self::None } }<|fim_prefix|>// repo: taiki-e/syn-serde path: /src/restriction.rs #[allow(unreachable_pub)] // https://gith...
code_fim
medium
{ "lang": "rust", "repo": "taiki-e/syn-serde", "path": "/src/restriction.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: taiki-e/syn-serde path: /src/restriction.rs #[allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/57411 pub use crate::{ ast_enum::{FieldMutability, Visibility}, ast_struct::VisRestricted, }; impl Visibility { pub(crate) fn is_inherited(&self) -> bool { match...
code_fim
medium
{ "lang": "rust", "repo": "taiki-e/syn-serde", "path": "/src/restriction.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: happyborg/gitoxide path: /git-protocol/src/fetch/refs.rs use bstr::{BString, ByteSlice}; use git_object::owned; use quick_error::quick_error; use std::io; quick_error! { #[derive(Debug)] pub enum Error { Io(err: io::Error) { display("An IO error occurred while readin...
code_fim
hard
{ "lang": "rust", "repo": "happyborg/gitoxide", "path": "/git-protocol/src/fetch/refs.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl InternalRef { fn unpack_direct(self) -> Option<(BString, owned::Id)> { match self { InternalRef::Direct { path, object } => Some((path, object)), _ => None, } } fn lookup_symbol_has_path(&self, predicate_path: &str) -> bool { matches!(self, ...
code_fim
hard
{ "lang": "rust", "repo": "happyborg/gitoxide", "path": "/git-protocol/src/fetch/refs.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> use self::Directive::*; let d = match s { "%" => Literal(Cow::from("%")), "a" => ClientIP, // {c}a => Underlying IP "A" => LocalIP, "B" => ResSizeExcludingHeaders, "b" => ResSize, // %{VARNAME}C => Request ...
code_fim
hard
{ "lang": "rust", "repo": "ant1441/apache-logformat-rs", "path": "/src/directive.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ant1441/apache-logformat-rs path: /src/directive.rs use std::borrow::Cow; use std::str::FromStr; #[derive(Debug, PartialEq)] pub enum PortType { Canonical, Local, Remote, } #[derive(Debug, PartialEq)] pub enum PIDType { PID, TID, HexTID, } #[derive(Debug, PartialEq)] p...
code_fim
hard
{ "lang": "rust", "repo": "ant1441/apache-logformat-rs", "path": "/src/directive.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>macro_rules! load_surface { ($file_name:expr) => {{ let mut s = Surface::from_file($file_name).expect(concat!("failed to load `", $file_name, "`")); if s.pixel_format_enum() != PixelFormatEnum::RGBA8888 { s = s .convert_format(PixelFormatEnum::RG...
code_fim
hard
{ "lang": "rust", "repo": "iCodeIN/rust-toy-game", "path": "/src/map.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: iCodeIN/rust-toy-game path: /src/map.rs use rand::Rng; use rand_chacha::ChaCha8Rng; use sdl2::image::LoadSurface; use sdl2::pixels::{Color, PixelFormatEnum}; use sdl2::rect::Rect; use sdl2::render::{Texture, TextureCreator}; use sdl2::surface::Surface; use sdl2::video::WindowContext; use serde_c...
code_fim
hard
{ "lang": "rust", "repo": "iCodeIN/rust-toy-game", "path": "/src/map.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Map { data: map, x, y, texture: texture_creator .create_texture_from_surface(surface_map) .expect("failed to build texture from surface"), top_layer_texture: texture_creator .create_texture_...
code_fim
hard
{ "lang": "rust", "repo": "iCodeIN/rust-toy-game", "path": "/src/map.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: patrickcsullivan/abm-server path: /src/network/error.rs use serde_json; use std::{convert::From, fmt}; use tungstenite; pub type NetworkResult<T> = Result<T, NetworkError>; #[derive(Debug)] pub enum NetworkError { Serde(serde_json::Error), Tungstenite(tungstenite::error::Error), } imp...
code_fim
medium
{ "lang": "rust", "repo": "patrickcsullivan/abm-server", "path": "/src/network/error.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl From<tungstenite::error::Error> for NetworkError { fn from(err: tungstenite::error::Error) -> NetworkError { NetworkError::Tungstenite(err) } }<|fim_prefix|>// repo: patrickcsullivan/abm-server path: /src/network/error.rs use serde_json; use std::{convert::From, fmt}; use tungstenite...
code_fim
medium
{ "lang": "rust", "repo": "patrickcsullivan/abm-server", "path": "/src/network/error.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> NetworkError::Serde(err) } } impl From<tungstenite::error::Error> for NetworkError { fn from(err: tungstenite::error::Error) -> NetworkError { NetworkError::Tungstenite(err) } }<|fim_prefix|>// repo: patrickcsullivan/abm-server path: /src/network/error.rs use serde_json; use ...
code_fim
hard
{ "lang": "rust", "repo": "patrickcsullivan/abm-server", "path": "/src/network/error.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if sub[i].len() == 0 { salary[i] = 1; return 1; } let ss = sub[i].iter().map(|&s| rec(s, salary, sub)).collect_vec(); let s = ss.iter().max().unwrap() + ss.iter().min().unwrap() + 1; salary[i] = s; return s; }<|fim_prefix|>// repo: hayashikun/atcoder path: /atcod...
code_fim
hard
{ "lang": "rust", "repo": "hayashikun/atcoder", "path": "/atcoder-rust/abc026/src/bin/c.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hayashikun/atcoder path: /atcoder-rust/abc026/src/bin/c.rs #![allow(unused_imports)] use itertools::Itertools; use proconio::{fastout, input, marker::*}; #[fastout] fn main() { input! { n: usize, bb: [Usize1; n - 1] }; let mut sub = vec![Vec::new(); n]; for (i,...
code_fim
hard
{ "lang": "rust", "repo": "hayashikun/atcoder", "path": "/atcoder-rust/abc026/src/bin/c.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: BitSine/sinewave path: /src/hooks.rs use crate::CommandCounter; use log::{debug, info, warn}; use serenity::{ client::Context, framework::standard::{macros::hook, CommandResult}, model::channel::Message, }; #[hook] pub async fn before(ctx: &Context, msg: &Message, command_name: &str...
code_fim
medium
{ "lang": "rust", "repo": "BitSine/sinewave", "path": "/src/hooks.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let _ = msg .channel_id .say(&ctx.http, format!("running command `{}`", command_name)) .await; let mut data = ctx.data.write().await; let counter = data .get_mut::<CommandCounter>() .expect("Expected CommandCounter in TypeMap."); let entry = counter...
code_fim
medium
{ "lang": "rust", "repo": "BitSine/sinewave", "path": "/src/hooks.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[hook] pub async fn delay_action(ctx: &Context, msg: &Message) { // You may want to handle a Discord rate limit if this fails. let _ = msg.react(ctx, '⏱').await; } #[hook] pub async fn after( ctx: &Context, msg: &Message, command_name: &str, command_result: CommandResult, ) { ...
code_fim
hard
{ "lang": "rust", "repo": "BitSine/sinewave", "path": "/src/hooks.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// The credential of a network connection. It mirrors the fidl_fuchsia_wlan_policy Credential #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub enum Credential { None, Password(Vec<u8>), Psk(Vec<u8>), }<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/connectivity/wlan/lib/stas...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/connectivity/wlan/lib/stash/src/constants.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/connectivity/wlan/lib/stash/src/constants.rs // Copyright 2020 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. use serde::{Deserialize, Serialize}; pub const NODE_SEPAR...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/connectivity/wlan/lib/stash/src/constants.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|>pub type StashedSsid = Vec<u8>; /// The data that will be stored between reboots of a device. Used to convert the data between JSON /// and network config. #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct PersistentData { pub credential: Credential, pub has_ever_connected: bo...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/connectivity/wlan/lib/stash/src/constants.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> //en array för att kunna spara alla UNIKA, hela namn let mut unika_namn_och_efternamn: Vec<String> = Vec::new(); //spara alla förnamn for _i in 0..n{ let fornamn = lines .next().unwrap(); namn_och_efternamn.push(fornamn) } //spara alla efternamn til...
code_fim
hard
{ "lang": "rust", "repo": "INDAPlus20/kfolke-task-2", "path": "/cyber-ClaraOchAnmalningslistorna/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: INDAPlus20/kfolke-task-2 path: /cyber-ClaraOchAnmalningslistorna/src/main.rs //ja jag var ju tvungen att lösa denna uppgift pågrund av dess namn hahaha /*Är medveten om att jag har lite dålig namngivning, dels att jag har lite ospecifika namn samt att de är lite blandad svengelska vilket jag ...
code_fim
hard
{ "lang": "rust", "repo": "INDAPlus20/kfolke-task-2", "path": "/cyber-ClaraOchAnmalningslistorna/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jeffw387/bmpfntgen path: /src/main.rs use bmpfntgen::{CharSets, ImageFormat, MetaFormat}; use structopt::StructOpt; #[derive(StructOpt, Debug)] #[structopt(name = "bmpfntgen")] struct CLIOptions { #[structopt(short, long)] font_path: String, #[structopt(short = "n", long, default_v...
code_fim
hard
{ "lang": "rust", "repo": "jeffw387/bmpfntgen", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let result = bmpfntgen::layout_and_render( &font, cli_options.char_set, cli_options.height as f32, )?; bmpfntgen::save( &cli_options.output_name, &cli_options.output_path, result, cli_options.meta_format, cli_options.image_format,...
code_fim
hard
{ "lang": "rust", "repo": "jeffw387/bmpfntgen", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let font = bmpfntgen::load_ttf(&cli_options.font_path)?; let result = bmpfntgen::layout_and_render( &font, cli_options.char_set, cli_options.height as f32, )?; bmpfntgen::save( &cli_options.output_name, &cli_options.output_path, result, ...
code_fim
hard
{ "lang": "rust", "repo": "jeffw387/bmpfntgen", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn visit_u32<E>(&mut self, value: u32) -> Result<Priority, E> where E: Error { if let Some(p) = Priority::from_i32(value as i32) { Ok(p) } else { Err(serde::de::Error::custom("unexpected value")) } } fn visit_u64<E>(&mut self, value: u64) ->...
code_fim
hard
{ "lang": "rust", "repo": "dogamak/transmission_rpc", "path": "/src/priority.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if let Some(p) = Priority::from_i32(value as i32) { Ok(p) } else { Err(serde::de::Error::custom("unexpected value")) } } fn visit_i64<E>(&mut self, value: i64) -> Result<Priority, E> where E: Error { if let Some(p) = Priority::from_i32(v...
code_fim
hard
{ "lang": "rust", "repo": "dogamak/transmission_rpc", "path": "/src/priority.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dogamak/transmission_rpc path: /src/priority.rs use serde; use serde::de::Error; #[derive(Clone, Debug)] pub enum Priority { Low, Normal, High } impl Priority { fn from_i32(v: i32) -> Option<Priority> { match v { -1 => Some(Priority::Low), 0 => S...
code_fim
hard
{ "lang": "rust", "repo": "dogamak/transmission_rpc", "path": "/src/priority.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[inline] fn visit_string<E>(self, value: String) -> Result<Self::Value, E> where E: serde::de::Error, { Ok(Self::parse_str(Cow::Owned(value))) } #[inline] fn visit_bytes<E>(self, value: &[u8]) -> Result<Self::Value, E> where E: serde::de::Error, ...
code_fim
hard
{ "lang": "rust", "repo": "basiliqio/ciboulette", "path": "/src/query/fields.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> where E: serde::de::Error, { Ok(Self::parse_str(Cow::Owned(value.to_string()))) } #[inline] fn visit_string<E>(self, value: String) -> Result<Self::Value, E> where E: serde::de::Error, { Ok(Self::parse_str(Cow::Owned(value))) } #[inline...
code_fim
hard
{ "lang": "rust", "repo": "basiliqio/ciboulette", "path": "/src/query/fields.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: basiliqio/ciboulette path: /src/query/fields.rs use super::*; use serde::de::Visitor; use std::fmt::Formatter; /// ## Visitor for query parameters fields pub struct CibouletteQueryParametersFieldVisitor; /// ## Field of `json:api` query parameters object pub enum CibouletteQueryParametersField...
code_fim
hard
{ "lang": "rust", "repo": "basiliqio/ciboulette", "path": "/src/query/fields.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jethrogb/schannel-rs path: /src/cert_context.rs //! Bindings to winapi's `PCCERT_CONTEXT` APIs. use std::ffi::OsString; use std::io; use std::mem; use std::os::windows::prelude::*; use std::ptr; use std::slice; use crypt32; use winapi; use {Inner, KeyHandlePriv}; use key_handle::KeyHandle; //...
code_fim
hard
{ "lang": "rust", "repo": "jethrogb/schannel-rs", "path": "/src/cert_context.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Configures the string that contains the display name for this /// certificate. pub fn set_friendly_name(&self, name: &str) -> io::Result<()> { self.set_string(winapi::CERT_FRIENDLY_NAME_PROP_ID, name) } /// Verifies the time validity of this certificate relative to the sys...
code_fim
hard
{ "lang": "rust", "repo": "jethrogb/schannel-rs", "path": "/src/cert_context.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: casperin/rust_jazz_reader path: /src/main.rs extern crate actix; extern crate actix_web; extern crate askama; extern crate env_logger; extern crate jazz_reader; extern crate log; extern crate postgres; extern crate r2d2; extern crate r2d2_postgres; use actix_web::middleware::identity::{CookieId...
code_fim
hard
{ "lang": "rust", "repo": "casperin/rust_jazz_reader", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // start http server server::new(move || { App::with_state(AppState { db: pool.clone() }) .middleware(IdentityService::new( CookieIdentityPolicy::new(&[0; 32]) .name("auth-cookie") .secure(false), )) ...
code_fim
hard
{ "lang": "rust", "repo": "casperin/rust_jazz_reader", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lphk92/tictac path: /src/board.rs use std::fmt; use std::char; extern crate ansi_term; use self::ansi_term::Colour::Green; #[derive(Debug)] pub struct Board { name: String, board: [char; 9], move_count: i8, } impl fmt::Display for Board { fn fmt(&self, f: &mut fmt::Formatter) ...
code_fim
hard
{ "lang": "rust", "repo": "lphk92/tictac", "path": "/src/board.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> result } pub fn is_draw(&self) -> bool { self.winner().is_none() && self.move_count == 9 } pub fn winner(&self) -> Option<char> { for winning_move in Board::WINNING_MOVES.iter() { let winner = self.board[winning_move[0]]; if winner != ' ' ...
code_fim
hard
{ "lang": "rust", "repo": "lphk92/tictac", "path": "/src/board.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rethab/cs6120 path: /lesson2-basic-blocks/src/main.rs use std::io; use std::mem; use bril_rs as bril; use bril_rs::{Code, EffectOps, Instruction}; #[derive(Debug, Clone)] struct BasicBlock { label: String, instrs: Vec<bril::Instruction>, } impl BasicBlock { fn new(label: String) -...
code_fim
hard
{ "lang": "rust", "repo": "rethab/cs6120", "path": "/lesson2-basic-blocks/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> edges.push((label, successors)) } edges } fn main() -> io::Result<()> { let program = bril::load_program(); let cfg = create_cfg(create_blocks(program)); println!("digraph main {{"); for (label, _) in cfg.iter() { println!(" {};", label); } for (label, suc...
code_fim
hard
{ "lang": "rust", "repo": "rethab/cs6120", "path": "/lesson2-basic-blocks/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn print_cr(msg: String, next: bool) { let len = if msg.len() < STDOUT_MSG_SIZE { STDOUT_MSG_SIZE - msg.len() } else { 0 }; let padding = String::from(" ").repeat(len); print!("\r{}{}", msg, padding); if next { print!("\n"); ...
code_fim
hard
{ "lang": "rust", "repo": "namuyan/bc4py_plotter", "path": "/src/utils.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: namuyan/bc4py_plotter path: /src/utils.rs use bech32::{Bech32,convert_bits}; use std::str::FromStr; use std::io::{stdout, Write}; pub const STDOUT_MSG_SIZE: usize = 64; #[inline] pub fn addr2ver_identifier(address: &str) -> Result<Vec<u8>, String> { // return [ver+identifier] bytes l...
code_fim
hard
{ "lang": "rust", "repo": "namuyan/bc4py_plotter", "path": "/src/utils.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn print_cr(msg: String, next: bool) { let len = if msg.len() < STDOUT_MSG_SIZE { STDOUT_MSG_SIZE - msg.len() } else { 0 }; let padding = String::from(" ").repeat(len); print!("\r{}{}", msg, padding); if next { print!("\n"); }...
code_fim
hard
{ "lang": "rust", "repo": "namuyan/bc4py_plotter", "path": "/src/utils.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lovesegfault/chat path: /tests/common/mod.rs #![allow(dead_code)] use std::{ future::Future, net::{Ipv4Addr, SocketAddr}, time::Duration, }; use anyhow::{anyhow, Error}; use chat::client::Client; use chat::server::Server; use tokio::{task::JoinHandle, time::timeout}; pub struct Te...
code_fim
medium
{ "lang": "rust", "repo": "lovesegfault/chat", "path": "/tests/common/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> async fn timeout_call<T: Future>(f: T) -> Result<T::Output, Error> { match timeout(Self::TIMEOUT, f).await { Ok(f) => Ok(f), Err(_) => Err(anyhow!("Client timed-out")), } } pub async fn new(server_addr: &SocketAddr) -> Result<Self, Error> { let ...
code_fim
medium
{ "lang": "rust", "repo": "lovesegfault/chat", "path": "/tests/common/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: KennFatt/Snowflakes path: /src/appdelegate.rs use opengl_graphics::{GlGraphics, OpenGL}; use glutin_window::GlutinWindow; use piston::input::{RenderEvent, UpdateEvent, ButtonEvent}; use piston::window::WindowSettings; use piston::event_loop::{Events, EventSettings}; use super::core::Core; pub...
code_fim
hard
{ "lang": "rust", "repo": "KennFatt/Snowflakes", "path": "/src/appdelegate.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /* --- Render start --- */ self.core.render(&args, c, &mut self.gl); /* --- Render end --- */ self.gl.draw_end(); } /* Update event */ if let Some(args) = ev.update_args() { ...
code_fim
hard
{ "lang": "rust", "repo": "KennFatt/Snowflakes", "path": "/src/appdelegate.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /* Render event */ if let Some(args) = ev.render_args() { /* I have to call gl.draw_begin() and gl.draw_end() manually. This is basically how gl.draw() works. */ let c = self.gl.draw_begin(args...
code_fim
hard
{ "lang": "rust", "repo": "KennFatt/Snowflakes", "path": "/src/appdelegate.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn energymon_is_exclusive_msr() -> c_int; pub fn energymon_get_msr(em: *mut energymon) -> c_int; }<|fim_prefix|>// repo: connorimes/energymon-sys path: /energymon-msr-sys/lib.rs //! FFI bindings for `energymon-msr.h`. extern crate libc; extern crate energymon_sys; pub use energymon_sys::en...
code_fim
hard
{ "lang": "rust", "repo": "connorimes/energymon-sys", "path": "/energymon-msr-sys/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn energymon_get_interval_msr(em: *const energymon) -> uint64_t; pub fn energymon_get_precision_msr(em: *const energymon) -> uint64_t; pub fn energymon_is_exclusive_msr() -> c_int; pub fn energymon_get_msr(em: *mut energymon) -> c_int; }<|fim_prefix|>// repo: connorimes/energymon-sy...
code_fim
hard
{ "lang": "rust", "repo": "connorimes/energymon-sys", "path": "/energymon-msr-sys/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: connorimes/energymon-sys path: /energymon-msr-sys/lib.rs //! FFI bindings for `energymon-msr.h`. extern crate libc; extern crate energymon_sys; <|fim_suffix|> pub fn energymon_get_precision_msr(em: *const energymon) -> uint64_t; pub fn energymon_is_exclusive_msr() -> c_int; pub fn...
code_fim
hard
{ "lang": "rust", "repo": "connorimes/energymon-sys", "path": "/energymon-msr-sys/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: uklotzde/rust-mp4ameta path: /src/core/mod.rs /// Contains constants, structs and functions for working with MPEG-4 metadata atoms. <|fim_suffix|>g with data held inside MPEG-4 metadata /// atoms. #[macro_use] pub mod data; /// Contains structs and constants for working with types held inside da...
code_fim
medium
{ "lang": "rust", "repo": "uklotzde/rust-mp4ameta", "path": "/src/core/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>g with data held inside MPEG-4 metadata /// atoms. #[macro_use] pub mod data; /// Contains structs and constants for working with types held inside data atoms. pub mod types;<|fim_prefix|>// repo: uklotzde/rust-mp4ameta path: /src/core/mod.rs /// Contains constants, structs and functions for working with...
code_fim
medium
{ "lang": "rust", "repo": "uklotzde/rust-mp4ameta", "path": "/src/core/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gitter-badger/spectra path: /tests/lib.rs extern crate rand; extern crate spectra; use rand::{Rng, thread_rng}; use spectra::anim::spline::*; #[test] fn hold() { let spline = Spline::from_keys(vec![ Key::new(0., 10., Interpolation::Step(1.)), Key::new(24., 100., Interpolation::Step(1...
code_fim
hard
{ "lang": "rust", "repo": "gitter-badger/spectra", "path": "/tests/lib.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn keys_sorted() { let nb = 10000; let mut rng = thread_rng(); let mut keys = Vec::with_capacity(nb); for _ in 0..nb { let t = rng.gen::<f32>().abs(); let v: f32 = rng.gen(); let key = Key::new(t, v, Interpolation::Step(1.)); keys.push(key); } let anim_param = Spline...
code_fim
hard
{ "lang": "rust", "repo": "gitter-badger/spectra", "path": "/tests/lib.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> let (s, _, _) = gcd_extended(shuffle.a as i64, self.num_cards as i64); let mut ans = self.mul_mod(pos.abs() as u64, s.abs() as u64); if pos.is_negative() != s.is_negative() { ans = self.modulo(-(ans as i64)) as u64; } ans } } pub fn parse_input(inp...
code_fim
hard
{ "lang": "rust", "repo": "jblee123/advent_of_code_2019", "path": "/aoc2019_day22/src/day22_utils.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jblee123/advent_of_code_2019 path: /aoc2019_day22/src/day22_utils.rs the same form results in a third shuffle of /// the same form as the first two, that means we can compose together as many /// as we like, be it a list of separate shuffles or repeating the same shuffle /// over and over again....
code_fim
hard
{ "lang": "rust", "repo": "jblee123/advent_of_code_2019", "path": "/aoc2019_day22/src/day22_utils.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let target = Deck { cards: vec![0, 7, 4, 1, 8, 5, 2, 9, 6, 3] }; let mut deck = Deck::new(10); deck.shuffle(ShuffleType::WithIncrement(3)); assert_eq!(deck, target); } #[test] fn test_deck_shuffle_multi() { let target = Deck { cards: vec![0, 3, 6, 9, 2,...
code_fim
hard
{ "lang": "rust", "repo": "jblee123/advent_of_code_2019", "path": "/aoc2019_day22/src/day22_utils.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if arr.len() < n + index { return; } if n == 0 { let mut it = arr.iter().zip(incl_arr.iter()).filter_map(|(val, incl)| if *incl { Some(val) } else { None } ); for val in it { print!("{} ", *val); } print!("\n"); return; } incl_arr[index]...
code_fim
hard
{ "lang": "rust", "repo": "doyleyoung/adventofcode2017", "path": "/rust/2/checksum/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: doyleyoung/adventofcode2017 path: /rust/2/checksum/src/main.rs fn main() { let arr1 = [1, 2, 3, 4, 5]; comb(&arr1, 3); let arr2 = ["A", "B", "C", "D", "E"]; comb(&arr2, 3); } <|fim_suffix|>fn comb_u32ern<T: std::default::Default>(arr: &[T], n: u32, incl_arr: &mut [bool], index:...
code_fim
medium
{ "lang": "rust", "repo": "doyleyoung/adventofcode2017", "path": "/rust/2/checksum/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> incl_arr[index] = true; comb_u32ern(arr, n-1, incl_arr, index+1); incl_arr[index] = false; comb_u32ern(arr, n, incl_arr, index+1); }<|fim_prefix|>// repo: doyleyoung/adventofcode2017 path: /rust/2/checksum/src/main.rs fn main() { let arr1 = [1, 2, 3, 4, 5]; comb(&arr1, 3); l...
code_fim
hard
{ "lang": "rust", "repo": "doyleyoung/adventofcode2017", "path": "/rust/2/checksum/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> command::DocumentGetCommand { document_repository: &repo, database_name, collection_name, id, } .run() } ("delete", So...
code_fim
hard
{ "lang": "rust", "repo": "notomo/vimonga", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let repo = datastore::CollectionRepositoryImpl { connection_factory: &connection_factory, }; match cmd.subcommand() { ("list", Some(_)) => command::CollectionListCommand { collection_repository: &repo, ...
code_fim
hard
{ "lang": "rust", "repo": "notomo/vimonga", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: notomo/vimonga path: /src/main.rs ("args") .long("args") .multiple(true) .takes_value(true) .required(false), ) .arg( Arg::with_name("host") ...
code_fim
hard
{ "lang": "rust", "repo": "notomo/vimonga", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> method.call(request, response); Ok(()) } // finds the specified route's action pub fn find_route(&self, method: &String, path: &String) -> Result<(Arc<RouterAction>, HashMap<String, String>), Error> { let inner = self.inner.clone(); let inner = inner.inner_rout...
code_fim
hard
{ "lang": "rust", "repo": "Navrin/rusty-server", "path": "/src/server/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let routers = routers.iter(); for (routing, router) in routers { let routing = routing.to_string(); if path.trim_left().starts_with(&routing) { let (method, params) = router.find_route( method.to_string(), pat...
code_fim
hard
{ "lang": "rust", "repo": "Navrin/rusty-server", "path": "/src/server/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Navrin/rusty-server path: /src/server/mod.rs pub mod router; pub mod request; pub mod response; mod thread_pool; use std::net::{TcpListener, TcpStream}; use std::io::{Error, ErrorKind}; use std::sync::{Arc, Mutex}; use std::collections::HashMap; use self::request::Request; use self::router::{...
code_fim
hard
{ "lang": "rust", "repo": "Navrin/rusty-server", "path": "/src/server/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Manishearth/rust-sfml path: /examples/custom_drawable.rs //! Example from SFML: Custom drawable extern crate sfml; use sfml::graphics::{RenderWindow, Color, CircleShape, RectangleShape, RenderTarget, RenderStates, Drawable, Shape, Transformable}; use sfml::window::{VideoM...
code_fim
hard
{ "lang": "rust", "repo": "Manishearth/rust-sfml", "path": "/examples/custom_drawable.rs", "mode": "psm", "license": "Zlib", "source": "the-stack-v2" }
<|fim_suffix|>// Implements the drawable trait, only this function is mendatory. impl<'s> Drawable for CustomDrawable<'s> { fn draw<RT: RenderTarget>(&self, render_target: &mut RT, _: &mut RenderStates) { render_target.draw(&self.circle); render_target.draw(&self.rect) } } fn main() { // Cr...
code_fim
medium
{ "lang": "rust", "repo": "Manishearth/rust-sfml", "path": "/examples/custom_drawable.rs", "mode": "spm", "license": "Zlib", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DelSkayn/RustEngine3d path: /tungsten/tungsten_logic/src/lib.rs #![crate_name = "tungsten_logic"] #![crate_type = "lib"] #![allow(dead_code)] #[macro_use] extern crate log; extern crate task; pub mod component; mod entities; pub mod system; mod get_once; pub use self::component::{Components,Co...
code_fim
hard
{ "lang": "rust", "repo": "DelSkayn/RustEngine3d", "path": "/tungsten/tungsten_logic/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Clone,Copy,Eq,PartialEq)] struct Generation(i32); type Index = u32; #[derive(Eq,PartialEq,Clone,Copy)] pub struct Entity(Generation,Index); pub struct Logic{ world: Components, entities: Entities, } impl Logic{ pub fn new() -> Self{ Logic{ world: Components::ne...
code_fim
medium
{ "lang": "rust", "repo": "DelSkayn/RustEngine3d", "path": "/tungsten/tungsten_logic/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jonimake/MiniPLInterpreter path: /src/lexer/lexeme_iterator.rs eType; const SINGLE_CHAR_LEXEME: & [&str] = &["+", "-", "*", "/", "<", "=", "&", "!", "(", ")", ";", ".", ":"]; const TWO_CHAR_LEXEME: & [& str] = &["..", ":="]; const KEYWORD: & [& str] = &["assert", "string", "print", "bool", "rea...
code_fim
hard
{ "lang": "rust", "repo": "jonimake/MiniPLInterpreter", "path": "/src/lexer/lexeme_iterator.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jonimake/MiniPLInterpreter path: /src/lexer/lexeme_iterator.rs current_line_char_pos: usize, current_line: &'a str, slice_start: usize, initialized: bool, lexeme_matchers: LexemeMatcherType, } impl<'a> Clone for LexemeIterator<'a> { fn clone(&self) -> LexemeIterator<'a> {...
code_fim
hard
{ "lang": "rust", "repo": "jonimake/MiniPLInterpreter", "path": "/src/lexer/lexeme_iterator.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn is_identifier(lexeme: &str) -> bool { let all_are_alpha_num = lexeme.chars().all(|ch: char| ch.is_alphanumeric() || ch == '_'); let first_is_alphabetic = lexeme.chars().nth(0).unwrap_or('1').is_alphabetic(); first_is_alphabetic && all_are_alpha_num } fn is_bool(lexeme: &str) -> bool { ...
code_fim
hard
{ "lang": "rust", "repo": "jonimake/MiniPLInterpreter", "path": "/src/lexer/lexeme_iterator.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dandavison/_sylph path: /src/queries/guides.rs //! A query returning an array of guides, each with a nested array of image urls. use std::collections::HashMap; use serde::{Deserialize, Serialize}; <|fim_suffix|>pub fn query() -> Vec<Guide> { db::get_client() .query( " s...
code_fim
hard
{ "lang": "rust", "repo": "dandavison/_sylph", "path": "/src/queries/guides.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl From<postgres::Row> for Guide { fn from(row: postgres::Row) -> Self { Self { id: row.get("id"), name: row.get("name"), trip_guide: row.get("trip_guide"), description: row.get("description"), images: row.get("images"), } ...
code_fim
hard
{ "lang": "rust", "repo": "dandavison/_sylph", "path": "/src/queries/guides.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Cassin01/PracticeForCompetitiveProgramming path: /at_coder/C/abc_057/01.rs fn ee(n: usize) -> f64 { let mut e = 1.0_f64; let mut d = 1.0_f64; for i in 1..n { d *= i as f64; e += 1.0 / d as f64; } e } <|fim_suffix|> println!("n = 10 の時{}", ee(10)); prin...
code_fim
easy
{ "lang": "rust", "repo": "Cassin01/PracticeForCompetitiveProgramming", "path": "/at_coder/C/abc_057/01.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("n = 10 の時{}", ee(10)); println!("n = 100 の時{}", ee(100)); }<|fim_prefix|>// repo: Cassin01/PracticeForCompetitiveProgramming path: /at_coder/C/abc_057/01.rs fn ee(n: usize) -> f64 { let mut e = 1.0_f64; let mut d = 1.0_f64; for i in 1..n { d *= i as f64; e +=...
code_fim
easy
{ "lang": "rust", "repo": "Cassin01/PracticeForCompetitiveProgramming", "path": "/at_coder/C/abc_057/01.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let view = ClustersView { width: self.width, height: self.height, pixels: &self.pixels, clusters: &self.clusters, cluster_indices: &self.cluster_indices, clusters_output: &self.clusters_output, ...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/visioncortex", "path": "/src/color_clusters/builder.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let sum = self.clusters[from.0 as usize].sum; let rect = self.clusters[from.0 as usize].rect; let indices = self.clusters[from.0 as usize].indices.clone(); self.combine_clusters(from, to); self.clusters[from.0 as usize].sum = sum; self.clusters[from.0 as u...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/visioncortex", "path": "/src/color_clusters/builder.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/visioncortex path: /src/color_clusters/builder.rs :ClusterIndex}; #[derive(Clone)] pub struct BuilderConfig { pub(crate) diagonal: bool, pub(crate) batch_size: u32, pub(crate) key: Color, } impl Default for BuilderConfig { fn default() -> Self { Self { ...
code_fim
hard
{ "lang": "rust", "repo": "isgasho/visioncortex", "path": "/src/color_clusters/builder.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zhangyuang/leetcode path: /linkList/medium/merge_in_between/src/lib.rs /* * @lc app=leetcode.cn id=1669 lang=rust * * [1669] 合并两个链表 */ //Definition for singly-linked list. #[derive(PartialEq, Eq, Clone, Debug)] pub struct ListNode { pub val: i32, pub next: Option<Box<ListNode>>, } <|fim...
code_fim
medium
{ "lang": "rust", "repo": "zhangyuang/leetcode", "path": "/linkList/medium/merge_in_between/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>use std::env; use std::fs; fn main() { // Set up a temporary directory for the index. let tmp_dir = env::temp_dir().join("appendix-index"); fs::remove_dir(&tmp_dir); fs::create_dir(&tmp_dir); let index = Index::new(&tmp_dir).unwrap(); index.insert(0, &10).unwrap(); }<|fim_prefix|...
code_fim
hard
{ "lang": "rust", "repo": "iCodeIN/Rudra-PoC", "path": "/poc/0040-appendix.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let index = Index::new(&tmp_dir).unwrap(); index.insert(0, &10).unwrap(); }<|fim_prefix|>// repo: iCodeIN/Rudra-PoC path: /poc/0040-appendix.rs /*! ```rudra-poc [target] crate = "appendix" version = "0.2.0" [report] issue_url = "https://github.com/krl/appendix/issues/6" issue_date = 2020-11-15 r...
code_fim
medium
{ "lang": "rust", "repo": "iCodeIN/Rudra-PoC", "path": "/poc/0040-appendix.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: iCodeIN/Rudra-PoC path: /poc/0040-appendix.rs /*! ```rudra-poc [target] crate = "appendix" version = "0.2.0" [report] issue_url = "https://github.com/krl/appendix/issues/6" issue_date = 2020-11-15 rustsec_url = "https://github.com/RustSec/advisory-db/pull/848" rustsec_id = "RUSTSEC-2020-0149" ...
code_fim
medium
{ "lang": "rust", "repo": "iCodeIN/Rudra-PoC", "path": "/poc/0040-appendix.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub type CurrentPlatformSession = <CurrentPlatformBackend as traits::Backend>::Session; pub type CurrentPlatformDevice = <CurrentPlatformBackend as traits::Backend>::Device; pub type CurrentPlatformError = <CurrentPlatformBackend as traits::Backend>::Error; pub type CurrentPlatformAudioBuffers = <CurrentP...
code_fim
easy
{ "lang": "rust", "repo": "mhallin/render_callback-rs", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mhallin/render_callback-rs path: /src/lib.rs mod coreaudio; mod traits; pub use traits::*; <|fim_suffix|>pub type CurrentPlatformSession = <CurrentPlatformBackend as traits::Backend>::Session; pub type CurrentPlatformDevice = <CurrentPlatformBackend as traits::Backend>::Device; pub type Curren...
code_fim
easy
{ "lang": "rust", "repo": "mhallin/render_callback-rs", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> false } fn view(&self) -> Html { let checkbox = with_raw_code!(checkbox { html! { <section> <div class="demo"> <h3>{"Standard"}</h3> <MatFormfield label="This is a checkbox"> <MatCheckbox /> </...
code_fim
hard
{ "lang": "rust", "repo": "realotz/material-yew", "path": "/website/src/components/form_field.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: realotz/material-yew path: /website/src/components/form_field.rs use crate::components::Codeblock; use crate::with_raw_code; use material_yew::{MatCheckbox, MatFormfield, MatRadio, MatSwitch}; use yew::prelude::*; pub struct FormField {} impl Component for FormField { type Message = (); ...
code_fim
hard
{ "lang": "rust", "repo": "realotz/material-yew", "path": "/website/src/components/form_field.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: codebje/vtrs20 path: /zexrunner/src/lib.rs assert_eq!(state.get(15), 0x49, "bc.1 access is correct"); assert_eq!(state.get(16), 0x93, "f access is correct"); assert_eq!(state.get(17), 0x00, "a access is correct"); assert_eq!(state.get(18), 0xad, "sp.0 access is correct"); as...
code_fim
hard
{ "lang": "rust", "repo": "codebje/vtrs20", "path": "/zexrunner/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: codebje/vtrs20 path: /zexrunner/src/lib.rs _eq!(state.operand, 0x85e8, "operand low byte good"); } fn count_bits(state: &ZexState) -> u32 { state.instruction.count_ones() + state.operand.count_ones() as u32 + state.iy.count_ones() as u32 + state.ix.count_ones() as u3...
code_fim
hard
{ "lang": "rust", "repo": "codebje/vtrs20", "path": "/zexrunner/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> ram.write( 0x103, &[ state.operand as u8, (state.operand >> 8) as u8, state.iy as u8, (state.iy >> 8) as u8, state.ix as u8, (state.ix >> 8) as u8, state.hl as u8, (state.hl >> 8) as u8, ...
code_fim
hard
{ "lang": "rust", "repo": "codebje/vtrs20", "path": "/zexrunner/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: facundoolano/exercism path: /rust/run-length-encoding/src/lib.rs pub fn encode(source: &str) -> String { let mut result = String::new(); let mut count = 1; let mut current = '/'; <|fim_suffix|> for c in source.chars() { if c.is_numeric() { digit_accumulator.pu...
code_fim
hard
{ "lang": "rust", "repo": "facundoolano/exercism", "path": "/rust/run-length-encoding/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn decode(source: &str) -> String { let mut result = String::new(); let mut digit_accumulator = String::new(); for c in source.chars() { if c.is_numeric() { digit_accumulator.push(c); } else { if let Ok(digit) = digit_accumulator.parse() { ...
code_fim
hard
{ "lang": "rust", "repo": "facundoolano/exercism", "path": "/rust/run-length-encoding/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }