text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|>impl<S, E> Stream for TimedStream<S, E> where S: Stream<Error = E>, E: From<tokio::timer::Error>, { type Item = S::Item; type Error = S::Error; fn poll(&mut self) -> Poll<Option<Self::Item>, Self::Error> { use futures::Async; let _ = try_ready!(self.delay.poll().map_e...
code_fim
hard
{ "lang": "rust", "repo": "zoosky/rust-trending", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Ok(RustTrending { config, storage, token, }) } pub fn run_loop(self) -> impl Future<Item = (), Error = Error> { use futures::future::ok; use futures::stream::iter_ok; use std::sync::Arc; use tokio::timer::Interval...
code_fim
hard
{ "lang": "rust", "repo": "zoosky/rust-trending", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut scope = Scope { space: f.params.to_vec(), parent: Some(parent_scope), }; let (ret, stmts) = typecheck_stmt(&mut scope, &f.stmts); if ret != f.ret { panic!("function return type {} doesn't match {}", ret, f.ret); } Fn { params: params, ...
code_fim
hard
{ "lang": "rust", "repo": "mytchel/lang", "path": "/src/typechecker.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mytchel/lang path: /src/typechecker.rs use crate::lexer::Token; use crate::parser::{ Type, Expr, Stmt, Fn, Prog }; struct Scope<'a> { space: Vec<(String, Type)>, parent: Option<&'a Scope<'a>>, } fn scope_get<'a>(scope: &'a Scope, name: &str) -> Option<&'a Type> { ...
code_fim
hard
{ "lang": "rust", "repo": "mytchel/lang", "path": "/src/typechecker.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn handler(&mut self, event: MediaQueryListEvent) { assert_eq!(event.matches(), false); let closure = self .closure .as_ref() .expect("DevicePixelRatioChangeDetector::closure should not be None"); let mql = self .mql ....
code_fim
hard
{ "lang": "rust", "repo": "ryanisaacg/winit", "path": "/src/platform_impl/web/web_sys/scaling.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ryanisaacg/winit path: /src/platform_impl/web/web_sys/scaling.rs use super::super::ScaleChangeArgs; use std::{cell::RefCell, rc::Rc}; use wasm_bindgen::{prelude::Closure, JsCast}; use web_sys::{MediaQueryList, MediaQueryListEvent}; pub struct ScaleChangeDetector(Rc<RefCell<ScaleChangeDetectorI...
code_fim
hard
{ "lang": "rust", "repo": "ryanisaacg/winit", "path": "/src/platform_impl/web/web_sys/scaling.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: devforfu/rust path: /web/src/bin/main.rs use std::{fs, env, thread}; use std::io::{Read, Write}; use std::net::{TcpListener, TcpStream}; use std::time::Duration; use web::{Config, ThreadPool}; fn main() { let config = Config::default(); let listener = TcpListener::bind(config.address())...
code_fim
hard
{ "lang": "rust", "repo": "devforfu/rust", "path": "/web/src/bin/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let test_input = "sesenwnenenewseeswwswswwnenewsewsw neeenesenwnwwswnenewnwwsewnenwseswesw seswneswswsenwwnwse nwnwneseeswswnenewneswwnewseswneseene swweswneswnenwsewnwneneseenw eesenwseswswnenwswnwnwsewwnwsene sewnenenenesenwsewnenwwwse wenwwweseeeweswwwnwwe wsweesenenewnwwnwsenewsenwwsesesenwne nees...
code_fim
hard
{ "lang": "rust", "repo": "mihajlo-jovanovic/advent-of-code", "path": "/2020/rust/src/day24.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mihajlo-jovanovic/advent-of-code path: /2020/rust/src/day24.rs use itertools::Itertools; use std::collections::HashMap; #[aoc_generator(day24)] fn parse_tiles(input: &str) -> Vec<(i32, i32)> { input.lines().map(|l| parse_single_tile(l)).collect() } #[aoc(day24, part1)] fn part1(input: &[(i...
code_fim
hard
{ "lang": "rust", "repo": "mihajlo-jovanovic/advent-of-code", "path": "/2020/rust/src/day24.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> truncated.iter().all(|t| primes.contains(t)) } fn slice_to_num(p: &[usize]) -> usize { p.iter().fold(0, |acc, x| acc * 10 + x) }<|fim_prefix|>// repo: shioyama18/project-euler path: /src/solution/p037.rs /// [Truncatable primes](https://projecteuler.net/problem=37) /// /// solve() returns sum of...
code_fim
medium
{ "lang": "rust", "repo": "shioyama18/project-euler", "path": "/src/solution/p037.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for i in 1..digits { truncated.push(slice_to_num(&p[i..])); truncated.push(slice_to_num(&p[..i])); } truncated.iter().all(|t| primes.contains(t)) } fn slice_to_num(p: &[usize]) -> usize { p.iter().fold(0, |acc, x| acc * 10 + x) }<|fim_prefix|>// repo: shioyama18/project-e...
code_fim
medium
{ "lang": "rust", "repo": "shioyama18/project-euler", "path": "/src/solution/p037.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: shioyama18/project-euler path: /src/solution/p037.rs /// [Truncatable primes](https://projecteuler.net/problem=37) /// /// solve() returns sum of 11 primes that are truncatable from both side /// i.e. 3797 -> 797 -> 97 -> 7 and 3797 -> 379 -> 37 -> 3 are all primes /// /// # Example /// /// ```i...
code_fim
medium
{ "lang": "rust", "repo": "shioyama18/project-euler", "path": "/src/solution/p037.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>gsVariable { /// The value of environment variable. #[serde(rename = "value")] pub value: String, }<|fim_prefix|>// repo: cholcombe973/isilon path: /src/models/ndmp_settings_variable.rs #[allow(unused_imports)] use serde_json::Value; #[deri<|fim_middle|>ve(Debug, Serialize, Deserialize)] pub...
code_fim
easy
{ "lang": "rust", "repo": "cholcombe973/isilon", "path": "/src/models/ndmp_settings_variable.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cholcombe973/isilon path: /src/models/ndmp_settings_variable.rs #[allow(unused_imports)] use serde_json::Value; #[deri<|fim_suffix|>gsVariable { /// The value of environment variable. #[serde(rename = "value")] pub value: String, }<|fim_middle|>ve(Debug, Serialize, Deserialize)] pub...
code_fim
easy
{ "lang": "rust", "repo": "cholcombe973/isilon", "path": "/src/models/ndmp_settings_variable.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub use accumulator::Accumulator; pub use aggregate_function::AggregateFunction; pub use built_in_function::BuiltinScalarFunction; pub use columnar_value::ColumnarValue; pub use expr::{ Between, BinaryExpr, Case, Cast, Expr, GetIndexedField, GroupingSet, Like, TryCast, }; pub use expr_fn::*; pub use e...
code_fim
hard
{ "lang": "rust", "repo": "biaoma-ty/arrow-datafusion", "path": "/datafusion/expr/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: biaoma-ty/arrow-datafusion path: /datafusion/expr/src/lib.rs // Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses ...
code_fim
hard
{ "lang": "rust", "repo": "biaoma-ty/arrow-datafusion", "path": "/datafusion/expr/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>mod accumulator; pub mod aggregate_function; pub mod array_expressions; mod built_in_function; mod columnar_value; pub mod conditional_expressions; pub mod expr; pub mod expr_fn; pub mod expr_rewriter; pub mod expr_schema; pub mod field_util; pub mod function; mod literal; pub mod logical_plan; mod nullif...
code_fim
hard
{ "lang": "rust", "repo": "biaoma-ty/arrow-datafusion", "path": "/datafusion/expr/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: krzysz00/rust-kernel path: /kernel/lazy_global.rs use core::cell::UnsafeCell; pub struct LazyGlobal<T> { data: UnsafeCell<Option<T>>, } <|fim_suffix|> pub unsafe fn get_mut<'a>(&'a self) -> &'a mut T { match *self.data.get() { Some(ref mut val) => val, No...
code_fim
hard
{ "lang": "rust", "repo": "krzysz00/rust-kernel", "path": "/kernel/lazy_global.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // You must call this before using the global pub unsafe fn init(&self, val: T) { *self.data.get() = Some(val); } pub unsafe fn get<'a>(&'a self) -> &'a T { match *self.data.get() { Some(ref val) => val, None => panic!("Lazy global not initialized")...
code_fim
hard
{ "lang": "rust", "repo": "krzysz00/rust-kernel", "path": "/kernel/lazy_global.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lucifer1004/AtCoder path: /arc116/src/bin/d.rs use proconio::input; const MOD: usize = 998_244_353; const N: usize = 10_000; fn fexp(mut x: usize, mut y: usize) -> usize { let mut ans = 1; while y > 0 { if y & 1 == 1 { ans = ans * x % MOD; } x = x * ...
code_fim
medium
{ "lang": "rust", "repo": "lucifer1004/AtCoder", "path": "/arc116/src/bin/d.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fexp(x, MOD - 2) } fn main() { input! { n: usize, m: usize, }; if m % 2 == 1 || n == 1 { println!("0"); std::process::exit(0); } let mut fac = vec![1usize; N + 1]; let mut ifac = vec![1usize; N + 1]; for i in 2..=N { fac[i] = fac[i...
code_fim
medium
{ "lang": "rust", "repo": "lucifer1004/AtCoder", "path": "/arc116/src/bin/d.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>) is empty", source)] SourceEmpty { source: String, } }<|fim_prefix|>// repo: isgasho/unhtml.rs path: /unhtml/src/err.rs #[derive(Fail, Debug)] pub enum DeserializeError { #[fail(display <|fim_middle|>= "{}({}) get nothing", attr, value)] SourceNotFound { attr: String, ...
code_fim
medium
{ "lang": "rust", "repo": "isgasho/unhtml.rs", "path": "/unhtml/src/err.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: isgasho/unhtml.rs path: /unhtml/src/err.rs #[derive(Fail, Debug)] pub enum DeserializeError { #[fail(display <|fim_suffix|>: String, value: String }, #[fail(display = "source({}) is empty", source)] SourceEmpty { source: String, } }<|fim_middle|>= "{}({}) get ...
code_fim
medium
{ "lang": "rust", "repo": "isgasho/unhtml.rs", "path": "/unhtml/src/err.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>ecode; pub use crate::base64::BASE64_STANDARD; pub use crate::base64::BASE64_URL_SAFE;<|fim_prefix|>// repo: makepad/makepad path: /libs/base64/src/lib.rs pub mod base64; pub use crate::base64::bas<|fim_middle|>e64_encode; pub use crate::base64::base64_d
code_fim
easy
{ "lang": "rust", "repo": "makepad/makepad", "path": "/libs/base64/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: makepad/makepad path: /libs/base64/src/lib.rs pub mod base64; pub use crate::base64::bas<|fim_suffix|>ecode; pub use crate::base64::BASE64_STANDARD; pub use crate::base64::BASE64_URL_SAFE;<|fim_middle|>e64_encode; pub use crate::base64::base64_d
code_fim
easy
{ "lang": "rust", "repo": "makepad/makepad", "path": "/libs/base64/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marirs/nparse path: /src/kv_str_document.rs use serde_json::{json, Value}; use nom::{ complete, named, map, take_until, pair, separated_list0, separated_pair, call, tag, character::complete::{line_ending, space1}, }; named!( pub(crate) parse_kv_str_string<&str, Value>, map!...
code_fim
hard
{ "lang": "rust", "repo": "marirs/nparse", "path": "/src/kv_str_document.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> v.drain(..) .map(|(k, v)| (k.to_string(), json!(v.trim()))) .collect::<serde_json::Map<_, _>>() ) ) );<|fim_prefix|>// repo: marirs/nparse path: /src/kv_str_document.rs use serde_json::{json, Value}; use nom::{ complete, named, ...
code_fim
hard
{ "lang": "rust", "repo": "marirs/nparse", "path": "/src/kv_str_document.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[doc(inline)] pub use begin::{ChannelPollBeginV1, ChannelPollBeginV1Payload}; #[doc(inline)] pub use end::{ChannelPollEndV1, ChannelPollEndV1Payload}; #[doc(inline)] pub use progress::{ChannelPollProgressV1, ChannelPollProgressV1Payload}; /// Bits voting settings for a poll #[derive(Clone, Debug, Partia...
code_fim
medium
{ "lang": "rust", "repo": "naumazeredo/twitch_api2", "path": "/src/eventsub/channel/poll/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: naumazeredo/twitch_api2 path: /src/eventsub/channel/poll/mod.rs #![doc(alias = "channel.poll")] //! Poll on a specific channel has been begun, ended or progressed. use super::{EventSubscription, EventType}; use crate::types; use serde::{Deserialize, Serialize}; pub mod begin; pub mod end; pub m...
code_fim
hard
{ "lang": "rust", "repo": "naumazeredo/twitch_api2", "path": "/src/eventsub/channel/poll/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// Bits voting settings for a poll #[derive(Clone, Debug, PartialEq, PartialOrd, Eq, Serialize, Deserialize)] #[cfg_attr(feature = "deny_unknown_fields", serde(deny_unknown_fields))] #[non_exhaustive] pub struct BitsVoting { // FIXME: Is this null or 0 when not enabled? /// Number of Bits require...
code_fim
hard
{ "lang": "rust", "repo": "naumazeredo/twitch_api2", "path": "/src/eventsub/channel/poll/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> loop { new_game.print(); println!("Please enter a case to choose a piece to move"); let from: String = read!(); if from == "q" { break; } println!("Please enter a case for your piece to be moved"); let to: String = read!()...
code_fim
medium
{ "lang": "rust", "repo": "Trabrak/chess_rust", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Trabrak/chess_rust path: /src/main.rs mod game; use text_io::read; fn main() { println!("This project is meant to create a simple chess game, to pratice with Rust."); println!("At any moment, enter q to quit the game."); <|fim_suffix|> loop { new_game.print(); pr...
code_fim
medium
{ "lang": "rust", "repo": "Trabrak/chess_rust", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn drop<T>(_x: T) { } pub fn run() { println!("Before everything"); let x = FooBar(1); drop(x); println!("After drop(x)"); let _y = FooBar(2); println!("End"); } } pub mod exercise2 { ...
code_fim
hard
{ "lang": "rust", "repo": "TobiasPleyer/rust_crashcourse", "path": "/exercises/src/lessons.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TobiasPleyer/rust_crashcourse path: /exercises/src/lessons.rs pub mod lesson1 { pub mod exercise1 { pub fn run() { let val: String = String::from("Hello, World!"); printer(val.clone()); printer(val); let val2: String = String::from("He...
code_fim
hard
{ "lang": "rust", "repo": "TobiasPleyer/rust_crashcourse", "path": "/exercises/src/lessons.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> *self } } fn uses_foobar(foobar: Foobar) { println!("I consumed a Foobar: {:?}", foobar); } pub fn run() { let x = Foobar(1); uses_foobar(x); uses_foobar(x); } } }<|fim_prefix|>// repo...
code_fim
hard
{ "lang": "rust", "repo": "TobiasPleyer/rust_crashcourse", "path": "/exercises/src/lessons.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sudachen/svm path: /crates/codec/src/receipt/spawn.rs //! ## `Spawn Account` Receipt Binary Format Version 0 //! //! On success (`is_success = 1`) //! //! ```text //! +---------------------------------------------------------+ //! | | | | | ...
code_fim
hard
{ "lang": "rust", "repo": "sudachen/svm", "path": "/crates/codec/src/receipt/spawn.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> debug_assert!(receipt.success); let state = receipt.init_state(); w.write_state(state); } fn encode_returndata(receipt: &SpawnReceipt, w: &mut Vec<u8>) { debug_assert!(receipt.success); let data = receipt.returndata(); returndata::encode(&data, w); } #[cfg(test)] mod tests { ...
code_fim
hard
{ "lang": "rust", "repo": "sudachen/svm", "path": "/crates/codec/src/receipt/spawn.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_hello_random() { let hr = hello_random(); io::println(fmt!("%?", hr)); } }<|fim_prefix|>// repo: randombit/rust-tls path: /util.rs use to_bytes::ToBytes; pub fn hello_random() -> ~[u8] { let time32 = std::time::get_time().sec as u32; let time_bytes ...
code_fim
easy
{ "lang": "rust", "repo": "randombit/rust-tls", "path": "/util.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: randombit/rust-tls path: /util.rs use to_bytes::ToBytes; pub fn hello_random() -> ~[u8] { let time32 = std::time::get_time().sec as u32; <|fim_suffix|> io::println(fmt!("%?", hr)); } }<|fim_middle|> let time_bytes = time32.to_bytes(false); let random = crypto::rand::ran...
code_fim
hard
{ "lang": "rust", "repo": "randombit/rust-tls", "path": "/util.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match prefix { "v" => Value::with_number(number).map(Token::Value), "block" => Block::with_number(number).map(Token::Block), "ss" => Some(Token::StackSlot(number)), "dss" => Some(Token::DynamicStackSlot(number)), "dt" => Some(Token::Dynam...
code_fim
hard
{ "lang": "rust", "repo": "bytecodealliance/wasmtime", "path": "/cranelift/reader/src/lexer.rs", "mode": "spm", "license": "LLVM-exception", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bytecodealliance/wasmtime path: /cranelift/reader/src/lexer.rs // fn2 SigRef(u32), // sig2 UserRef(u32), // u345 UserNameRef(u32), // userextname345 Name(&'a str), // %9arbitrary_alphanum, %x3, %0, %function ... String(&'a str), // ...
code_fim
hard
{ "lang": "rust", "repo": "bytecodealliance/wasmtime", "path": "/cranelift/reader/src/lexer.rs", "mode": "psm", "license": "LLVM-exception", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bytecodealliance/wasmtime path: /cranelift/reader/src/lexer.rs can represent either an integer or floating point number. // // Accept the following forms: // // - `10`: Integer // - `-10`: Integer // - `0xff_00`: Integer // - `0.0`: Float // - `0x1.f`: Float ...
code_fim
hard
{ "lang": "rust", "repo": "bytecodealliance/wasmtime", "path": "/cranelift/reader/src/lexer.rs", "mode": "psm", "license": "LLVM-exception", "source": "the-stack-v2" }
<|fim_suffix|>pub async fn push_record(client: &reqwest::Client, zone_id: &str, record_id: &str, record: &CloudflareRecordInstance) -> Result<(), String> { match client.patch(&format!("https://api.cloudflare.com/client/v4/zones/{}/dns_records/{}", zone_id, record_id)) .json(&json!({"content": record.ip.clon...
code_fim
hard
{ "lang": "rust", "repo": "SamHDev/Cloudflare-Record-Updater", "path": "/src/cloudflare.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub async fn get_record(client: &reqwest::Client, zone_id: &str, record_id: &str) -> Result<CloudflareRecordInstance, String> { match client.get(&format!("https://api.cloudflare.com/client/v4/zones/{}/dns_records/{}", zone_id, record_id)).send().await { Ok(query) => match query.text().await { ...
code_fim
hard
{ "lang": "rust", "repo": "SamHDev/Cloudflare-Record-Updater", "path": "/src/cloudflare.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: SamHDev/Cloudflare-Record-Updater path: /src/cloudflare.rs use reqwest; use serde::{Serialize, Deserialize}; use serde_json as json; use serde_json::json; pub fn get_client(api_key: &str) -> reqwest::Client { let mut headers = reqwest::header::HeaderMap::new(); headers.insert( r...
code_fim
hard
{ "lang": "rust", "repo": "SamHDev/Cloudflare-Record-Updater", "path": "/src/cloudflare.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Get a connection to the pool pub async fn conn(&self) -> ATResult<DBConn> { let conn = self.pool.acquire().await; if let Err(_) = conn { println!("Error trying to acquire DB connection"); return Err(ATError::ParseError); } Ok(conn.unwrap(...
code_fim
hard
{ "lang": "rust", "repo": "bragaigor/cockroach_portal", "path": "/portal/src/query.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bragaigor/cockroach_portal path: /portal/src/query.rs use uuid::Uuid; use sqlx::{pool::PoolConnection, postgres::PgPoolOptions, PgPool, Postgres}; use std::sync::Arc; use std::time::Duration; use serde::{Deserialize, Serialize}; pub type ATResult<T> = anyhow::Result<T, ATError>; pub type DBCo...
code_fim
hard
{ "lang": "rust", "repo": "bragaigor/cockroach_portal", "path": "/portal/src/query.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>uct Match { # [ serde ( with = " prefix_player1 " ) ] player1 : Player # [ serde ( with = " prefix_player2 " ) ] player2 : Option < Player > # [ serde ( with = " prefix_player3 " ) ] player3 : Option < Player > # [ serde ( with = " prefix_tag " ) ] tags : HashMap < String String > } # [ derive ( Serialize...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/serde_with/tests/with_prefix.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>name " : " name1 " " player1_votes " : 1 } " player2 " : { " player2_name " : " name2 " " player2_votes " : 2 } " player3 " : null " tags " : { " tag_t " : " T " } } " # ] ] ) ; } / / / Ensure that with_prefix works for unit type enum variants . # [ test ] fn test_enum_unit_variant_with_prefix ( ) { # [ d...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/serde_with/tests/with_prefix.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/serde_with/tests/with_prefix.rs # ! [ allow ( / / clippy is broken and shows wrong warnings / / clippy on stable does not know yet about the lint name unknown_lints / / https : / / github . com / rust - lang / rust - clippy / issues / 8867 clip...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-wordified", "path": "/third_party/rust/serde_with/tests/with_prefix.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> let n1: u8 = rng.gen(); let n2: u16 = rng.gen(); println!("Rastgele u8 {}" , n1); println!("Rastgele u16 {}" , n2); }<|fim_prefix|>// repo: retikulum/fuzz path: /src/random_number_generate.rs use rand::Rng; fn main(){ <|fim_middle|> let mut rng = rand:Ç:thread_rng();
code_fim
easy
{ "lang": "rust", "repo": "retikulum/fuzz", "path": "/src/random_number_generate.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: retikulum/fuzz path: /src/random_number_generate.rs use rand::Rng; fn main(){ <|fim_suffix|> let n1: u8 = rng.gen(); let n2: u16 = rng.gen(); println!("Rastgele u8 {}" , n1); println!("Rastgele u16 {}" , n2); }<|fim_middle|> let mut rng = rand:Ç:thread_rng();
code_fim
easy
{ "lang": "rust", "repo": "retikulum/fuzz", "path": "/src/random_number_generate.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq![my_iter.next(), Some(&mut 1)]; assert_eq![my_iter.next(), Some(&mut 2)]; assert_eq![my_iter.next(), Some(&mut 3)]; assert_eq![my_iter.next(), None]; }<|fim_prefix|>// repo: paarasg/Rust-Projects path: /iterator/src/main.rs fn main() { let mut result = vec![1, 2, 3]; <|f...
code_fim
easy
{ "lang": "rust", "repo": "paarasg/Rust-Projects", "path": "/iterator/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: paarasg/Rust-Projects path: /iterator/src/main.rs fn main() { let mut result = vec![1, 2, 3]; let mut my_iter = result.iter_mut(); assert_eq![my_iter.next(), Some(&mut 1)]; <|fim_suffix|> assert_eq![my_iter.next(), Some(&mut 3)]; assert_eq![my_iter.next(), None]; }<|fim_mi...
code_fim
easy
{ "lang": "rust", "repo": "paarasg/Rust-Projects", "path": "/iterator/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let face = '\u{1F600}'; let text = "Hello"; println!("{} {} {}", a1, face, text); }<|fim_prefix|>// repo: IlgssonBraga/rust-crash-course path: /src/types.rs pub fn run(){ // By default i32 let x = 1; // By default f64 let y = 2.5; // Add explicit type let z: i64 = ...
code_fim
medium
{ "lang": "rust", "repo": "IlgssonBraga/rust-crash-course", "path": "/src/types.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IlgssonBraga/rust-crash-course path: /src/types.rs pub fn run(){ // By default i32 let x = 1; // By default f64 let y = 2.5; // Add explicit type let z: i64 = 4352452525; // Find max size println!("Max i32: {}", std::i32::MAX); println!("Max i64: {}", std:...
code_fim
medium
{ "lang": "rust", "repo": "IlgssonBraga/rust-crash-course", "path": "/src/types.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> ids.sort(); for i in 0..(ids.len() - 2) { if ids[i + 1] - ids[i] != 1 { let missing = ids[i] + 1; dbg!(missing); } } Ok(()) }<|fim_prefix|>// repo: balintbalazs/advent-of-code-2020 path: /src/bin/day5.rs use std::error::Error; use std::fs; fn main...
code_fim
hard
{ "lang": "rust", "repo": "balintbalazs/advent-of-code-2020", "path": "/src/bin/day5.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: balintbalazs/advent-of-code-2020 path: /src/bin/day5.rs use std::error::Error; use std::fs; fn main() -> Result<(), Box<dyn Error>> { <|fim_suffix|> ids.sort(); for i in 0..(ids.len() - 2) { if ids[i + 1] - ids[i] != 1 { let missing = ids[i] + 1; dbg!(miss...
code_fim
hard
{ "lang": "rust", "repo": "balintbalazs/advent-of-code-2020", "path": "/src/bin/day5.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Divides `input` and `output` into chunks of size `self.len()`, and computes a DHT on each chunk. /// /// This method uses both the `input` buffer and `scratch` buffer as scratch space, so the contents of both should be /// considered garbage after calling. /// /// This is a mor...
code_fim
hard
{ "lang": "rust", "repo": "ejmahler/RustDHT", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ejmahler/RustDHT path: /src/lib.rs use num_traits::Zero; use rustfft::{FftNum, Length}; #[macro_use] mod macros; pub mod scalar; mod twiddles; mod array_utils; mod math_utils; #[cfg(test)] mod test_utils; /// Trait for algorithms that compute DHTs. /// /// This trait has a few methods for co...
code_fim
hard
{ "lang": "rust", "repo": "ejmahler/RustDHT", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bagelboy/adventofcode path: /2017/day05/src/main.rs use std::fs::File; use std::io::Read; fn escape_jump_maze(offsets: &[i32]) -> u32 { let mut offsets_copy = offsets.to_vec(); let mut position = 0; let mut steps = 0; loop { steps += 1; let new_position = positio...
code_fim
hard
{ "lang": "rust", "repo": "bagelboy/adventofcode", "path": "/2017/day05/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let mut input = String::new(); if File::open("input") .expect("cannot read input") .read_to_string(&mut input) .is_ok() { let offsets: Vec<i32> = input.lines().map(|l| l.parse().unwrap()).collect(); println!("maze one: {} steps", escape_jump...
code_fim
medium
{ "lang": "rust", "repo": "bagelboy/adventofcode", "path": "/2017/day05/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(10, escape_strange_jump_maze(&vec![0, 3, 0, 1, -3])); } fn main() { let mut input = String::new(); if File::open("input") .expect("cannot read input") .read_to_string(&mut input) .is_ok() { let offsets: Vec<i32> = input.lines().map(|l| l.parse()....
code_fim
hard
{ "lang": "rust", "repo": "bagelboy/adventofcode", "path": "/2017/day05/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub use utils::glob_to_regex;<|fim_prefix|>// repo: alekitto/rzephir path: /libzephir/src/lib.rs #![feature(once_cell)] #![feature(try_trait)] // 1.53.0-nightly (2021-04-01 d474075a8f28ae9a410e) <|fim_middle|>pub mod cache; mod compiler; pub mod err; pub mod identity; pub mod policy; pub mod storage; pu...
code_fim
medium
{ "lang": "rust", "repo": "alekitto/rzephir", "path": "/libzephir/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alekitto/rzephir path: /libzephir/src/lib.rs #![feature(once_cell)] #![feature(try_trait)] // 1.53.0-nightly (2021-04-01 d474075a8f28ae9a410e) <|fim_suffix|>pub use utils::glob_to_regex;<|fim_middle|>pub mod cache; mod compiler; pub mod err; pub mod identity; pub mod policy; pub mod storage; pu...
code_fim
medium
{ "lang": "rust", "repo": "alekitto/rzephir", "path": "/libzephir/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: adrien-ben/gltf-viewer-rs path: /crates/libs/vulkan/src/debug.rs use ash::extensions::ext::DebugUtils; use ash::{vk, Entry, Instance}; use std::{ffi::CStr, os::raw::c_void}; unsafe extern "system" fn vulkan_debug_callback( flag: vk::DebugUtilsMessageSeverityFlagsEXT, typ: vk::DebugUtils...
code_fim
hard
{ "lang": "rust", "repo": "adrien-ben/gltf-viewer-rs", "path": "/crates/libs/vulkan/src/debug.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let create_info = vk::DebugUtilsMessengerCreateInfoEXT::builder() .flags(vk::DebugUtilsMessengerCreateFlagsEXT::empty()) .message_severity(Severity::VERBOSE | Severity::INFO | Severity::WARNING | Severity::ERROR) .message_type(MsgType::GENERAL | MsgType::VALIDATION | MsgType::P...
code_fim
hard
{ "lang": "rust", "repo": "adrien-ben/gltf-viewer-rs", "path": "/crates/libs/vulkan/src/debug.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn connect_probe (&mut self, p: &mut Probe) { let sender = Arc::downgrade(&self.sender); let structs = self.structures.clone (); p.updated.lock().unwrap().connect(move |s| { match sender.upgrade() { None => (), Some (sender) => ...
code_fim
hard
{ "lang": "rust", "repo": "meadofpoetry/ats-analyzer", "path": "/backend/src/streams.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: meadofpoetry/ats-analyzer path: /backend/src/streams.rs use serde_json; use std::sync::{Arc,Mutex}; use std::sync::mpsc::Sender; use metadata::Structure; use signals::Signal; use probe::Probe; pub struct StreamParser { pub structures: Arc<Mutex<Vec<Structure>>>, sender: Arc<Mutex<Sender...
code_fim
hard
{ "lang": "rust", "repo": "meadofpoetry/ats-analyzer", "path": "/backend/src/streams.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ghousseyn/FrameworkBenchmarks path: /frameworks/Rust/iron/src/main.rs extern crate iron; extern crate router; extern crate rustc_serialize; use iron::{Iron, Request, Response, IronResult}; use iron::status; use router::{Router}; use rustc_serialize::json; #[derive(RustcDecodable, RustcEncodabl...
code_fim
medium
{ "lang": "rust", "repo": "ghousseyn/FrameworkBenchmarks", "path": "/frameworks/Rust/iron/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let message: Message = Message{ message: "Hello, World!".to_string(), }; Ok(Response::with((status::Ok, json::encode(&message).unwrap()))) } fn plaintextHandler(req: &mut Request) -> IronResult<Response> { Ok(Response::with((status::Ok, "Hello, World!"))) }<|fim_prefix|>// repo: g...
code_fim
hard
{ "lang": "rust", "repo": "ghousseyn/FrameworkBenchmarks", "path": "/frameworks/Rust/iron/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn jsonHandler(req: &mut Request) -> IronResult<Response> { let message: Message = Message{ message: "Hello, World!".to_string(), }; Ok(Response::with((status::Ok, json::encode(&message).unwrap()))) } fn plaintextHandler(req: &mut Request) -> IronResult<Response> { Ok(Response::wi...
code_fim
hard
{ "lang": "rust", "repo": "ghousseyn/FrameworkBenchmarks", "path": "/frameworks/Rust/iron/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>lor::Color, rect::Rect, render::Render, view_context::ViewContext, };<|fim_prefix|>// repo: U007D/mandel path: /src/ports/ui.rs mod app; mod app_builder; mod components; pub use app::{App, NamedWindow<|fim_middle|>Dimensions, Size, WindowDimensions, WindowSettings}; pub use app_builder::AppBuilder; p...
code_fim
medium
{ "lang": "rust", "repo": "U007D/mandel", "path": "/src/ports/ui.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: U007D/mandel path: /src/ports/ui.rs mod app; mod app_builder; mod components; pub use app::{App, NamedWindow<|fim_suffix|>lor::Color, rect::Rect, render::Render, view_context::ViewContext, };<|fim_middle|>Dimensions, Size, WindowDimensions, WindowSettings}; pub use app_builder::AppBuilder; p...
code_fim
medium
{ "lang": "rust", "repo": "U007D/mandel", "path": "/src/ports/ui.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn collect_block(block: String) -> Vec<u8> { block .split(' ') .map(|x| x.parse::<u8>().expect("Incorrect characters in blocks")) .collect() } fn print_collision(c: ([u8;32], [u8; 32])){ println!("M1: {:#?}", c.0); println!("M1: {:#?}", c.1); }<|fim_prefix|>// repo: ne...
code_fim
hard
{ "lang": "rust", "repo": "nevenoomo/GOST_collision", "path": "/src/bin/get_collision.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nevenoomo/GOST_collision path: /src/bin/get_collision.rs //! # Get GOST collision //! This is a CLI interface for the library module ***gost_collision***, which finds a collision //! given a state block with symmetric first quater. <|fim_suffix|>fn main() { let h = parse_args(); let mu...
code_fim
medium
{ "lang": "rust", "repo": "nevenoomo/GOST_collision", "path": "/src/bin/get_collision.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fralalonde/dipstick path: /src/cache.rs //! Metric input scope caching. use crate::attributes::{Attributes, OnFlush, Prefixed, WithAttributes}; use crate::input::{Input, InputDyn, InputKind, InputMetric, InputScope}; use crate::lru_cache as lru; use crate::name::MetricName; use crate::Flush; u...
code_fim
hard
{ "lang": "rust", "repo": "fralalonde/dipstick", "path": "/src/cache.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl InputCache { /// Wrap scopes with an asynchronous metric write & flush dispatcher. fn wrap<OUT: Input + Send + Sync + 'static>(target: OUT, max_size: usize) -> InputCache { InputCache { attributes: Attributes::default(), target: Arc::new(target), ca...
code_fim
hard
{ "lang": "rust", "repo": "fralalonde/dipstick", "path": "/src/cache.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> root.lock(b2).await?; Ok(root) } pub async fn delete_root(b2: &mut b2::B2, roots: &mut Vec<BackupRoot>, path: &Path) -> Result<()> { if roots .iter() .position(|r| r.path == path) .map(|i| roots.remove(i)) .is_none() { Err(eyre!( "Backup...
code_fim
hard
{ "lang": "rust", "repo": "tux3/frozen", "path": "/src/data/root.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tux3/frozen path: /src/data/root.rs use crate::crypto; use crate::data::file::{RemoteFile, RemoteFileVersion}; use crate::net::b2; use crate::prompt::prompt_yes_no; use bincode::{deserialize, serialize}; use data_encoding::HEXLOWER_PERMISSIVE; use eyre::{bail, ensure, eyre, Result}; use serde::{...
code_fim
hard
{ "lang": "rust", "repo": "tux3/frozen", "path": "/src/data/root.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> }, Err(_) => { [0, 0] } }; let seed: [u8; 16] = unsafe { std::mem::transmute(seed) }; RandGen { rng: XorShiftRng::from_seed(seed), _seed: seed } } pub fn unit_circle_glm(&mut self) -> glm::...
code_fim
hard
{ "lang": "rust", "repo": "j-rock/fortress", "path": "/fortress/src/lib/math/rand_gen.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: j-rock/fortress path: /fortress/src/lib/math/rand_gen.rs use glm; use nalgebra::Point2; use rand::{ Rng, SeedableRng, }; use rand_distr::{ Distribution, UnitCircle, }; use rand_xorshift::XorShiftRng; use std::{ self, time::SystemTime }; pub struct RandGen { rng: XorS...
code_fim
hard
{ "lang": "rust", "repo": "j-rock/fortress", "path": "/fortress/src/lib/math/rand_gen.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jhungerford/adventofcode-2020 path: /day1/src/main.rs use std::str::FromStr; use std::fs::File; use std::io::{BufRead, BufReader}; use itertools::Itertools; /// Loads numbers out of the given file, panicing if the file doesn't exist or is invalid. fn load_input(filename: &str) -> Vec<i32> { ...
code_fim
hard
{ "lang": "rust", "repo": "jhungerford/adventofcode-2020", "path": "/day1/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> 0 } /// Finds three numbers that sum to 2020 and returns their product. fn find_three_2020_product(numbers: &Vec<i32>) -> i32 { for combo in numbers.iter().combinations(3) { if combo.iter().fold(0, |sum, &num| sum + num) == 2020 { return combo.iter().fold(1, |product, &num| pr...
code_fim
hard
{ "lang": "rust", "repo": "jhungerford/adventofcode-2020", "path": "/day1/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_find_three_2020() { let numbers = load_input("sample.txt"); assert_eq!(241861950, find_three_2020_product(&numbers)); } } fn main() { let lines = load_input("input.txt"); println!("Part 1: {}", find_two_2020_product(&lines)); println!("Part 2: {}",...
code_fim
hard
{ "lang": "rust", "repo": "jhungerford/adventofcode-2020", "path": "/day1/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let map = Map::new_map_rooms(); let (player_x, player_y) = map.rooms[0].center(); world.insert( (), iter::once(( Player {}, Name { name: "player".to_string(), }, Position { x: player_x, ...
code_fim
hard
{ "lang": "rust", "repo": "AdamLatos/rogue-legion", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AdamLatos/rogue-legion path: /src/main.rs rltk::add_wasm_support!(); use legion::query::{IntoQuery, Read}; use legion::schedule::Schedule; use legion::world::{Universe, World}; use rltk::{Console, GameState, Point, Rltk, RGB}; use std::iter; mod player; use player::*; mod map; use map::*; mod c...
code_fim
hard
{ "lang": "rust", "repo": "AdamLatos/rogue-legion", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> world.insert( (), iter::once(( Player {}, Name { name: "player".to_string(), }, Position { x: player_x, y: player_y, }, Velocity { x: 0, y: 0 }, Viewshed ...
code_fim
hard
{ "lang": "rust", "repo": "AdamLatos/rogue-legion", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: qwelyt/advent-of-code path: /2021/rust/src/day18/mod.rs use crate::util::lines_from_file; pub fn day18() { println!("== Day 18 =="); let input = lines_from_file("src/day18/input.txt"); let (a, _) = part_a(&input); println!("Part A: {}", a); let b = part_b(&input); printl...
code_fim
hard
{ "lang": "rust", "repo": "qwelyt/advent-of-code", "path": "/2021/rust/src/day18/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut sum = Pair::Branch { left: Box::new(a.clone()), right: Box::new(b.clone()), }; // loop { // // Reduce and split until nothing happens // if sum.reduce(0).is_none(){break;} // if sum.split().is_none(){break} // } while sum.reduce(0).is_som...
code_fim
hard
{ "lang": "rust", "repo": "qwelyt/advent-of-code", "path": "/2021/rust/src/day18/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[cfg(test)] mod tests { use super::*; #[test] fn part_a_test_input() { let filename = "src/day18/test-input.txt"; let input = lines_from_file(filename); let (result, _sum) = part_a(&input); // println!("{:?}", _sum); assert_eq!(4140, result) } ...
code_fim
hard
{ "lang": "rust", "repo": "qwelyt/advent-of-code", "path": "/2021/rust/src/day18/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: torkve/habropengl path: /src/main.rs #![feature(io)] #![feature(core)] use tgaimage::Image; use model::Model; use render::Renderer; <|fim_suffix|>fn main() { let width = 800; let height = 800; let mut img = Image::new(width, height, 3); let model = Model::new("african_head.obj"...
code_fim
medium
{ "lang": "rust", "repo": "torkve/habropengl", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let width = 800; let height = 800; let mut img = Image::new(width, height, 3); let model = Model::new("african_head.obj").unwrap(); println!("Loaded {} faces, {} verts", model.nfaces(), model.nverts()); img.render(model).unwrap(); img.flip_vertically().unwrap(); img.write_t...
code_fim
medium
{ "lang": "rust", "repo": "torkve/habropengl", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: atsamd-rs/atsamd path: /pac/atsame53j/src/dmac/pendch.rs lf { PENDCH8_R(crate::FieldReader::new(bits)) } } impl core::ops::Deref for PENDCH8_R { type Target = crate::FieldReader<bool, bool>; #[inline(always)] fn deref(&self) -> &Self::Target { &self.0 } } #[do...
code_fim
hard
{ "lang": "rust", "repo": "atsamd-rs/atsamd", "path": "/pac/atsame53j/src/dmac/pendch.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> &self.0 } } #[doc = "Field `PENDCH22` reader - Pending Channel 22"] pub struct PENDCH22_R(crate::FieldReader<bool, bool>); impl PENDCH22_R { #[inline(always)] pub(crate) fn new(bits: bool) -> Self { PENDCH22_R(crate::FieldReader::new(bits)) } } impl core::ops::Deref for PEN...
code_fim
hard
{ "lang": "rust", "repo": "atsamd-rs/atsamd", "path": "/pac/atsame53j/src/dmac/pendch.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: atsamd-rs/atsamd path: /pac/atsame53j/src/dmac/pendch.rs 6_R { #[inline(always)] pub(crate) fn new(bits: bool) -> Self { PENDCH6_R(crate::FieldReader::new(bits)) } } impl core::ops::Deref for PENDCH6_R { type Target = crate::FieldReader<bool, bool>; #[inline(always)] ...
code_fim
hard
{ "lang": "rust", "repo": "atsamd-rs/atsamd", "path": "/pac/atsame53j/src/dmac/pendch.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> 1 } #[cfg(test)] mod tests { #[test] fn part_1() { let test_data = "class: 1-3 or 5-7 row: 6-11 or 33-44 seat: 13-40 or 45-50 your ticket: 7,1,14 nearby tickets: 7,3,47 40,4,50 55,2,20 38,6,12" .to_string(); assert_eq!(super::part_1(&test_data), 71); } #...
code_fim
hard
{ "lang": "rust", "repo": "nossrannug/adventofcode", "path": "/rust/day_16/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>your ticket: 7,1,14 nearby tickets: 7,3,47 40,4,50 55,2,20 38,6,12" .to_string(); assert_eq!(super::part_1(&test_data), 71); } #[ignore] #[test] fn part_2() { let test_data = "class: 0-1 or 4-19 row: 0-5 or 8-19 seat: 0-13 or 16-19 your ticket: 11,12,13 near...
code_fim
hard
{ "lang": "rust", "repo": "nossrannug/adventofcode", "path": "/rust/day_16/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nossrannug/adventofcode path: /rust/day_16/src/main.rs use common::get_file_content; use std::{collections::HashSet, env}; fn main() { let args: Vec<String> = env::args().collect(); let contents = get_file_content(args.last().unwrap().to_string()).expect("Failed to open file"); prin...
code_fim
hard
{ "lang": "rust", "repo": "nossrannug/adventofcode", "path": "/rust/day_16/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: howlowck/srt-rs path: /tests/lossy_conn/mod.rs use std::cmp::Ordering; use std::collections::BinaryHeap; use std::fmt::Debug; use std::time::{Duration, Instant}; use failure::{bail, Error}; use futures::{sync::mpsc, Async, AsyncSink, Future, Poll, Sink, StartSend, Stream}; use futures_timer::D...
code_fim
hard
{ "lang": "rust", "repo": "howlowck/srt-rs", "path": "/tests/lossy_conn/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }