text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: shreyashsaitwal/recast path: /src/main.rs
use std::path::{Path, PathBuf};
use std::process;
use ansi_term::Color::{Blue, Cyan, Green, Red, Yellow};
use structopt::clap::AppSettings::{ColorAlways, ColoredHelp};
use structopt::StructOpt;
use archive::ArchiveType;
mod archive;
mod dexer;
mod jet... | code_fim | hard | {
"lang": "rust",
"repo": "shreyashsaitwal/recast",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let opts: Options = Options::from_args();
let output_dir = opts.output;
let input = opts.input;
// Create the output dir if it doesn't already exists.
if !output_dir.exists() {
if let Err(err) = std::fs::create_dir_all(&output_dir) {
eprintln!(
" ... | code_fim | hard | {
"lang": "rust",
"repo": "shreyashsaitwal/recast",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Enable ANSI support on Windows 10 ignoring any error.
#[cfg(target_os = "windows")]
ansi_term::enable_ansi_support().unwrap_or(());
let opts: Options = Options::from_args();
let output_dir = opts.output;
let input = opts.input;
// Create the output dir if it doesn't alread... | code_fim | hard | {
"lang": "rust",
"repo": "shreyashsaitwal/recast",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ben-75/irusti path: /src/transaction.rs
tryte_count -=1;
remaining_count = 0;
}
2 => {
response.push(tuple_2_char((b0, b1, t0)));
tryte_count -=1;
if tryte_count == 0 {b... | code_fim | hard | {
"lang": "rust",
"repo": "ben-75/irusti",
"path": "/src/transaction.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_min_value_is_valid_value(){
let tx = Transaction::new(None,Some("A9RGRKVGWMWMKOLVMDFWJUHNUNYWZTJADGGPZGXNLERLXYWJE9WQHWWBMCPZMVVMJUMWWBLZLNMLDCGDJ".as_ref()), Some(-SUPPLY),
Some("MOBSOLETE"),
Some(14825222... | code_fim | hard | {
"lang": "rust",
"repo": "ben-75/irusti",
"path": "/src/transaction.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(tx.value(),0);
}
#[test]
fn test_value_minus_1(){
let tx = Transaction::new(None,Some("A9RGRKVGWMWMKOLVMDFWJUHNUNYWZTJADGGPZGXNLERLXYWJE9WQHWWBMCPZMVVMJUMWWBLZLNMLDCGDJ".as_ref()), Some(-1),
None,
So... | code_fim | hard | {
"lang": "rust",
"repo": "ben-75/irusti",
"path": "/src/transaction.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: floschnell/ascii-platformer path: /src/main.rs
extern crate termion;
use std::error::Error;
use std::fs::File;
use std::io::{stdout, Read, Write};
use termion::color::{Bg, Fg, Rgb};
use termion::raw::IntoRawMode;
struct Display {
width: u16,
height: u16,
left: usize,
top: usize,
}
stru... | code_fim | hard | {
"lang": "rust",
"repo": "floschnell/ascii-platformer",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut buffer = String::new();
let width_max = if display.width > world.width {
world.width
} else {
display.width
};
let height_max = if display.height > world.height {
world.height
} else {
display.height
};
for y in display.top..(display.top + height_max as usize) {
... | code_fim | hard | {
"lang": "rust",
"repo": "floschnell/ascii-platformer",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> DrawingError {
msg: String::from(err.description()),
}
}
}
fn walk(player: &mut Player, dir: i8) {
player.walking = true;
player.walking_dir = dir;
}
fn jump(player: &mut Player) {
if player.on_ground {
player.speed_y = -JUMP;
}
}
fn simulate(world: &World, player: &mut Play... | code_fim | hard | {
"lang": "rust",
"repo": "floschnell/ascii-platformer",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MTCoster/fp-types-rs path: /src/lib.rs
#![no_std]
#[cfg(test)]
mod tests;
use core::marker::PhantomData;
use core::mem;
pub trait FpBase: From<*const ()> + Sized {
fn is_unsafe(&self) -> bool;
}
pub unsafe trait CallFp<'f, Args, Ret>: FpBase {
type Raw;
fn as_fp(&self) -> Self:... | code_fim | hard | {
"lang": "rust",
"repo": "MTCoster/fp-types-rs",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[inline]
fn as_fp(&self) -> Self::Raw {
// SAFETY: Provided `Self::Raw` was implemented correctly, this will always be a
// safe conversion.
unsafe { mem::transmute(self.fp) }
}
#[inline]
unsafe f... | code_fim | hard | {
"lang": "rust",
"repo": "MTCoster/fp-types-rs",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aaliang/bittorrent path: /src/metadata.rs
use std::collections::HashMap;
use std::str;
use crypto::sha1::Sha1;
use crypto::digest::Digest;
use bencode::{Bencode, TypedMethods, BencodeToString};
#[derive(Clone, Debug)]
pub struct SingleFileInfo {
length: i64,
md5sum: Option<Vec<u8>>
}
#... | code_fim | hard | {
"lang": "rust",
"repo": "aaliang/bittorrent",
"path": "/src/metadata.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mode_info = match info_dict.get_list("files") {
Some(flist) => {
FileMode::MultiFile(MultiFileInfo {
files: to_file_list(flist).unwrap_or_else(|| panic!("unable to deserialize filelist"))
})
},
None => File... | code_fim | hard | {
"lang": "rust",
"repo": "aaliang/bittorrent",
"path": "/src/metadata.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cronokirby/iku path: /src/scopes.rs
use std::collections::HashMap;
#[derive(Debug)]
struct Scope<T> {
// If a scope is nested, then it has access to its parent scopes,
// otherwise it's detached from those scopes. When calling a function,
// that function has a completely new scope,... | code_fim | hard | {
"lang": "rust",
"repo": "cronokirby/iku",
"path": "/src/scopes.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Create a new variable in the current scope
// This panics if no scopes have been created
pub fn create<S: Into<String>>(&mut self, name: S, value: T) {
let name = name.into();
self.scopes.last_mut().unwrap().insert(name, value);
}
}<|fim_prefix|>// repo: cronokirby/iku ... | code_fim | hard | {
"lang": "rust",
"repo": "cronokirby/iku",
"path": "/src/scopes.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Insert a new variable, or replace an existing one
fn insert<S: Into<String>>(&mut self, name: S, value: T) {
self.vars.insert(name.into(), value);
}
}
/// This allows us to handle lexical scoping
///
/// This is useful for assigning types to variables, as well as assigned
/// values... | code_fim | hard | {
"lang": "rust",
"repo": "cronokirby/iku",
"path": "/src/scopes.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: YosiSF/solomon path: /solomon/causet-algebrizer/src/lib.rs
//Copyright 2020 WHTCORPS Inc
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use
// this file except in compliance with the License. You may obtain a copy of the
// License at http://www.apache.org/lice... | code_fim | hard | {
"lang": "rust",
"repo": "YosiSF/solomon",
"path": "/solomon/causet-algebrizer/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>use solomon_einstein::counter::RcCounter;
pub struct Known<'s, 'c> {
pub schema: &'s Schema,
pub cache: Option<&'c CachedCausets>,
}
impl<'s, 'c> Known<'s, 'c> {
pub fn for_schema(s: &'s Schema) -> Known<'s, 'static> {
Known {
schema: s,
cache: None,
}... | code_fim | hard | {
"lang": "rust",
"repo": "YosiSF/solomon",
"path": "/solomon/causet-algebrizer/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let arg1 = interp.data.pop().ok_or(Error::StackUndeflow)?;
let arg0 = interp.data.pop().ok_or(Error::StackUndeflow)?;
if let Value::Integer(a0) = arg0 {
if let Value::Integer(a1) = arg1 {
let a0_conv = a0;
let a1_conv = a1;
let r: u64 = u64::wrapping... | code_fim | hard | {
"lang": "rust",
"repo": "Dentosal/hepta-lang",
"path": "/src/builtins/generated/int.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Dentosal/hepta-lang path: /src/builtins/generated/int.rs
))
}
} else {
Err(Error::WrongArgumentType(
arg0.type_(),
vec![ValueType::Integer],
))
}
}
/// `wrapping_div_euc(u64, u64) -> u64`
fn f_wrapping_div_euc(interp: &mut Int... | code_fim | hard | {
"lang": "rust",
"repo": "Dentosal/hepta-lang",
"path": "/src/builtins/generated/int.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// `overflowing_sub(u64, u64) -> (u64, bool)`
fn f_overflowing_sub(interp: &mut Interpreter) -> Result<(), Error> {
let arg1 = interp.data.pop().ok_or(Error::StackUndeflow)?;
let arg0 = interp.data.pop().ok_or(Error::StackUndeflow)?;
if let Value::Integer(a0) = arg0 {
if let Value::In... | code_fim | hard | {
"lang": "rust",
"repo": "Dentosal/hepta-lang",
"path": "/src/builtins/generated/int.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jpJuni0r/WebGrid path: /core/src/main.rs
use anyhow::Result;
use opentelemetry::global;
use structopt::StructOpt;
#[cfg(feature = "orchestrator")]
use webgrid::services::orchestrator::{provisioners, Provisioner};
use webgrid::services::*;
#[derive(Debug, StructOpt)]
#[structopt(
about = "D... | code_fim | hard | {
"lang": "rust",
"repo": "jpJuni0r/WebGrid",
"path": "/core/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[cfg(feature = "storage")]
Command::Storage(options) => storage::run(shared_options, options).await?,
#[cfg(feature = "orchestrator")]
Command::Orchestrator(core_options) => match core_options.provisioner {
#[cfg(feature = "docker")]
Provisioner::D... | code_fim | hard | {
"lang": "rust",
"repo": "jpJuni0r/WebGrid",
"path": "/core/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[cfg(feature = "api")]
Api(api::Options),
}
#[tokio::main]
async fn main() -> Result<()> {
let main_options = MainOptions::from_args();
let shared_options = main_options.shared_options;
pretty_env_logger::formatted_timed_builder()
.parse_filters(&shared_options.log)
... | code_fim | hard | {
"lang": "rust",
"repo": "jpJuni0r/WebGrid",
"path": "/core/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: adrianparvino/stm32h743-http path: /src/main.rs
// #![deny(unsafe_code)]
#![deny(warnings)]
#![allow(unused_imports)]
#![allow(unused_must_use)]
#![allow(dead_code)]
#![no_std]
#![no_main]
use rtic::app;
mod cdc_ecm;
mod http_server;
mod request;
mod response_builder;
mod veth;
use defmt_rtt ... | code_fim | hard | {
"lang": "rust",
"repo": "adrianparvino/stm32h743-http",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let http_step::SharedResources {
mut sockets,
mut led,
} = ctx.shared;
let http_step::LocalResources { http_servers } = ctx.local;
sockets.lock(|sockets| {
for http_server in http_servers {
replace_with_or_abort(http_serv... | code_fim | hard | {
"lang": "rust",
"repo": "adrianparvino/stm32h743-http",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: eeskildsen/rust-learning path: /variables/src/main.rs
fn main() {
let tup: (i32, f64, u8) = (500, 6.4, 1);
let (_x, y, _z) = tup;
println!("The value of y is: {}", y);
println!("Here's another way of accessing the value of y: {}", tup.1);
// Add 2 to 2
println!("I'm plea... | code_fim | medium | {
"lang": "rust",
"repo": "eeskildsen/rust-learning",
"path": "/variables/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Iterate over an array
let a = [10, 20, 30, 40, 50];
for element in a.iter() {
println!("Here's a value from the array: {}", element);
}
// Iterate over a range
for number in (1..22).rev() {
println!("Here's a number from the range: {}", number);
}
}
fn add_... | code_fim | medium | {
"lang": "rust",
"repo": "eeskildsen/rust-learning",
"path": "/variables/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(target_os = "linux")]
pub const SECRET_ENVS_DYN_LIB_PATHS: &str = &"secret_envs_dynamic_libs/libdrl_mystery_envs_wrapper.so";
#[cfg(target_os = "macos")]
pub const SECRET_ENVS_DYN_LIB_PATHS: &str = &"secret_envs_dynamic_libs/libdrl_mystery_envs_wrapper.dylib";<|fim_prefix|>// repo: natane07/esgi_20... | code_fim | medium | {
"lang": "rust",
"repo": "natane07/esgi_2021_4a_IABD_drl_sample_project",
"path": "/drl_sample_project/src/do_not_touch/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: natane07/esgi_2021_4a_IABD_drl_sample_project path: /drl_sample_project/src/do_not_touch/mod.rs
pub mod result_structures;
#[allow(unused)]
mod single_agent_env_state_data_generated;
#[allow(unused)]
mod mdp_env_data_generated;
mod bytes_wrapper;
mod secret_envs_dynamic_libs_wrapper;
pub mod sec... | code_fim | medium | {
"lang": "rust",
"repo": "natane07/esgi_2021_4a_IABD_drl_sample_project",
"path": "/drl_sample_project/src/do_not_touch/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/rust-bindgen path: /bindgen-tests/tests/expectations/tests/issue-674-1.rs
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)]
pub mod root {
#[allow(unused_imports)]
use self::... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rust-bindgen",
"path": "/bindgen-tests/tests/expectations/tests/issue-674-1.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>Alignment of ", stringify!(CapturingContentInfo)),
);
assert_eq!(
unsafe { ::std::ptr::addr_of!((*ptr).a) as usize - ptr as usize },
0usize,
concat!(
"Offset of field: ",
stringify!(CapturingContentInfo),
"... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rust-bindgen",
"path": "/bindgen-tests/tests/expectations/tests/issue-674-1.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn map<F, U>(&self, data: &[U], mapper: F) where F: Fn(&U) -> T, U: Sync {
let Mapper { ref target, ref index, len } = *self;
let fetch_size = CACHE_LINE_SIZE * mem::size_of::<U>();
let mut_target = target.as_mut();
loop {
let mut i = index.fetch_add(... | code_fim | hard | {
"lang": "rust",
"repo": "weykon/rust-softrender",
"path": "/src/parallel.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: weykon/rust-softrender path: /src/parallel.rs
use std::cell::UnsafeCell;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::{ptr, mem};
// Common x86-64 cache line size
pub const CACHE_LINE_SIZE: usize = 64;
pub struct TrustedThreadSafe<T> {
inner: UnsafeCell<T>,
}
impl<T> TrustedTh... | code_fim | hard | {
"lang": "rust",
"repo": "weykon/rust-softrender",
"path": "/src/parallel.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> loop {
let mut i = index.fetch_add(fetch_size, Ordering::Relaxed);
if i < len {
let max = i + fetch_size;
let max = if max < len { max } else { len };
while i < max {
unsafe {
ptr:... | code_fim | hard | {
"lang": "rust",
"repo": "weykon/rust-softrender",
"path": "/src/parallel.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MPTGits/QuestGiverRustGame path: /src/lib.rs
use ggez::{graphics, Context, GameResult};
use ggez::event::{self, EventHandler};
pub struct MyGame {
// Your state here...
}
<|fim_suffix|> // Update code here...
Ok(())
}
fn draw(&mut self, context: &mut Context) -> Gam... | code_fim | hard | {
"lang": "rust",
"repo": "MPTGits/QuestGiverRustGame",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Update code here...
Ok(())
}
fn draw(&mut self, context: &mut Context) -> GameResult<()> {
graphics::clear(context, graphics::WHITE);
// Draw code here...
let player_img = graphics::Image::new(context, "/King/King_Idle_1.png").unwrap();
let dra... | code_fim | medium | {
"lang": "rust",
"repo": "MPTGits/QuestGiverRustGame",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rheinardkorf/advent-of-code-2019 path: /day5/main.rs
use std::io;
use std::env;
use std::fs::File;
use std::io::{BufRead, BufReader, Result};
fn get_input(filename: String) -> Vec<i32> {
let file = File::open(filename).expect("File could not be read.");
let mut line = String::new();
... | code_fim | hard | {
"lang": "rust",
"repo": "rheinardkorf/advent-of-code-2019",
"path": "/day5/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let ref1 = intcode[p1];
let ref2 = intcode[p2];
let val1 = if p1m == 0 { intcode[ref1 as usize] } else { ref1 };
let val2 = if p2m == 0 { intcode[ref2 as usize] } else { ref2 };
if val1 == 0 {
jump = true;... | code_fim | hard | {
"lang": "rust",
"repo": "rheinardkorf/advent-of-code-2019",
"path": "/day5/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: paulwratt/customasm path: /src/asm/invokation.rs
use crate::*;
#[derive(Debug)]
pub struct Invokation
{
pub ctx: asm::Context,
pub size_guess: usize,
pub span: diagn::Span,
pub kind: InvokationKind,
}
#[derive(Debug)]
pub enum InvokationKind
{
Rule(RuleInvokation),
Da... | code_fim | hard | {
"lang": "rust",
"repo": "paulwratt/customasm",
"path": "/src/asm/invokation.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> panic!();
}
pub fn get_data_invok(&self) -> &DataInvokation
{
if let InvokationKind::Data(ref data_invok) = self.kind
{
return data_invok;
}
panic!();
}
}<|fim_prefix|>// repo: paulwratt/customasm path: /src/asm/invokation.rs
use crat... | code_fim | hard | {
"lang": "rust",
"repo": "paulwratt/customasm",
"path": "/src/asm/invokation.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn get_data_invok(&self) -> &DataInvokation
{
if let InvokationKind::Data(ref data_invok) = self.kind
{
return data_invok;
}
panic!();
}
}<|fim_prefix|>// repo: paulwratt/customasm path: /src/asm/invokation.rs
use crate::*;
#[derive(Debug)]
p... | code_fim | medium | {
"lang": "rust",
"repo": "paulwratt/customasm",
"path": "/src/asm/invokation.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use super::Additive as A;
use super::*;
#[test]
fn additive() {
assert_eq!(A::<i32>::id().0, 0);
assert_eq!(A::inv(A(2)).0, -2);
assert_eq!(A::op(A(1), A(2)).0, 3);
}
}<|fim_prefix|>// repo: statiolake/procon-lib-rs path: /src/pcl/trai... | code_fim | hard | {
"lang": "rust",
"repo": "statiolake/procon-lib-rs",
"path": "/src/pcl/traits/math/group.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: statiolake/procon-lib-rs path: /src/pcl/traits/math/group.rs
//! 群の定義といくつかの実装。
use super::monoid::Monoid;
/// 群
///
/// M が群であるとは、M が次の条件を満たす集合であることをいう。
///
/// - モノイドである
/// - 逆元の存在
/// 任意の M の元 x に対して inv(x) が存在して op(x, inv(x)) = x 。
pub trait Group: Monoid {
/// 逆元
fn inv(x: Sel... | code_fim | hard | {
"lang": "rust",
"repo": "statiolake/procon-lib-rs",
"path": "/src/pcl/traits/math/group.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mephistopheles-8/basicweb-rust-experiments path: /app/src/routes/item.rs
use crate::db::DbPool;
use crate::actions::item::*;
use crate::models;
use actix_web::{web,HttpResponse};
pub async fn item_create_json(
data : web::Json<models::ItemUpd>
, pool: web::Data<DbPool>
) -> Result<... | code_fim | hard | {
"lang": "rust",
"repo": "mephistopheles-8/basicweb-rust-experiments",
"path": "/app/src/routes/item.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub async fn item_name_by_id_json(
path: web::Path<i32>
, pool: web::Data<DbPool>
) -> Result<HttpResponse,actix_web::Error> {
let conn = pool.get().expect("couldn't get db connection from pool");
// use web::block to offload blocking Diesel code without blocking server thread
let ... | code_fim | hard | {
"lang": "rust",
"repo": "mephistopheles-8/basicweb-rust-experiments",
"path": "/app/src/routes/item.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: EFanZh/LeetCode path: /src/problem_1526_minimum_number_of_increments_on_subarrays_to_form_a_target_array/greedy.rs
pub struct Solution;
// ------------------------------------------------------ snip ------------------------------------------------------ //
<|fim_suffix|>#[cfg(test)]
mod tests ... | code_fim | hard | {
"lang": "rust",
"repo": "EFanZh/LeetCode",
"path": "/src/problem_1526_minimum_number_of_increments_on_subarrays_to_form_a_target_array/greedy.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // NB: The marker position doesn't consider Unicode combining characters nor fullwidth
// characters, but that would probably be overkill here ...
let marker_start = if (line_start..line_end).contains(&span.start()) {
context.extend(
... | code_fim | hard | {
"lang": "rust",
"repo": "AudioSceneDescriptionFormat/asdf-rust",
"path": "/src/parser/error.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(thiserror::Error, Debug)]
pub enum IntegrityError {
#[error("Non-existing ID used in \"apply-to\": {:?}", .0)]
NonExistingId(String),
#[error("Multiple rotations applying to ID {:?}", .0)]
MultipleRotations(String),
#[error("\"apply-to\" cycle involving ID {:?}", .0)]
Cycl... | code_fim | hard | {
"lang": "rust",
"repo": "AudioSceneDescriptionFormat/asdf-rust",
"path": "/src/parser/error.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AudioSceneDescriptionFormat/asdf-rust path: /src/parser/error.rs
use std::io;
use std::iter;
use xmlparser as xml;
#[derive(thiserror::Error, Debug)]
#[error("{msg}\n---{context}\n---")]
pub struct ParseError {
msg: String,
context: String,
source: Option<Box<dyn std::error::Error>... | code_fim | hard | {
"lang": "rust",
"repo": "AudioSceneDescriptionFormat/asdf-rust",
"path": "/src/parser/error.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: agdust/lumber path: /src/ast/procession.rs
use super::*;
use crate::parser::Rule;
/// A sequence of steps.
#[derive(Default, Clone, Debug)]
pub(crate) struct Procession {
/// Steps between which backtracking is skipped..
pub(crate) steps: Vec<Unification>,
}
impl Procession {
pub f... | code_fim | medium | {
"lang": "rust",
"repo": "agdust/lumber",
"path": "/src/ast/procession.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn identifiers<'a>(&'a self) -> impl Iterator<Item = Identifier> + 'a {
self.steps.iter().flat_map(|step| step.identifiers())
}
}<|fim_prefix|>// repo: agdust/lumber path: /src/ast/procession.rs
use super::*;
use crate::parser::Rule;
/// A sequence of steps.
#[derive(Default, Clone, ... | code_fim | hard | {
"lang": "rust",
"repo": "agdust/lumber",
"path": "/src/ast/procession.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /*
Döngü başlatılan thread'leri bir vector'de topluyor.
Eğer move closure'ını kullanmazsak i değişkeni sahipliğinin ödünç olarak thread içerisine alınamamasından dolayı
derleme zamanı hatası alırız.
*/
let mut threads = vec![];
for i in 0..5 {
threads.push... | code_fim | medium | {
"lang": "rust",
"repo": "learnMoreCode/skynet",
"path": "/No 32 - Who are you Rust/src/multi_join/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // println!("{} sonlandı", i);
}));
}
// Bitmeyen thread'ler için Main bekletiliyor.
for t in threads {
let result = t.join();
match result {
Ok(r) => {
println!("#{} tamamlandı", r); // Tamamlanan thread'den dönen değeri r ile a... | code_fim | hard | {
"lang": "rust",
"repo": "learnMoreCode/skynet",
"path": "/No 32 - Who are you Rust/src/multi_join/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: learnMoreCode/skynet path: /No 32 - Who are you Rust/src/multi_join/src/main.rs
/*
join() kullanımı ile ilgili başka bir kod parçası.
Bu sefer n adet thread'i bir döngü ile başlatıyor
bu döngülerde tamamen sembolik olarak uzun sürecek aynı işleri planlıyor
ve main thread'i her bi... | code_fim | hard | {
"lang": "rust",
"repo": "learnMoreCode/skynet",
"path": "/No 32 - Who are you Rust/src/multi_join/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl AddressRegisterConnector {
pub(crate) fn new(register: &Rc<RefCell<AddressRegister>>) -> AddressRegisterConnector {
AddressRegisterConnector {
register: register.clone(),
}
}
}
impl InputOutputDevice for AddressRegisterConnector {
#[inline]
fn read(&self) ... | code_fim | medium | {
"lang": "rust",
"repo": "AgustinCB/emulators",
"path": "/nes/src/lib/ppu/address_register.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AgustinCB/emulators path: /nes/src/lib/ppu/address_register.rs
use nes::InputOutputDevice;
use std::cell::RefCell;
use std::rc::Rc;
pub(crate) struct AddressRegister {
pub(crate) value: u8,
}
<|fim_suffix|> (*self.register.borrow()).value
}
#[inline]
fn write(&mut self, ... | code_fim | hard | {
"lang": "rust",
"repo": "AgustinCB/emulators",
"path": "/nes/src/lib/ppu/address_register.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tastyporkchop/DND2ndCharsheet path: /src/lib.rs
use crate::character_model::Character;
use log::Level;
use mogwai::prelude::*;
use std::panic;
use std::result::Result;
use wasm_bindgen::prelude::*;
<|fim_suffix|>#[wasm_bindgen]
pub fn main() -> Result<(), JsValue> {
panic::set_hook(Box::new... | code_fim | hard | {
"lang": "rust",
"repo": "tastyporkchop/DND2ndCharsheet",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let character = Character {
..Default::default()
};
character.into_component().run()
}<|fim_prefix|>// repo: tastyporkchop/DND2ndCharsheet path: /src/lib.rs
use crate::character_model::Character;
use log::Level;
use mogwai::prelude::*;
use std::panic;
use std::result::Result;
use wasm... | code_fim | hard | {
"lang": "rust",
"repo": "tastyporkchop/DND2ndCharsheet",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Multiples of 15 were double-counted, so we
// should subtract them from the result.
let total = sum_mul3 + sum_mul5 - sum_mul15;
println!("{}", total);
}<|fim_prefix|>// repo: ryanavella/projecteuler path: /rust/src/bin/p001.rs
fn triangular_num(n: u32) -> u32 {
n * (n + 1) / 2
}
... | code_fim | medium | {
"lang": "rust",
"repo": "ryanavella/projecteuler",
"path": "/rust/src/bin/p001.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ryanavella/projecteuler path: /rust/src/bin/p001.rs
fn triangular_num(n: u32) -> u32 {
n * (n + 1) / 2
}
<|fim_suffix|> let limit = 1000 - 1;
let sum_mul3 = 3 * triangular_num(limit / 3);
let sum_mul5 = 5 * triangular_num(limit / 5);
let sum_mul15 = 15 * triangular_num(limit... | code_fim | easy | {
"lang": "rust",
"repo": "ryanavella/projecteuler",
"path": "/rust/src/bin/p001.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: davidoster/fcp path: /dev_utils/src/lib.rs
use fcp::{self, filesystem as fs};
use lazy_static::lazy_static;
use rand::prelude::*;
use rand::{Rng, SeedableRng};
use rand_pcg::Pcg64;
use rayon::prelude::{IntoParallelIterator, ParallelIterator};
use serde::Deserialize;
use serde_json::Deserializer;... | code_fim | hard | {
"lang": "rust",
"repo": "davidoster/fcp",
"path": "/dev_utils/src/lib.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Deserialize)]
struct FileStub {
name: String,
mode: u32,
#[serde(flatten)]
kind: FileKind,
}
pub fn remove(path: &Path) {
if let Ok(metadata) = fs::symlink_metadata(path) {
if metadata.is_dir() {
fs::remove_dir_all(path)
} else {
... | code_fim | hard | {
"lang": "rust",
"repo": "davidoster/fcp",
"path": "/dev_utils/src/lib.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: williele/wigame path: /crates/render/src/renderable.rs
use crate::{buffer::Vertex, material::Material};
use wgpu::util::DeviceExt;
pub struct Renderable {
material: Material,
vertex_buffer: wgpu::Buffer,
indices_buffer: wgpu::Buffer,
}
impl Renderable {
pub fn new(device: &wgpu... | code_fim | hard | {
"lang": "rust",
"repo": "williele/wigame",
"path": "/crates/render/src/renderable.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pass.set_vertex_buffer(0, self.vertex_buffer.slice(..));
pass.set_index_buffer(self.indices_buffer.slice(..), wgpu::IndexFormat::Uint16);
pass.draw_indexed(0..6, 0, 0..1);
}
}<|fim_prefix|>// repo: williele/wigame path: /crates/render/src/renderable.rs
use crate::{buffer::Ver... | code_fim | hard | {
"lang": "rust",
"repo": "williele/wigame",
"path": "/crates/render/src/renderable.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Self {
material,
vertex_buffer,
indices_buffer,
}
}
pub fn render<'a, 'b>(
&'a self,
pass: &'b mut wgpu::RenderPass<'a>,
ctx_bind_group: &'a wgpu::BindGroup,
) {
self.material.binding(pass, ctx_bind_group);
... | code_fim | hard | {
"lang": "rust",
"repo": "williele/wigame",
"path": "/crates/render/src/renderable.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/librustc_codegen_ssa/traits/misc.rs
use super::BackendTypes;
use rustc::mir::mono::CodegenUnit;
use rustc::session::Session;
use rustc::ty::{self, Instance, Ty};
use rustc::util::nodemap::FxHashMap;
use std::cell::RefCell;
use std::sync::Arc;
pub trait... | code_fim | hard | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/librustc_codegen_ssa/traits/misc.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn sess(&self) -> &Session;
fn codegen_unit(&self) -> &Arc<CodegenUnit<'tcx>>;
fn used_statics(&self) -> &RefCell<Vec<Self::Value>>;
fn set_frame_pointer_elimination(&self, llfn: Self::Function);
fn apply_target_cpu_attr(&self, llfn: Self::Function);
fn create_used_variable(&self);... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/librustc_codegen_ssa/traits/misc.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn get_fn(&self, instance: Instance<'tcx>) -> Self::Function;
fn get_fn_addr(&self, instance: Instance<'tcx>) -> Self::Value;
fn eh_personality(&self) -> Self::Value;
fn eh_unwind_resume(&self) -> Self::Value;
fn sess(&self) -> &Session;
fn codegen_unit(&self) -> &Arc<CodegenUnit<'... | code_fim | hard | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/librustc_codegen_ssa/traits/misc.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // but Rust has iterators, shiney! (you don't get access to the
// loop counter though)
for element in a.iter() {
println!("[Iterator] The value on is {}", element);
}
// we can define ranges and loop over those
for number in (1..4).rev() {
println!("{}!", number)... | code_fim | hard | {
"lang": "rust",
"repo": "mboogerd/hello-rust",
"path": "/src/ch3-control-flow.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mboogerd/hello-rust path: /src/ch3-control-flow.rs
fn main() {
// Control flow
let number = 3;
// if-else-if statement; if expects an expression that
// evaluates to boolean.
if number < 5 {
println!("{} < 5", number);
} else if number > 5 {
println!("{} ... | code_fim | medium | {
"lang": "rust",
"repo": "mboogerd/hello-rust",
"path": "/src/ch3-control-flow.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: movb/esaxx-rs path: /src/sais.rs
{
let mut sum = 0;
if end {
b.iter_mut().enumerate().for_each(|(i, b_el)| {
sum += c[i];
*b_el = sum;
});
} else {
b.iter_mut().enumerate().for_each(|(i, b_el)| {
*b_el = sum;
sum... | code_fim | hard | {
"lang": "rust",
"repo": "movb/esaxx-rs",
"path": "/src/sais.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: movb/esaxx-rs path: /src/sais.rs
_k: usize, end: bool) {
let mut sum = 0;
if end {
b.iter_mut().enumerate().for_each(|(i, b_el)| {
sum += c[i];
*b_el = sum;
});
} else {
b.iter_mut().enumerate().for_each(|(i, b_el)| {
*b_el... | code_fim | hard | {
"lang": "rust",
"repo": "movb/esaxx-rs",
"path": "/src/sais.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_induce_sa_long() {
let string = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen b... | code_fim | hard | {
"lang": "rust",
"repo": "movb/esaxx-rs",
"path": "/src/sais.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gcapell/aoc2020 path: /src/day20.rs
use std::fs;
use std::fmt;
use std::cmp::min;
use std::collections::HashMap;
pub fn run() {
let tile_str = fs::read_to_string("input.txt").unwrap();
let tiles:Vec<Tile> = tile_str.trim().split("\n\n").map(Tile::new).collect();
let mut matchings: ... | code_fim | hard | {
"lang": "rust",
"repo": "gcapell/aoc2020",
"path": "/src/day20.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Tile {
fn new(s: &str) -> Tile {
let lines = s.lines().collect::<Vec<&str>>();
let west = lines[1..]
.iter()
.map(|x| x.chars().next().unwrap())
.collect::<String>();
let east = lines[1..]
.iter()
.map(|x| x.char... | code_fim | hard | {
"lang": "rust",
"repo": "gcapell/aoc2020",
"path": "/src/day20.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: FofanovLab/mtsv_tools path: /ssw/src/lib.rs
//! (Mostly) safe bindings to Mengyao Zhao's SIMD implementation of Smith-Waterman.
//!
//! Currently limited to processing DNA5 sequences.
#![warn(missing_docs)]
extern crate libc;
/// Identity matrix for matching.
#[cfg_attr(rustfmt, rustfmt_skip)... | code_fim | hard | {
"lang": "rust",
"repo": "FofanovLab/mtsv_tools",
"path": "/ssw/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if query.len() < 32 || reference.len() < 32 {
return true;
}
let query_bytes = query.iter().map(|base| base.0).collect::<Vec<u8>>();
let reference_bytes = reference.iter().map(|base| base.0).collect::<Vec<u8>>();
let scorer = |a... | code_fim | hard | {
"lang": "rust",
"repo": "FofanovLab/mtsv_tools",
"path": "/ssw/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wycats/argon path: /crates/argon/src/compile/function.rs
use super::body::compile_body;
use crate::{annotated, MathType, Type};
use parity_wasm::{builder, elements};
crate fn compile_function(
function: builder::FunctionBuilder,
input: &annotated::Function,
) -> builder::FunctionDefinit... | code_fim | hard | {
"lang": "rust",
"repo": "wycats/argon",
"path": "/crates/argon/src/compile/function.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn wasm_type(input: &Type) -> Option<elements::ValueType> {
match input {
Type::Math(ty) => match ty {
MathType::F32 => Some(elements::ValueType::F32),
MathType::F64 => Some(elements::ValueType::F64),
MathType::U32 | MathType::I32 => Some(elements::ValueType... | code_fim | hard | {
"lang": "rust",
"repo": "wycats/argon",
"path": "/crates/argon/src/compile/function.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// Ignoring "interpolated", not expected to work yet.<|fim_prefix|>// repo: glebm/rsass path: /tests/libsass/selectors/variables/multiple/mod.rs
//! Tests auto-converted from "sass-spec/spec/libsass/selectors/variables/multiple"
#[allow(unused)]
use super::rsass;
#[allow(unused)]
use rsass::precision;
<... | code_fim | easy | {
"lang": "rust",
"repo": "glebm/rsass",
"path": "/tests/libsass/selectors/variables/multiple/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: glebm/rsass path: /tests/libsass/selectors/variables/multiple/mod.rs
//! Tests auto-converted from "sass-spec/spec/libsass/selectors/variables/multiple"
#[allow(unused)]
use super::rsass;
#[allow(unused)]
use rsass::precision;
<|fim_suffix|>// Ignoring "interpolated", not expected to work yet.<... | code_fim | easy | {
"lang": "rust",
"repo": "glebm/rsass",
"path": "/tests/libsass/selectors/variables/multiple/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RUSTools/autograph path: /src/neural_network/autograd.rs
use crate::Result;
use crate::backend::Device;
use crate::tensor::{Dimension, OwnedRepr, ArcRepr, ArcTensor, TensorViewD, TensorViewMutD};
use std::sync::Arc;
use std::sync::atomic::{AtomicUsize, Ordering};
use smol::lock::Mutex;
use std::... | code_fim | hard | {
"lang": "rust",
"repo": "RUSTools/autograph",
"path": "/src/neural_network/autograd.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>enum DynBackwardOp {
F32(Box<dyn BackwardOp<Elem=f32>>)
}
#[doc(hidden)]
pub struct VariableId {
gen: usize,
id: usize
}
#[doc(hidden)]
pub struct ParameterId(usize);
#[doc(hidden)]
pub enum GraphId {
Variable(VariableId),
Parameter(ParameterId),
}
#[doc(hidden)]
pub struct GraphBa... | code_fim | hard | {
"lang": "rust",
"repo": "RUSTools/autograph",
"path": "/src/neural_network/autograd.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// CHECK-LABEL: @unchecked_sub_signed
#[no_mangle]
pub unsafe fn unchecked_sub_signed(a: i32, b: i32) -> i32 {
// CHECK: sub nsw
unchecked_sub(a, b)
}
// CHECK-LABEL: @unchecked_sub_unsigned
#[no_mangle]
pub unsafe fn unchecked_sub_unsigned(a: u32, b: u32) -> u32 {
// CHECK: sub nuw
unche... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/codegen/intrinsics/unchecked_math.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/codegen/intrinsics/unchecked_math.rs
#![crate_type = "lib"]
#![feature(core_intrinsics)]
use std::intrinsics::*;
// CHECK-LABEL: @unchecked_add_signed
#[no_mangle]
pub unsafe fn unchecked_add_signed(a: i32, b: i32) -> i32 {
// CHECK: add nsw
... | code_fim | hard | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/codegen/intrinsics/unchecked_math.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// CHECK-LABEL: @unchecked_mul_unsigned
#[no_mangle]
pub unsafe fn unchecked_mul_unsigned(a: u32, b: u32) -> u32 {
// CHECK: mul nuw
unchecked_mul(a, b)
}<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/codegen/intrinsics/unchecked_math.rs
#![crate_type = "lib"]
#![feature(c... | code_fim | hard | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/codegen/intrinsics/unchecked_math.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AtheMathmo/learning-machines path: /src/models/k_means.rs
use rm::learning::UnSupModel;
use rm::learning::k_means::KMeansClassifier;
use iron::prelude::*;
use iron::status;
use iron::error::HttpError;
use std::io::{Error, ErrorKind};
use rustc_serialize::json::{ToJson, Object};
use super::Mode... | code_fim | hard | {
"lang": "rust",
"repo": "AtheMathmo/learning-machines",
"path": "/src/models/k_means.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let clusters = match input.get("k") {
Some(k) => {
match k.as_u64() {
Some(k) => k as usize,
None => {
return Err(IronError::new(HttpError::Io(Error::new(ErrorKind::InvalidData,
... | code_fim | hard | {
"lang": "rust",
"repo": "AtheMathmo/learning-machines",
"path": "/src/models/k_means.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> model.train(&input_data);
// let centroids = model.centroids().as_ref().unwrap();
let output = model.predict(&input_data);
Ok(Response::with((status::Ok, format!("{0}", output.data().to_json()))))
}
}<|fim_prefix|>// repo: AtheMathmo/learning-machines path: /src/mode... | code_fim | hard | {
"lang": "rust",
"repo": "AtheMathmo/learning-machines",
"path": "/src/models/k_means.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let width: f64 = split.next().unwrap().parse().unwrap();
let length: f64 = split.next().unwrap().parse().unwrap();
accum += width * length;
}
let result = accum * c as f64;
println!("{}", result);
}<|fim_prefix|>// repo: Bugvi-Benjamin-M/Kattis path: /rust/grass-seed... | code_fim | medium | {
"lang": "rust",
"repo": "Bugvi-Benjamin-M/Kattis",
"path": "/rust/grass-seed-inc/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Bugvi-Benjamin-M/Kattis path: /rust/grass-seed-inc/src/main.rs
fn input() -> String {
let mut input = String::new();
std::io::stdin().read_line(&mut input).expect("Failed to read from input");
input
}
<|fim_suffix|> accum += width * length;
}
let result = accum * c a... | code_fim | hard | {
"lang": "rust",
"repo": "Bugvi-Benjamin-M/Kattis",
"path": "/rust/grass-seed-inc/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut accum = 0.0;
for _ in 0..l {
let line = input().trim().to_owned();
let mut split = line.split_ascii_whitespace();
let width: f64 = split.next().unwrap().parse().unwrap();
let length: f64 = split.next().unwrap().parse().unwrap();
accum += width * ... | code_fim | medium | {
"lang": "rust",
"repo": "Bugvi-Benjamin-M/Kattis",
"path": "/rust/grass-seed-inc/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 422404/Lang path: /parser/src/ast/mod.rs
mod file;
mod node;
mod attribute;
mod function;
mod param;
mod expression;
mod statement;
mod closure;
mod variable;
mod class;
mod litterals;
pub use self::{
file::{File, FirstClassEntity},
node::{FromPair, AstNode, ToAny, AstNodeType},
att... | code_fim | medium | {
"lang": "rust",
"repo": "422404/Lang",
"path": "/parser/src/ast/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>{VariableDeclaration, VariableAffectation},
class::{Class, ClassMember, Field, Block},
litterals::{Identifier, StringLitteral, Integer, Char, Boolean}
};<|fim_prefix|>// repo: 422404/Lang path: /parser/src/ast/mod.rs
mod file;
mod node;
mod attribute;
mod function;
mod param;
mod expression;
mod ... | code_fim | medium | {
"lang": "rust",
"repo": "422404/Lang",
"path": "/parser/src/ast/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Player {
pub fn new(order: usize, name: String) -> Player {
Player {
name: name,
order: order,
key: Uuid::new_v4()
}
}
}
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
pub struct Tile {
pub id: u32,
pub image: String... | code_fim | hard | {
"lang": "rust",
"repo": "Direside/spiritwood",
"path": "/src/api.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Default for GameState {
fn default() -> GameState {
GameState::WAITING
}
}
// Players send these to the server, which responds with Turns
// all should have time and signature
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum Move {
ReadyToStart { name: String },
Place... | code_fim | medium | {
"lang": "rust",
"repo": "Direside/spiritwood",
"path": "/src/api.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Direside/spiritwood path: /src/api.rs
use uuid::Uuid;
pub type Etag = Uuid;
pub type Key = Uuid;
pub type Href = String;
#[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq, Eq)]
pub enum GameState { WAITING, PLAYING, FINISHED }
<|fim_suffix|>// Players send these to the server, wh... | code_fim | hard | {
"lang": "rust",
"repo": "Direside/spiritwood",
"path": "/src/api.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: papertigers/nictagadm path: /src/utils.rs
use regex;
use std::collections::HashMap;
use std::io::BufRead;
/// Parse a config file that's made up of lines like "foo=bar".
/// Takes an optional regex filter that will be<|fim_suffix|> continue;
}
}
if let Some(pos) =... | code_fim | hard | {
"lang": "rust",
"repo": "papertigers/nictagadm",
"path": "/src/utils.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> continue;
}
}
if let Some(pos) = line.find('=') {
map.insert(line[..pos].to_string(), line[(pos + 1)..].to_string());
}
}
}<|fim_prefix|>// repo: papertigers/nictagadm path: /src/utils.rs
use regex;
use std::collections::HashMap;
use std::io::BufRea... | code_fim | hard | {
"lang": "rust",
"repo": "papertigers/nictagadm",
"path": "/src/utils.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.