text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: andoriyu/material-design-icons-rs path: /src/materialiconstwotone/search/icon_living.rs pub struct IconLiving { props: crate::Props, } impl yew::Component for IconLiving { type Properties = crate::Props; type Message = (); fn create(props: Self::Properties, _: yew::prelude::Compone...
code_fim
medium
{ "lang": "rust", "repo": "andoriyu/material-design-icons-rs", "path": "/src/materialiconstwotone/search/icon_living.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_validate_datetime() { assert!(validate_datetime(make_datetime(2020, 1, 1, 3, 4, 5)).is_some()); assert!(validate_datetime(make_datetime(1820, 1, 1, 3, 4, 5)).is_none()); } }<|fim_prefix|>// repo: RealOrangeOne/date-group path: /src/utils.rs use chrono::{Datelik...
code_fim
hard
{ "lang": "rust", "repo": "RealOrangeOne/date-group", "path": "/src/utils.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: RealOrangeOne/date-group path: /src/utils.rs use chrono::{Datelike, Local, NaiveDateTime}; use dtparse::Parser; use std::cmp::Ord; use std::collections::HashMap; #[inline] fn is_between<T: Ord>(i: T, min: T, max: T) -> bool { return i >= min && i <= max; } <|fim_suffix|> if !is_between(...
code_fim
hard
{ "lang": "rust", "repo": "RealOrangeOne/date-group", "path": "/src/utils.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: holg/goedesearch path: /src/filters.rs /** * The filters module contains all the simple little functions for filtering english text into * usable tokens for the search index */ <|fim_suffix|> let mut stems = vec![]; // Create a stemmer for the english language let en_stemmer = Ste...
code_fim
hard
{ "lang": "rust", "repo": "holg/goedesearch", "path": "/src/filters.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for token in text.split(' ') { let token: String = token.to_lowercase() .chars() .filter(|ch| ! ch.is_ascii_punctuation()) .collect(); // only stem the word if it doesn't match a stopword if ! STOPWORDS.contains(&token.as_str()) { ...
code_fim
medium
{ "lang": "rust", "repo": "holg/goedesearch", "path": "/src/filters.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zaeleus/noodles path: /noodles-htsget/src/request.rs //! htsget request. <|fim_suffix|>pub use self::class::Class; pub(crate) use self::{builder::Builder, kind::Kind, payload::Payload};<|fim_middle|>mod builder; mod class; mod kind; mod payload;
code_fim
easy
{ "lang": "rust", "repo": "zaeleus/noodles", "path": "/noodles-htsget/src/request.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub use self::class::Class; pub(crate) use self::{builder::Builder, kind::Kind, payload::Payload};<|fim_prefix|>// repo: zaeleus/noodles path: /noodles-htsget/src/request.rs //! htsget request. <|fim_middle|>mod builder; mod class; mod kind; mod payload;
code_fim
easy
{ "lang": "rust", "repo": "zaeleus/noodles", "path": "/noodles-htsget/src/request.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn arbitrary_with(height: Self::Parameters) -> Self::Strategy { if let Some(height) = height { (vec(any::<u8>(), 0..95), any::<u32>()) .prop_map(move |(data, sequence)| Input::Coinbase { height, data: if height == block::Heigh...
code_fim
hard
{ "lang": "rust", "repo": "ZcashFoundation/zebra", "path": "/zebra-chain/src/transparent/arbitrary.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ZcashFoundation/zebra path: /zebra-chain/src/transparent/arbitrary.rs use proptest::{arbitrary::any, collection::vec, prelude::*}; use crate::{block, LedgerState}; use super::{CoinbaseData, Input, OutPoint, Script, GENESIS_COINBASE_DATA}; <|fim_suffix|> if let Some(height) = height { ...
code_fim
hard
{ "lang": "rust", "repo": "ZcashFoundation/zebra", "path": "/zebra-chain/src/transparent/arbitrary.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> if let Some(height) = height { (vec(any::<u8>(), 0..95), any::<u32>()) .prop_map(move |(data, sequence)| Input::Coinbase { height, data: if height == block::Height(0) { CoinbaseData(GENESIS_COINBASE_DATA.to...
code_fim
hard
{ "lang": "rust", "repo": "ZcashFoundation/zebra", "path": "/zebra-chain/src/transparent/arbitrary.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cpdean/aoc_2019_rust path: /old_days/src/main.rs fn main() { println!("Hello, world!"); } <|fim_suffix|> #[test] fn first_example() { assert_eq!(11, 11); } }<|fim_middle|> #[cfg(test)] mod tests { use super::*;
code_fim
easy
{ "lang": "rust", "repo": "cpdean/aoc_2019_rust", "path": "/old_days/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(11, 11); } }<|fim_prefix|>// repo: cpdean/aoc_2019_rust path: /old_days/src/main.rs fn main() { println!("Hello, world!"); } <|fim_middle|>#[cfg(test)] mod tests { use super::*; #[test] fn first_example() {
code_fim
medium
{ "lang": "rust", "repo": "cpdean/aoc_2019_rust", "path": "/old_days/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn hash_map() { let mut contacts = HashMap::new(); // Insert data contacts.insert("Daniel", "798-1364"); contacts.insert("Ashley", "645-7689"); contacts.insert("Katie", "435-8291"); contacts.insert("Robert", "956-1745"); println!("{}", contacts.get(&"Daniel").unwrap()); ...
code_fim
hard
{ "lang": "rust", "repo": "ciusji/ferris", "path": "/src/example/std_libs/hashmap.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> println!("{}", contacts.get(&"Daniel").unwrap()); contacts.remove(&"Daniel"); for (contact, &number) in contacts.iter() { println!("Calling {}: {}", contact, call(number)) } }<|fim_prefix|>// repo: ciusji/ferris path: /src/example/std_libs/hashmap.rs // Copyright 2021 Ferris Pr...
code_fim
hard
{ "lang": "rust", "repo": "ciusji/ferris", "path": "/src/example/std_libs/hashmap.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ciusji/ferris path: /src/example/std_libs/hashmap.rs // Copyright 2021 Ferris Project Authors. License user Apache License. // HashMap // Where vectors store values by an integer index, HashMaps store values by key. HashMap keys can be // booleans, integers, strings, or any other type that impl...
code_fim
medium
{ "lang": "rust", "repo": "ciusji/ferris", "path": "/src/example/std_libs/hashmap.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: LastLeaf/maomi path: /maomi-dom/src/event/animation.rs use wasm_bindgen::{prelude::*, JsCast}; use super::{ColdEventItem, DomEventRegister}; use crate::DomGeneralElement; /// The animation event detail. #[derive(Debug, Clone, PartialEq)] pub struct AnimationEvent { dom_event: web_sys::Anim...
code_fim
hard
{ "lang": "rust", "repo": "LastLeaf/maomi", "path": "/maomi-dom/src/event/animation.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>cold_event!( AnimationIteration, AnimationEvent, Closure::new(move |dom_event: web_sys::AnimationEvent| { trigger_ev::<AnimationIteration>(dom_event); }) ); cold_event!( AnimationEnd, AnimationEvent, Closure::new(move |dom_event: web_sys::AnimationEvent| { trig...
code_fim
medium
{ "lang": "rust", "repo": "LastLeaf/maomi", "path": "/maomi-dom/src/event/animation.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> variant as _ } } #[doc = "Field `SEL` reader - CLKOUT clock source selection"] pub struct SEL_R(crate::FieldReader<u8, SEL_A>); impl SEL_R { pub(crate) fn new(bits: u8) -> Self { SEL_R(crate::FieldReader::new(bits)) } #[doc = r"Get enumerated values variant"] #[inline(a...
code_fim
hard
{ "lang": "rust", "repo": "lpc-rs/lpc-pac", "path": "/lpc54608/src/syscon/clkoutsela.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lpc-rs/lpc-pac path: /lpc54608/src/syscon/clkoutsela.rs #[doc = "Register `CLKOUTSELA` reader"] pub struct R(crate::R<CLKOUTSELA_SPEC>); impl core::ops::Deref for R { type Target = crate::R<CLKOUTSELA_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Target { &self.0 } }...
code_fim
hard
{ "lang": "rust", "repo": "lpc-rs/lpc-pac", "path": "/lpc54608/src/syscon/clkoutsela.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> - '0' as u8) * 10 + v[i + 1] as u8 - '0' as u8; r.push(('a' as u8 + n - 1) as char); i += 3; } else { r.push(('a' as u8 + v[i] as u8 - '1' as u8) as char); i += 1; } } r } }<|fim_prefix|>// repo: g...
code_fim
hard
{ "lang": "rust", "repo": "gKevinK/LeetCode", "path": "/1309_Decrypt_String_from_Alphabet_to_Integer_Mapping.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gKevinK/LeetCode path: /1309_Decrypt_String_from_Alphabet_to_Integer_Mapping.rs impl Solution { pub fn freq_alphabets(s: String) -> String { let v: Vec<char> = s.chars().collect(); let mut r = String::from(""); let mut i = 0; while i < v.len() { if...
code_fim
hard
{ "lang": "rust", "repo": "gKevinK/LeetCode", "path": "/1309_Decrypt_String_from_Alphabet_to_Integer_Mapping.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// ユーザーの登録 /// /// # Arguments /// `name` ユーザーの名前 /// `email` ユーザーのメールアドレス /// /// # Returns /// 成否 pub fn register_new_user(&self, name: &str, email: &str) -> std::result::Result<(), Box<dyn std::error::Error>> { // ユーザーを登録します。 let connection = db::DatabaseConnection::new(); connection.in...
code_fim
medium
{ "lang": "rust", "repo": "mass10/rust.note", "path": "/code/batch01/src/services/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mass10/rust.note path: /code/batch01/src/services/mod.rs //! //! 各種ビジネスロジックを提供するサービス層です。 //! use crate::db; /// /// ユーザー管理 /// pub struct UserManager { #[allow(unused)] reserved: i32, } <|fim_suffix|> /// ユーザーの登録 /// /// # Arguments /// `name` ユーザーの名前 /// `email` ユーザーのメールアドレス /// /// ...
code_fim
medium
{ "lang": "rust", "repo": "mass10/rust.note", "path": "/code/batch01/src/services/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dalalsunil1986/xv7 path: /xv7-boot/src/lib.rs //! FIXME: Add missing docs #![no_std] #![deny(missing_docs)] pub mod config; use core::fmt; use uefi::table::boot::MemoryDescriptor; pub use x86_64::{PhysAddr, VirtAddr}; /// Function signature for kernel entry point. #[cfg(target_arch = "x86_64...
code_fim
hard
{ "lang": "rust", "repo": "dalalsunil1986/xv7", "path": "/xv7-boot/src/lib.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>impl<'buf> Iterator for MemoryMapIter<'buf> { type Item = &'buf MemoryDescriptor; fn size_hint(&self) -> (usize, Option<usize>) { let sz = self.len - self.index; (sz, Some(sz)) } fn next(&mut self) -> Option<Self::Item> { if self.index < self.len { le...
code_fim
hard
{ "lang": "rust", "repo": "dalalsunil1986/xv7", "path": "/xv7-boot/src/lib.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: io12/pwninit path: /src/set_exec.rs use std::os::unix::fs::PermissionsExt; use std::path::Path; <|fim_suffix|>/// Set the file at `path` executable pub fn set_exec<P: AsRef<Path>>(path: P) -> io::Result<()> { let path = path.as_ref(); let mode = fs::metadata(path)?.permissions().mode();...
code_fim
easy
{ "lang": "rust", "repo": "io12/pwninit", "path": "/src/set_exec.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>/// Set the file at `path` executable pub fn set_exec<P: AsRef<Path>>(path: P) -> io::Result<()> { let path = path.as_ref(); let mode = fs::metadata(path)?.permissions().mode(); let mode = mode | umask::EXEC; let perm = fs::Permissions::from_mode(mode); fs::set_permissions(path, perm)?...
code_fim
easy
{ "lang": "rust", "repo": "io12/pwninit", "path": "/src/set_exec.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> assert!((*guard).inner.sender_fp.is_some()); let mut bytes_written = 0; if let Some(ref mut fp) = (*guard).inner.sender_fp { match fp.write_u32::<BigEndian>(payload_len as u32) { Ok(()) => bytes_written += PAYLOAD_LEN_BYTES, Err(e) => { ...
code_fim
hard
{ "lang": "rust", "repo": "IQ-SCM/hopper", "path": "/src/sender.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: IQ-SCM/hopper path: /src/sender.rs use bincode::serialize_into; use byteorder::{BigEndian, WriteBytesExt}; use deque; use deque::BackGuardInner; use flate2::write::DeflateEncoder; use flate2::Compression; use parking_lot::MutexGuard; use private; use serde::{Deserialize, Serialize}; use std::fs;...
code_fim
hard
{ "lang": "rust", "repo": "IQ-SCM/hopper", "path": "/src/sender.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> /// Attempt to flush any outstanding disk writes to the deque /// /// This function will attempt to flush outstanding disk writes, which may /// fail if the in-memory buffer is full. This function is useful when /// traffic patterns are bursty, meaning a write may end up being stranded...
code_fim
hard
{ "lang": "rust", "repo": "IQ-SCM/hopper", "path": "/src/sender.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn to_key_str(key: libc::c_int) -> ~str { match key { /* Printable keys */ k if k == glfw3::KEY_SPACE => { ~"Space" } k if k == glfw3::KEY_APOSTROPHE => { ~"Apostrophe" } k if k == glfw3::KEY_COMMA => { ~"Comma" } ...
code_fim
hard
{ "lang": "rust", "repo": "pnkfelix/glfw3-rs", "path": "/examples/callbacks.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /* Function keys */ k if k == glfw3::KEY_ESCAPE => { ~"Escape" } k if k == glfw3::KEY_ENTER => { ~"Enter" } k if k == glfw3::KEY_TAB => { ~"Tab" } k if k == glfw3::KEY_BACKSPACE => { ~"Backspace" ...
code_fim
hard
{ "lang": "rust", "repo": "pnkfelix/glfw3-rs", "path": "/examples/callbacks.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pnkfelix/glfw3-rs path: /examples/callbacks.rs extern mod glfw3; // let mut done = false; fn main() { // Run this task on the main thread. Unlike C or C++, a Rust program // automatically starts a new thread, so this line is _essential_ to ensure // that the OS is able to upda...
code_fim
hard
{ "lang": "rust", "repo": "pnkfelix/glfw3-rs", "path": "/examples/callbacks.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_empty() -> io::Result<()> { let map = count_chars(Cursor::new(b""))?; assert!(map.is_empty()); Ok(()) } #[test] fn test_basic() -> io::Result<()> { let map = count_chars(Cursor::new(b"aaaabbbbc"))?; assert_eq!(map.len(), 3); ...
code_fim
hard
{ "lang": "rust", "repo": "rust-rosetta/rust-rosetta", "path": "/tasks/letter-frequency/src/main.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> use std::io::Cursor; #[test] fn test_empty() -> io::Result<()> { let map = count_chars(Cursor::new(b""))?; assert!(map.is_empty()); Ok(()) } #[test] fn test_basic() -> io::Result<()> { let map = count_chars(Cursor::new(b"aaaabbbbc"))?; asse...
code_fim
hard
{ "lang": "rust", "repo": "rust-rosetta/rust-rosetta", "path": "/tasks/letter-frequency/src/main.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-rosetta/rust-rosetta path: /tasks/letter-frequency/src/main.rs use std::collections::HashMap; use std::fs::File; use std::io::prelude::*; use std::io::{self, BufReader}; /// Returns a `HashMap` of each letter and its count fn count_chars<R: Read>(reader: R) -> io::Result<HashMap<char, usiz...
code_fim
hard
{ "lang": "rust", "repo": "rust-rosetta/rust-rosetta", "path": "/tasks/letter-frequency/src/main.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Murano/boteg path: /src/messages.rs use hyper::Body; use serde::{ de, de::{MapAccess, Visitor}, Deserialize, Deserializer, Serialize, Serializer, }; use serde_json::Value; use std::{convert::TryFrom, fmt}; #[derive(Debug)] pub struct Update { pub update_id: u64, pub contents...
code_fim
hard
{ "lang": "rust", "repo": "Murano/boteg", "path": "/src/messages.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug)] pub struct CallbackData { pub command: String, pub message_id: Option<u64>, } impl Serialize for CallbackData { fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where S: Serializer, { ...
code_fim
hard
{ "lang": "rust", "repo": "Murano/boteg", "path": "/src/messages.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn visit_map<V>(self, mut map: V) -> Result<Update, V::Error> where V: MapAccess<'de>, { let mut update_id = None; let mut contents = None; while let Some((key, value)) = map.next_entry::<String, Value>()?...
code_fim
hard
{ "lang": "rust", "repo": "Murano/boteg", "path": "/src/messages.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for line in v { if line.starts_with("cpu MHz") { let mhz_str: &str = &line[11..15]; let mhz: i16 = mhz_str.parse().unwrap(); if mhz > top { top = mhz; } } } thread::sleep(de...
code_fim
hard
{ "lang": "rust", "repo": "iphands/hertz", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: iphands/hertz path: /src/main.rs use std::fs::File; use std::io::SeekFrom; use std::io::BufReader; use std::io::prelude::*; use std::{thread}; use std::time::{SystemTime, Duration}; use subprocess::{Popen, PopenConfig, Redirection}; use std::error::Error; use std::env; fn start_process(command:...
code_fim
hard
{ "lang": "rust", "repo": "iphands/hertz", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: 0xdeafbeef/nekoton path: /src/transport/utils.rs use tokio::sync::Mutex; use anyhow::Result; use super::Transport; pub struct ConfigCache { state: Mutex<Option<ConfigCacheState>>, } impl ConfigCache { pub fn new(use_default_config: bool) -> Self { Self { state: Mu...
code_fim
hard
{ "lang": "rust", "repo": "0xdeafbeef/nekoton", "path": "/src/transport/utils.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let master = extra .read_custom() .map_err(|_| QueryConfigError::InvalidBlock)? .ok_or(QueryConfigError::InvalidBlock)?; let params = master .config() .ok_or(QueryConfigError::InvalidBlock)? .clone(); let config = ton_executor::BlockchainConfig...
code_fim
hard
{ "lang": "rust", "repo": "0xdeafbeef/nekoton", "path": "/src/transport/utils.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> for &size in file_sizes { let name = format!("{}", size); let bytes = Byte::from_bytes(size as u128); let display_name = bytes.get_appropriate_unit(true).format(0).to_string(); let path = create_random_test_file(size)?; let p = Param::new(name, display_name, siz...
code_fim
hard
{ "lang": "rust", "repo": "lukaspustina/fastfile", "path": "/fastfile_benches/src/benches/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lukaspustina/fastfile path: /fastfile_benches/src/benches/mod.rs use crate::{benchmark::Param, utils::create_random_test_file}; pub mod methods; use byte_unit::Byte; use std::{fs, io, path::PathBuf}; #[rustfmt::skip] pub static FILE_SIZES_VERY_SMALL: &[usize] = &[ 64, 128, 256, ...
code_fim
hard
{ "lang": "rust", "repo": "lukaspustina/fastfile", "path": "/fastfile_benches/src/benches/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> StateChange::None } }<|fim_prefix|>// repo: PsichiX/global-game-jam-2020 path: /ggj20-game/src/states/menu.rs use crate::states::game::GameState; use oxygengine::prelude::*; #[derive(Default)] pub struct MenuState; <|fim_middle|>impl State for MenuState { fn on_process(&mut self, world:...
code_fim
medium
{ "lang": "rust", "repo": "PsichiX/global-game-jam-2020", "path": "/ggj20-game/src/states/menu.rs", "mode": "spm", "license": "CC-BY-4.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: PsichiX/global-game-jam-2020 path: /ggj20-game/src/states/menu.rs use crate::states::game::GameState; use oxygengine::prelude::*; <|fim_suffix|> StateChange::None } }<|fim_middle|>#[derive(Default)] pub struct MenuState; impl State for MenuState { fn on_process(&mut self, world:...
code_fim
medium
{ "lang": "rust", "repo": "PsichiX/global-game-jam-2020", "path": "/ggj20-game/src/states/menu.rs", "mode": "psm", "license": "CC-BY-4.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nicholasnjihian/All-my-rust-code-thus-far path: /Exploring_Macros/line/src/line.rs //#[cfg(test)] //mod tests { // #[test] //fn it_works() { // assert_eq!(2 + 2, 4); //} //<|fim_suffix|>r>> { let current_line = line!(); let stdout = io::stdout(); let mut...
code_fim
medium
{ "lang": "rust", "repo": "nicholasnjihian/All-my-rust-code-thus-far", "path": "/Exploring_Macros/line/src/line.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>ufWriter::new(stdout); writeln!(handle, "defined on line {}",current_line)?; Ok(()) } }<|fim_prefix|>// repo: nicholasnjihian/All-my-rust-code-thus-far path: /Exploring_Macros/line/src/line.rs //#[cfg(test)] //mod tests { // #[test] //fn it_works() { // assert_eq!(2 + 2,...
code_fim
hard
{ "lang": "rust", "repo": "nicholasnjihian/All-my-rust-code-thus-far", "path": "/Exploring_Macros/line/src/line.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: prokosna/jongleur_back path: /src/util/random_id.rs use rand::{OsRng, Rng}; /// Generate secure random id whose length is `len`. pub fn generate_random_id(len: usiz<|fim_suffix|>en_ascii_chars().take(len).collect()) .unwrap() }<|fim_middle|>e) -> String { OsRng::new() .map(|...
code_fim
easy
{ "lang": "rust", "repo": "prokosna/jongleur_back", "path": "/src/util/random_id.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>en_ascii_chars().take(len).collect()) .unwrap() }<|fim_prefix|>// repo: prokosna/jongleur_back path: /src/util/random_id.rs use rand::{OsRng, Rng}; /// Generate secure random id whose length is `len`. pub fn generate_random_id(len: usiz<|fim_middle|>e) -> String { OsRng::new() .map(|...
code_fim
easy
{ "lang": "rust", "repo": "prokosna/jongleur_back", "path": "/src/util/random_id.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>/// Return a new String containing the urot13'd text from s. /// /// The dat argument is a reference to the hash containing Unicode /// decomposition data (as returned by unidata::generate_hash()). /// fn urot13( s: &str, dat: &HashMap<u32, unidata::Multichar> ) -> String { let mut rva...
code_fim
hard
{ "lang": "rust", "repo": "d2718/urot13", "path": "/urot13.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: d2718/urot13 path: /urot13.rs //! urot13.rs //! //! Perform a Unicode-aware rot13 transformation. //! //! last update: 2016-09-25 //! //! This program manages to perform rot13 on a large number of precomposed //! Unicode characters by decomposing said character into a base character //! and a se...
code_fim
hard
{ "lang": "rust", "repo": "d2718/urot13", "path": "/urot13.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let child_size = TypedWidget::<T, B>::layout(&mut self.child, bc, context, data); self.state.child_size = child_size.clone(); child_size } } #[derive(Debug, Clone)] pub enum ScrollType { Hidden, Scroll, } impl Default for ScrollType { fn default() -> Self { ...
code_fim
hard
{ "lang": "rust", "repo": "AlisCode/utopia", "path": "/utopia_scroll/src/widgets/scrollable.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn layout(&mut self, bc: &BoxConstraints, context: &Self::Context, data: &T) -> Size { let child_size = TypedWidget::<T, B>::layout(&mut self.child, bc, context, data); self.state.child_size = child_size.clone(); child_size } } #[derive(Debug, Clone)] pub enum ScrollType {...
code_fim
hard
{ "lang": "rust", "repo": "AlisCode/utopia", "path": "/utopia_scroll/src/widgets/scrollable.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: AlisCode/utopia path: /utopia_scroll/src/widgets/scrollable.rs use utopia_core::{ math::{Size, Vector2}, widgets::{pod::WidgetPod, TypedWidget, Widget}, Backend, BoxConstraints, CommonPrimitive, }; use crate::primitive::ClipPrimitive; #[derive(Debug, Default, Clone)] pub struct Scr...
code_fim
hard
{ "lang": "rust", "repo": "AlisCode/utopia", "path": "/utopia_scroll/src/widgets/scrollable.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: helgoboss/helgoboss-learn path: /src/base/unit.rs tatic str; fn from_str(source: &str) -> Result<Self, Self::Err> { let primitive = f64::from_str(source).map_err(|_| "not a valid decimal number")?; Ok(SoftSymmetricUnitValue(primitive)) } } /// Defines the normalization ...
code_fim
hard
{ "lang": "rust", "repo": "helgoboss/helgoboss-learn", "path": "/src/base/unit.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl TryFrom<f64> for UnitIncrement { type Error = &'static str; fn try_from(value: f64) -> Result<Self, Self::Error> { if !Self::is_valid(value) { return Err("not a valid unit increment"); } Ok(Self::new(value)) } } impl Display for UnitIncrement { fn...
code_fim
hard
{ "lang": "rust", "repo": "helgoboss/helgoboss-learn", "path": "/src/base/unit.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> write!(f, "{:+}", self.0) } } impl UnitIncrement { pub fn is_valid(number: f64) -> bool { number != 0.0 && (-1.0..=1.0).contains(&number) } /// Creates the unit increment. Panics if the given number is 0.0 or not within the positive or /// negative unit interval. ...
code_fim
hard
{ "lang": "rust", "repo": "helgoboss/helgoboss-learn", "path": "/src/base/unit.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> _copy_mem: usize, _set_mem: usize, _create_event_ex: usize } impl Table for BootServices { fn header(&self) -> TableHeader { self.header } }<|fim_prefix|>// repo: decoup/decoup path: /src/uefi/boot_services.rs use crate::uefi::Handle; use crate::uefi::table::*; #[repr(C)] pu...
code_fim
hard
{ "lang": "rust", "repo": "decoup/decoup", "path": "/src/uefi/boot_services.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: decoup/decoup path: /src/uefi/boot_services.rs use crate::uefi::Handle; use crate::uefi::table::*; #[repr(C)] pub struct BootServices { header: TableHeader, _raise_tpl: usize, _restore_tpl: usize, _allocate_pages: usize, _free_pages: usize, _get_memory_map: usize, ...
code_fim
hard
{ "lang": "rust", "repo": "decoup/decoup", "path": "/src/uefi/boot_services.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dmitriy-shmilo/ray-rs path: /src/vec3.rs use std::ops::{ Mul, Div, Add, Sub, Index }; use std::fmt; #[derive(Debug, Copy, Clone)] pub struct Vec3 { data: [f32; 3] } impl Vec3 { pub fn new_zero() -> Self { Vec3 { data: [0.0 ;3] } } pub fn new_all(v:...
code_fim
hard
{ "lang": "rust", "repo": "dmitriy-shmilo/ray-rs", "path": "/src/vec3.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Vec3::new(self[0] / other[0], self[1] / other[1], self[2] / other[2]) } } impl Index<usize> for Vec3 { type Output = f32; fn index(&self, i: usize) -> &f32{ &self.data[i] } } impl Index<i32> for Vec3 { type Output = f32; fn index(&self, i: i32) -> &f32{ ...
code_fim
hard
{ "lang": "rust", "repo": "dmitriy-shmilo/ray-rs", "path": "/src/vec3.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Run sheduler for checking minimal count of connections with peers pub fn run_periodic_checker(&mut self, ctx: &Context<AstroProtocol>) { let delay = Duration::from_millis(1000); ctx.schedule_once( delay, ctx.myself(), None, AstroP...
code_fim
hard
{ "lang": "rust", "repo": "kedia-project/astrocore", "path": "/src/actors/overlay_manager.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn handle_new_initiated_peer(&mut self, ctx: &Context<AstroProtocol>, address: String) { let name = peer_actor_name(&address); ctx.system .actor_of(PeerActor::initiated_peer_props(address), &name); } pub fn handle_incoming_message( &mut self, ct...
code_fim
hard
{ "lang": "rust", "repo": "kedia-project/astrocore", "path": "/src/actors/overlay_manager.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kedia-project/astrocore path: /src/actors/overlay_manager.rs use super::{ flood_gate_ref, info, peer_actor_name, riker::actors::*, xdr, AstroProtocol, FloodGateActor, OverlayListenerActor, OverlayManager, Peer, PeerActor, }; use std::time::{Duration, SystemTime, UNIX_EPOCH}; #[derive(Cl...
code_fim
hard
{ "lang": "rust", "repo": "kedia-project/astrocore", "path": "/src/actors/overlay_manager.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl<F: Field> UncheckedProjectTo<F> for NonNull<F::Parent> { type Projection = NonNull<F::Type>; unsafe fn project_to(self, field: F) -> Self::Projection { NonNull::new_unchecked(field.project_raw_mut(self.as_ptr())) } } impl<F: Field> UncheckedInverseProjectTo<F> for NonNull<F::Typ...
code_fim
hard
{ "lang": "rust", "repo": "RustyYato/generic-field-projection", "path": "/core/src/unchecked_project.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: RustyYato/generic-field-projection path: /core/src/unchecked_project.rs use crate::{Field, UncheckedInverseProjectTo, UncheckedProjectTo}; use core::ptr::NonNull; impl<F: Field> UncheckedProjectTo<F> for *const F::Parent { type Projection = *const F::Type; unsafe fn project_to(self, f...
code_fim
medium
{ "lang": "rust", "repo": "RustyYato/generic-field-projection", "path": "/core/src/unchecked_project.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MiyamonY/atcoder path: /abc/054/b/01/src/main.rs #[allow(unused_macros)] macro_rules! scan { () => { { let mut line: String = String::new(); std::io::stdin().read_line(&mut line).unwrap(); line.trim().to_string() } }; (;;) => { ...
code_fim
hard
{ "lang": "rust", "repo": "MiyamonY/atcoder", "path": "/abc/054/b/01/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for i in 0..n - m + 1 { for j in 0..n - m + 1 { let mut same = true; for k in 0..m { for l in 0..m { if a[i + k].as_bytes()[j + l] != b[k].as_bytes()[l] { same = false } } ...
code_fim
hard
{ "lang": "rust", "repo": "MiyamonY/atcoder", "path": "/abc/054/b/01/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { let mut s = S::new(); println!("{:?}", s.main()); } //{{{ ////////////////////////// Template ///////////////////////////////////// // macros macro_rules! otry {//{{{ ($e:expr) => (match $e { Some(e) => e, None => return None }) }//}}} // read from stdin struct StdinReader {//{{{ ...
code_fim
hard
{ "lang": "rust", "repo": "Hogeyama/procon", "path": "/ants/2/2-2/fence_repair/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Hogeyama/procon path: /ants/2/2-2/fence_repair/main.rs #![allow(dead_code)] #![allow(unused_imports)] #![allow(unused_variables)] use std::io; use std::cmp; use std::fmt; use std::str; use std::result; use std::cmp::Ordering; use std::collections::BinaryHeap; // Ita #[derive(Debug,Clone,Copy...
code_fim
hard
{ "lang": "rust", "repo": "Hogeyama/procon", "path": "/ants/2/2-2/fence_repair/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jingleizhang/OpenZKP path: /algebra/primefield/benches/fft.rs #![warn(clippy::all)] use criterion::{black_box, criterion_group, Criterion}; use zkp_criterion_utils::{log_size_bench, log_thread_bench}; use zkp_macros_decl::field_element; use zkp_primefield::{fft::fft_cofactor_permuted, FieldEleme...
code_fim
medium
{ "lang": "rust", "repo": "jingleizhang/OpenZKP", "path": "/algebra/primefield/benches/fft.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn fft_threads(crit: &mut Criterion) { let size: usize = *SIZES.last().unwrap(); log_thread_bench(crit, "FFT threads", size, move |bench| { let cofactor = field_element!("0142c45e5d743d10eae7ebb70f1526c65de7dbcdb65b322b6ddc36a812591e8f"); let leaves: Vec<_> = (0..size)....
code_fim
hard
{ "lang": "rust", "repo": "jingleizhang/OpenZKP", "path": "/algebra/primefield/benches/fft.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>/// A protocol error /// /// This kind of error is generated by the server if your client didn't respect /// the protocol, after which the server will kill your connection. #[derive(Clone, Debug)] pub struct ProtocolError { /// The error code associated with the error /// /// It should be inte...
code_fim
hard
{ "lang": "rust", "repo": "YaLTeR/wayland-rs", "path": "/wayland-backend/src/protocol.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: YaLTeR/wayland-rs path: /wayland-backend/src/protocol.rs //! Types and utilities for manipulating the Wayland protocol use std::{ffi::CString, os::unix::prelude::AsRawFd}; pub use wayland_sys::common::{wl_argument, wl_interface, wl_message}; /// Describes whether an argument may have a null v...
code_fim
hard
{ "lang": "rust", "repo": "YaLTeR/wayland-rs", "path": "/wayland-backend/src/protocol.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl std::error::Error for ProtocolError {} impl std::fmt::Display for ProtocolError { #[cfg_attr(coverage, no_coverage)] fn fmt(&self, f: &mut ::std::fmt::Formatter) -> Result<(), ::std::fmt::Error> { write!( f, "Protocol error {} on object {}@{}: {}", ...
code_fim
hard
{ "lang": "rust", "repo": "YaLTeR/wayland-rs", "path": "/wayland-backend/src/protocol.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: theypsilon/arraygen path: /tests/compile-fail/derive-on-struct-non-braced.rs #![no_main] extern crate arraygen; <|fim_suffix|>#[derive(Arraygen)] struct Empty2(i32, f32); //~ERROR 11:14: 11:15: derive 'Arraygen' should only be used with braced structs<|fim_middle|>use arraygen::Arraygen; #[de...
code_fim
medium
{ "lang": "rust", "repo": "theypsilon/arraygen", "path": "/tests/compile-fail/derive-on-struct-non-braced.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Arraygen)] struct Empty1; //~ERROR 8:14: 8:15: derive 'Arraygen' should only be used with braced structs #[derive(Arraygen)] struct Empty2(i32, f32); //~ERROR 11:14: 11:15: derive 'Arraygen' should only be used with braced structs<|fim_prefix|>// repo: theypsilon/arraygen path: /tests/compile-f...
code_fim
easy
{ "lang": "rust", "repo": "theypsilon/arraygen", "path": "/tests/compile-fail/derive-on-struct-non-braced.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>e!(), column!(), stringify!($val), &tmp, type_of(&tmp)); tmp } } } } pub fn print_type_of<T>(_: &T) { println!("{}", unsafe { std::intrinsics::type_name::<T>() }); }<|fim_prefix|>// repo: alishahusain/lpd path: /brontide/src/utils.rs #![feature(core_intrinsics...
code_fim
hard
{ "lang": "rust", "repo": "alishahusain/lpd", "path": "/brontide/src/utils.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alishahusain/lpd path: /brontide/src/utils.rs #![feature(core_intrinsics)] // Slightly modified version of dbg! macro which includes also type information and column name // This works only in night builds of rust. // It uses approach from https://stacko<|fim_suffix|>e!(), column!(), stringify!...
code_fim
hard
{ "lang": "rust", "repo": "alishahusain/lpd", "path": "/brontide/src/utils.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl IntoSendable for State { type T = State; fn into_sendable(self) -> Self::T { todo!() } }<|fim_prefix|>// repo: cda-group/arc path: /arc-runtime/examples/consensus/src/state.rs use arc_runtime::prelude::*; <|fim_middle|>#[derive(Clone, Debug, New)] pub struct State { pub key:...
code_fim
medium
{ "lang": "rust", "repo": "cda-group/arc", "path": "/arc-runtime/examples/consensus/src/state.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cda-group/arc path: /arc-runtime/examples/consensus/src/state.rs use arc_runtime::prelude::*; <|fim_suffix|>impl IntoSendable for State { type T = State; fn into_sendable(self) -> Self::T { todo!() } }<|fim_middle|>#[derive(Clone, Debug, New)] pub struct State { pub key:...
code_fim
medium
{ "lang": "rust", "repo": "cda-group/arc", "path": "/arc-runtime/examples/consensus/src/state.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { ptr_partial_read(); transmute_strip_provenance(); }<|fim_prefix|>// repo: rust-lang/miri path: /tests/pass/ptr_int_transmute.rs //@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows // Test what happens when we read parts of a pointer. // Related to <https://github.com/...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/miri", "path": "/tests/pass/ptr_int_transmute.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/miri path: /tests/pass/ptr_int_transmute.rs //@revisions: stack tree //@[tree]compile-flags: -Zmiri-tree-borrows // Test what happens when we read parts of a pointer. // Related to <https://github.com/rust-lang/rust/issues/69488>. fn ptr_partial_read() { <|fim_suffix|>fn transmute_stri...
code_fim
medium
{ "lang": "rust", "repo": "rust-lang/miri", "path": "/tests/pass/ptr_int_transmute.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[deriving(Clone)] pub struct Tile { pub sprite: Sprite, pub tile_type: TileType, pub variant: uint, pub regions: Vec<uint>, pub cost: uint, animation_handler: AnimationHandler } impl Tile { pub fn new(tile_size: uint, height: uint, texture: TextureRc, animations: Vec<Animatio...
code_fim
hard
{ "lang": "rust", "repo": "HexColors60/citybuilder", "path": "/src/tile.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl TileType { pub fn residential(max_pop_per_level: uint, max_levels: uint) -> TileType { Residential { population: 0.0, max_pop_per_level: max_pop_per_level, max_levels: max_levels } } pub fn commercial(max_pop_per_level: uint, max_levels...
code_fim
hard
{ "lang": "rust", "repo": "HexColors60/citybuilder", "path": "/src/tile.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: HexColors60/citybuilder path: /src/tile.rs use std::rand::{Rng, task_rng}; use std::fmt; use std::rc::Rc; use std::cell::RefCell; use rsfml; use rsfml::graphics::{RenderWindow, IntRect}; use rsfml::graphics::rc::Sprite; use rsfml::system::vector2::Vector2f; pub type TextureRc = Rc<RefCell<rsfm...
code_fim
hard
{ "lang": "rust", "repo": "HexColors60/citybuilder", "path": "/src/tile.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug, Clone, PartialEq)] pub struct Token { pub token_type: TokenType, pub literal: String, } pub fn lookup_ident(ident: &str) -> TokenType { match ident { "let" => TokenType::Let, "fn" => TokenType::Function, "true" => TokenType::True, "false" => Tok...
code_fim
medium
{ "lang": "rust", "repo": "zaki-yama/monkey-interpreter-rust", "path": "/src/token.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zaki-yama/monkey-interpreter-rust path: /src/token.rs #[derive(Debug, PartialEq, Clone)] pub enum TokenType { Illegal, Eof, // 識別子 + リテラル Ident, // add, foobar, x, y, ... Int, // 123456 // 演算子 Assign, Plus, Minus, Bang, Asterisk, Slash, Lt, ...
code_fim
medium
{ "lang": "rust", "repo": "zaki-yama/monkey-interpreter-rust", "path": "/src/token.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bouzuya/rust-social-bookmarking path: /src/use_case/get_current_user_use_case.rs use crate::entity::User; use crate::service::SessionService; use anyhow::Result; use std::sync::Arc; <|fim_suffix|>impl GetCurrentUserUseCase { pub fn new(session_service: Arc<dyn SessionService>) -> Self { ...
code_fim
medium
{ "lang": "rust", "repo": "bouzuya/rust-social-bookmarking", "path": "/src/use_case/get_current_user_use_case.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn get_current_user(&self) -> Result<Option<User>> { self.session_service.get_current_user() } }<|fim_prefix|>// repo: bouzuya/rust-social-bookmarking path: /src/use_case/get_current_user_use_case.rs use crate::entity::User; use crate::service::SessionService; use anyhow::Result; use ...
code_fim
hard
{ "lang": "rust", "repo": "bouzuya/rust-social-bookmarking", "path": "/src/use_case/get_current_user_use_case.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if is_collinear { Isometry3::face_towards(&origin, &(origin + z), &WORLD_RIGHT).inverse() } else { Isometry3::face_towards(&origin, &(origin + z), &WORLD_UP).inverse() } } pub struct SampleRecord { pub o: Point3<f64>, pub on: Vector3<f64>, pub m: Isometry3<f64>, ...
code_fim
hard
{ "lang": "rust", "repo": "WBreno9/rusttracer", "path": "/src/sample.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: WBreno9/rusttracer path: /src/sample.rs extern crate nalgebra as na; use na::{Isometry3, Point3, Vector3}; use crate::object; use crate::ray::Ray; use std::f64::consts::PI; lazy_static! { pub static ref WORLD_UP: Vector3<f64> = Vector3::<f64>::new(0.0, 1.0, 0.0); pub static ref WORLD_...
code_fim
medium
{ "lang": "rust", "repo": "WBreno9/rusttracer", "path": "/src/sample.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: heroes-coding/rusty_replays path: /src/load.rs use unpack::Replay; pub fn add_replay(replay: Replay) { ::REPLAYS.lock().unwrap().push(replay); } pub fn print_replay(index: usize) { println!("Replay {}: {}",index,::REPLAYS.lock().unwrap()[index]); } <|fim_suffix|> /* let roles ...
code_fim
hard
{ "lang": "rust", "repo": "heroes-coding/rusty_replays", "path": "/src/load.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!("ROLES: {:?}",*::ROLES.lock().unwrap()); println!("N_HEROES: {}",*::N_HEROES.lock().unwrap()); assert_eq!(78,*::N_HEROES.lock().unwrap()); */ }<|fim_prefix|>// repo: heroes-coding/rusty_replays path: /src/load.rs use unpack::Replay; pub fn add_replay(replay: Replay) { ::REP...
code_fim
medium
{ "lang": "rust", "repo": "heroes-coding/rusty_replays", "path": "/src/load.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: KeenS/webml path: /src/mir/unalias.rs use crate::config::Config; use crate::mir::*; use crate::pass::Pass; use crate::prim::*; use std::collections::HashMap; #[derive(Default)] pub struct UnAlias { alias: HashMap<Symbol, Symbol>, } impl UnAlias { fn conv_mir(&mut self, mir: MIR) -> MIR...
code_fim
hard
{ "lang": "rust", "repo": "KeenS/webml", "path": "/src/mir/unalias.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> fn conv_ebb(&mut self, mut ebb: EBB) -> EBB { use crate::mir::Op::*; let mut body = Vec::new(); for mut op in ebb.body.into_iter() { match &mut op { Alias { var, sym, .. } => { self.alias(var.clone(), sym.clone()); ...
code_fim
hard
{ "lang": "rust", "repo": "KeenS/webml", "path": "/src/mir/unalias.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_invalid_hosts_file() { let (mut file, path) = tempfile::NamedTempFile::new().unwrap().keep().unwrap(); file.write_all("invalid data".as_ref()).unwrap(); match Hosts::load_from(&path).unwrap_err() { Error::ParseHosts { .. } => {} _ =>...
code_fim
hard
{ "lang": "rust", "repo": "lumost/native_spark", "path": "/src/hosts.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lumost/native_spark path: /src/hosts.rs use std::net::SocketAddr; use std::path::Path; use crate::error::{Error, Result}; use once_cell::sync::OnceCell; use serde_derive::Deserialize; static HOSTS: OnceCell<Hosts> = OnceCell::new(); /// Handles loading of the hosts configuration. #[derive(Deb...
code_fim
hard
{ "lang": "rust", "repo": "lumost/native_spark", "path": "/src/hosts.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }