text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: sebbert/vectrex-rs path: /src/memory.rs pub trait Memory { fn read_8(&mut self, addr: u16) -> u8; <|fim_suffix|> fn read_16(&mut self, addr: u16) -> u16; fn write_16(&mut self, addr: u16, value: u16); }<|fim_middle|> fn write_8(&mut self, addr: u16, value: u8);
code_fim
easy
{ "lang": "rust", "repo": "sebbert/vectrex-rs", "path": "/src/memory.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn read_16(&mut self, addr: u16) -> u16; fn write_16(&mut self, addr: u16, value: u16); }<|fim_prefix|>// repo: sebbert/vectrex-rs path: /src/memory.rs pub trait Memory { fn read_8(&mut self, addr: u16) -> u8; <|fim_middle|> fn write_8(&mut self, addr: u16, value: u8);
code_fim
easy
{ "lang": "rust", "repo": "sebbert/vectrex-rs", "path": "/src/memory.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn write_16(&mut self, addr: u16, value: u16); }<|fim_prefix|>// repo: sebbert/vectrex-rs path: /src/memory.rs pub trait Memory { fn read_8(&mut self, addr: u16) -> u8; fn write_8(&mut self, addr: u16, value: u8); <|fim_middle|> fn read_16(&mut self, addr: u16) -> u16;
code_fim
easy
{ "lang": "rust", "repo": "sebbert/vectrex-rs", "path": "/src/memory.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: danhper/diem path: /language/diem-vm/src/unit_tests/script_to_script_function_tests.rs // Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 use crate::{ ADD_CURRENCY_TO_ACCOUNT_BYTES, ADD_RECOVERY_ROTATION_CAPABILITY_BYTES, ADD_VALIDATOR_AND_RECONFIGURE_BYT...
code_fim
hard
{ "lang": "rust", "repo": "danhper/diem", "path": "/language/diem-vm/src/unit_tests/script_to_script_function_tests.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> use LegacyStdlibScript as S; for script in LegacyStdlibScript::all() { let bytes_from_pattern = match script { S::AddCurrencyToAccount => ADD_CURRENCY_TO_ACCOUNT_BYTES!().to_vec(), S::AddRecoveryRotationCapability => ADD_RECOVERY_ROTATION_CAPABILITY_BYTES!().to_vec(...
code_fim
hard
{ "lang": "rust", "repo": "danhper/diem", "path": "/language/diem-vm/src/unit_tests/script_to_script_function_tests.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: RustyYato/chess path: /chess-lookup/src/lib.rs #![forbid(unsafe_op_in_unsafe_fn)] use chess_bitboard::{BitBoard, Color, File, Piece, Pos, Rank}; mod between; mod bishop_moves; mod bishop_rays; // mod book; mod king_moves; mod knight_moves; #[allow(clippy::all)] mod lichess_book; mod line; mod ...
code_fim
hard
{ "lang": "rust", "repo": "RustyYato/chess", "path": "/chess-lookup/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl core::fmt::Debug for BookMoves { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "book{}", self.index) } } pub const INITIAL_BOOOK_MOVES: BookMoves = BookMoves { index: lichess_book::BOOK_SIZE - 1, }; pub const EMPTY_BOOK_MOVES: BookMoves = BookMove...
code_fim
hard
{ "lang": "rust", "repo": "RustyYato/chess", "path": "/chess-lookup/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>instance::{PyToken, PyObjectWithToken, AsPyRef, Py, PyNativeType}; pub use conversion::{FromPyObject, RefFromPyObject, PyTryFrom, PyTryInto, ToPyObject, ToBorrowedObject, IntoPyObject, IntoPyTuple};<|fim_prefix|>// repo: rochacbruno/pyo3 path: /src/prelude.rs // Copyright (c) 2017-pr...
code_fim
hard
{ "lang": "rust", "repo": "rochacbruno/pyo3", "path": "/src/prelude.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rochacbruno/pyo3 path: /src/prelude.rs // Copyright (c) 2017-present PyO3 Project and Contributors //! The `PyO3` Prelude //! //! The purpose of this module is to alleviate imports of many common pyo3 traits //! by adding a glob import to the top of pyo3 h<|fim_suffix|> use noargs::NoArgs; pub ...
code_fim
hard
{ "lang": "rust", "repo": "rochacbruno/pyo3", "path": "/src/prelude.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> num == string .chars() .map(|c| c.to_string().parse::<u32>().unwrap().pow(exp as u32)) .sum() }<|fim_prefix|>// repo: spejamchr/exercism_solutions path: /rust/armstrong-numbers/src/lib.rs pub fn is_armstrong_number(num: u32) -> bool { let strin<|fim_middle|>g = num.to_string...
code_fim
medium
{ "lang": "rust", "repo": "spejamchr/exercism_solutions", "path": "/rust/armstrong-numbers/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: spejamchr/exercism_solutions path: /rust/armstrong-numbers/src/lib.rs pub fn is_armstrong_number(num: u32) -> bool { let string = num.to_string(); let exp = string.chars().count(); <|fim_suffix|>g().parse::<u32>().unwrap().pow(exp as u32)) .sum() }<|fim_middle|> num == string ...
code_fim
medium
{ "lang": "rust", "repo": "spejamchr/exercism_solutions", "path": "/rust/armstrong-numbers/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: leizongmin/tvm-rust path: /src/ast.rs #[derive(Debug)] pub enum OpCode { Block, Print, Exit } #[derive(Debug)] pub enum Value { None, Number(f64), String(String), Function(String), Block(AST), } #[derive(Debug)] pub struct AST { pub opcode: OpCode, pub a...
code_fim
hard
{ "lang": "rust", "repo": "leizongmin/tvm-rust", "path": "/src/ast.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[inline] pub fn push(&mut self, ast: AST) { self.chilren.push(ast); } }<|fim_prefix|>// repo: leizongmin/tvm-rust path: /src/ast.rs #[derive(Debug)] pub enum OpCode { Block, Print, Exit } #[derive(Debug)] pub enum Value { None, Number(f64), String(String), ...
code_fim
hard
{ "lang": "rust", "repo": "leizongmin/tvm-rust", "path": "/src/ast.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> impl ReadFD for FakeStreamRead { fn read( &mut self, buf: &mut [u8], _fd_storage: &mut Vec<RawFdContainer>, ) -> Result<usize, std::io::Error> { if self.pending.is_empty() { let packet = self.recv.recv().unwrap(); ...
code_fim
hard
{ "lang": "rust", "repo": "dalcde/x11rb", "path": "/tests/multithread_test.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dalcde/x11rb path: /tests/multithread_test.rs use std::sync::Arc; use x11rb::connection::Connection as _; use x11rb::protocol::xproto::{ ClientMessageData, ClientMessageEvent, ConnectionExt as _, EventMask, CLIENT_MESSAGE_EVENT, }; // Regression test for https://github.com/psychon/x11rb/is...
code_fim
hard
{ "lang": "rust", "repo": "dalcde/x11rb", "path": "/tests/multithread_test.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: xmc-rs/xmc4-hal path: /src/rtc.rs #![allow(dead_code)] use crate::device::{RTC, SCU_GENERAL, SCU_POWER, SCU_RESET}; // use crate::scu::Scu; /// Maximum number of seconds for the RTC time const MAX_SECONDS: u8 = 59; /// Maximum number of minutes for the RTC time const MAX_MINUTES: u8 = 59; /// ...
code_fim
hard
{ "lang": "rust", "repo": "xmc-rs/xmc4-hal", "path": "/src/rtc.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match val { Weekday::Sunday => 0, Weekday::Monday => 1, Weekday::Tuesday => 2, Weekday::Wednesday => 3, Weekday::Thursday => 4, Weekday::Friday => 5, Weekday::Saturday => 6, } } } /// Representation of...
code_fim
hard
{ "lang": "rust", "repo": "xmc-rs/xmc4-hal", "path": "/src/rtc.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn set_time(&self, time: Time) { assert!(time.second < MAX_SECONDS); assert!(time.minute < MAX_MINUTES); assert!(time.hour < MAX_HOURS); assert!(time.day < MAX_DAYS); assert!(time.year < MAX_YEAR); self.wait_for_mirrsts(); let rtc = periph!(...
code_fim
hard
{ "lang": "rust", "repo": "xmc-rs/xmc4-hal", "path": "/src/rtc.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let serial = stm32_nucleo::serial!(p, clocks); let (mut tx, mut rx) = serial.split(); loop { let byte = block!(rx.read()).unwrap(); block!(tx.write(byte)).ok(); } }<|fim_prefix|>// repo: mvertescher/stm32-nucleo path: /examples/serial_echo.rs //! Serial interface echo ser...
code_fim
medium
{ "lang": "rust", "repo": "mvertescher/stm32-nucleo", "path": "/examples/serial_echo.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mvertescher/stm32-nucleo path: /examples/serial_echo.rs //! Serial interface echo server for all Nucleo-64 boards #![deny(unsafe_code)] #![deny(warnings)] #![no_main] #![no_std] extern crate panic_semihosting; use cortex_m_rt::entry; use stm32_nucleo::hal::{prelude::*, stm32}; use nb::block; ...
code_fim
medium
{ "lang": "rust", "repo": "mvertescher/stm32-nucleo", "path": "/examples/serial_echo.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> /// Get the first [`Label`] in the `Path` and the rest of the [`Label`]s after it. /// /// # Examples /// /// ``` /// use radicle_surf::file_system::{Label, Path}; /// use radicle_surf::file_system::unsound; /// /// let path = unsound::path::new("~/src/lib.rs"); ///...
code_fim
hard
{ "lang": "rust", "repo": "alexjg/radicle-surf", "path": "/src/file_system/path/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alexjg/radicle-surf path: /src/file_system/path/mod.rs use crate::file_system::error; use crate::nonempty::split_last; use nonempty::NonEmpty; use std::convert::TryFrom; use std::fmt; use std::ops::Deref; use std::path; use std::str::FromStr; pub mod unsound; /// `Label` is a special case of a...
code_fim
hard
{ "lang": "rust", "repo": "alexjg/radicle-surf", "path": "/src/file_system/path/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn test_helloworld() { let code = OwnedCode::parse( r"밤밣따빠밣밟따뿌 빠맣파빨받밤뚜뭏 돋밬탕빠맣붏두붇 볻뫃박발뚷투뭏붖 뫃도뫃희멓뭏뭏붘 뫃봌토범더벌뿌뚜 뽑뽀멓멓더벓뻐뚠 뽀덩벐멓뻐덕더벅", ); let mut input = std::io::Cursor::new(""); let mut output = Vec::new(); let res = Env::new(&code, &mut input, &mut output).execute(); as...
code_fim
hard
{ "lang": "rust", "repo": "foriequal0/aheui-rs", "path": "/aheui-core/tests/exec.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: foriequal0/aheui-rs path: /aheui-core/tests/exec.rs use aheui_core::*; #[test] fn test_echo() { let code = OwnedCode::parse(r"밯망희"); let mut input = std::io::Cursor::new("밯"); let mut output = Vec::new(); let res = Env::new(&code, &mut input, &mut output).execute(); assert_...
code_fim
hard
{ "lang": "rust", "repo": "foriequal0/aheui-rs", "path": "/aheui-core/tests/exec.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if *count != 0 { *count -= 1; cows += 1; } } } format!("{bulls}A{cows}B") } } // ------------------------------------------------------ snip ------------------------------------------------------ // ...
code_fim
hard
{ "lang": "rust", "repo": "EFanZh/LeetCode", "path": "/src/problem_0299_bulls_and_cows/iterative.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: EFanZh/LeetCode path: /src/problem_0299_bulls_and_cows/iterative.rs pub struct Solution; // ------------------------------------------------------ snip ------------------------------------------------------ // impl Solution { pub fn get_hint(secret: String, guess: String) -> String { ...
code_fim
hard
{ "lang": "rust", "repo": "EFanZh/LeetCode", "path": "/src/problem_0299_bulls_and_cows/iterative.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: JonatanRaverta/qdrant path: /lib/collection/tests/common/mod.rs use collection::collection_builder::collection_builder::build_collection; use wal::WalOptions; use collection::collection::Collection; use segment::types::{Distance, SegmentConfig, Indexes}; use tokio::runtime::Runtime; use tokio::r...
code_fim
medium
{ "lang": "rust", "repo": "JonatanRaverta/qdrant", "path": "/lib/collection/tests/common/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let collection = load_collection( collection_path, &wal_options, threaded_rt.clone(), &TEST_OPTIMIZERS_CONFIG, ); return (threaded_rt, collection); } pub fn simple_collection_fixture(collection_path: &Path) -> (Arc<Runtime>, Collection) { let wal_options ...
code_fim
hard
{ "lang": "rust", "repo": "JonatanRaverta/qdrant", "path": "/lib/collection/tests/common/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let collection = build_collection( collection_path, &wal_options, &collection_config, threaded_rt.clone(), &TEST_OPTIMIZERS_CONFIG, ).unwrap(); return (threaded_rt, collection); }<|fim_prefix|>// repo: JonatanRaverta/qdrant path: /lib/collection/tests...
code_fim
hard
{ "lang": "rust", "repo": "JonatanRaverta/qdrant", "path": "/lib/collection/tests/common/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tkonid/forester path: /forester-crate/src/vec2d.rs //! A row-major contiguous two-dimensional array type, written `Vec2D<T>`. //! //! `Vec2D` implements indexing by a tuple `(row, col)` to get a single item, or by a scalar to //! get the slice of a row. Iteration is implemented over rows. //! //...
code_fim
hard
{ "lang": "rust", "repo": "tkonid/forester", "path": "/forester-crate/src/vec2d.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let x: Vec2D<f64> = Vec2D::new(); assert_eq!(x.n_cols(), 0); assert_eq!(x.n_rows(), 0); let y = Vec2D::from_slice(&[1, 2, 3, 4], 1); assert_eq!(y.n_cols(), 1); assert_eq!(y.n_rows(), 4); let y = Vec2D::from_slice(&[1, 2, 3, 4], 2); assert_e...
code_fim
hard
{ "lang": "rust", "repo": "tkonid/forester", "path": "/forester-crate/src/vec2d.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[test] #[should_panic] fn empty_iter() { let x: Vec2D<u32> = Vec2D::new(); x.iter(); } #[test] fn indexing() { let x: Vec2D<i32> = Vec2D::from_slice(&vec!(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12), 3); assert_eq!(x.n_rows(), 4); assert_eq!(x[...
code_fim
hard
{ "lang": "rust", "repo": "tkonid/forester", "path": "/forester-crate/src/vec2d.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub fn check_proof(password: &str, proof: &str, allowed_diff: u64) -> bool { let epoch = SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs(); for time in (epoch - allowed_diff)..(epoch + allowed_diff) { if proof_for_time(password, time) == proof { return true; ...
code_fim
medium
{ "lang": "rust", "repo": "unixpickle/squidtun", "path": "/src/proof.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: unixpickle/squidtun path: /src/proof.rs use std::fmt::Write; use std::time::{SystemTime, UNIX_EPOCH}; use sha1::Sha1; pub fn proof_for_time(password: &str, time: u64) -> String { let mut sh = Sha1::new(); sh.update(format!("{}{}{}", password, time, password).as_bytes()); let hash =...
code_fim
medium
{ "lang": "rust", "repo": "unixpickle/squidtun", "path": "/src/proof.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let yaml = load_yaml!("cli.yml"); let matches = App::from_yaml(yaml).version(VERSION).get_matches(); let in_path = matches.value_of("input"); let out_path = matches.value_of("output"); loggerv::Logger::new() .verbosity(matches.occurrences_of("v")) .level(matches.is_pre...
code_fim
hard
{ "lang": "rust", "repo": "duzhanyuan/mamba", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: duzhanyuan/mamba path: /src/main.rs #[macro_use] extern crate clap; extern crate ansi_term; #[macro_use] extern crate log; extern crate loggerv; use clap::App; use mamba::pipeline::transpile_directory; const VERSION: &str = env!("CARGO_PKG_VERSION"); pub fn main() -> Result<(), String> { ...
code_fim
hard
{ "lang": "rust", "repo": "duzhanyuan/mamba", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn compare_op(mut self, value: VkCompareOp) -> VkStencilOpStateBuilder<'a> { self.s.compare_op = value; self } pub fn compare_mask(mut self, value: u32) -> VkStencilOpStateBuilder<'a> { self.s.compare_mask = value; self } pub fn write_mask(...
code_fim
hard
{ "lang": "rust", "repo": "stevenlr/HandmadeRust", "path": "/vk/builders.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stevenlr/HandmadeRust path: /vk/builders.rs n format(mut self, value: VkFormat) -> VkImageCreateInfoBuilder<'a> { self.s.format = value; self } pub fn extent(mut self, value: VkExtent3D) -> VkImageCreateInfoBuilder<'a> { self.s.extent = value; sel...
code_fim
hard
{ "lang": "rust", "repo": "stevenlr/HandmadeRust", "path": "/vk/builders.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> pub fn max_vertex_input_bindings(mut self, value: u32) -> VkPhysicalDeviceLimitsBuilder<'a> { self.s.max_vertex_input_bindings = value; self } pub fn max_vertex_input_attribute_offset( mut self, value: u32, ) -> VkPhysicalDeviceLimitsBuilder<'a> { ...
code_fim
hard
{ "lang": "rust", "repo": "stevenlr/HandmadeRust", "path": "/vk/builders.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bifrost-rs/bifrost path: /bifrost-stun/src/agent/mod.rs use crate::message::{Message, TransactionId}; use std::collections::HashMap; use std::future::Future; use std::io; use std::net::SocketAddr; use std::sync::Arc; use std::time::Duration; use tokio_sync::{oneshot, Mutex}; use tokio_timer::Tim...
code_fim
hard
{ "lang": "rust", "repo": "bifrost-rs/bifrost", "path": "/bifrost-stun/src/agent/mod.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> pub async fn on_recv(&self, msg: Message, addr: SocketAddr) { let tx = self .transactions .lock() .await .remove(&(msg.transaction_id, addr)); if let Some(tx) = tx { let _ = tx.send(msg); } } } #[cfg(test)] mod t...
code_fim
hard
{ "lang": "rust", "repo": "bifrost-rs/bifrost", "path": "/bifrost-stun/src/agent/mod.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> the_same(Point2D::<f32>::new(1.0, 2.0)); assert_eq!(Point2D::<f32>::poke_max_size(), 2 * size_of::<f32>()); the_same(Rect::<f32>::new( Point2D::<f32>::new(0.0, 0.0), Size2D::<f32>::new(100.0, 80.0), )); assert_eq!(Rect::<f32>::poke_max_size(...
code_fim
hard
{ "lang": "rust", "repo": "djg/unsafe-poke", "path": "/tests/test.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: djg/unsafe-poke path: /tests/test.rs use bincode::serialize; use serde_derive::Serialize; use std::{fmt::Debug, marker::PhantomData}; use unsafe_poke::UnsafePoke; use unsafe_poke_derive::UnsafePoke; fn bincode_encode<V>(element: &V) -> Vec<u8> where V: serde::Serialize, { serialize(&ele...
code_fim
hard
{ "lang": "rust", "repo": "djg/unsafe-poke", "path": "/tests/test.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn test_tuple() { the_same((1isize,)); the_same((1isize, 2isize, 3isize)); the_same((1isize, ())); } #[test] fn test_basic_struct() { #[derive(Serialize, PartialEq, Debug, UnsafePoke)] struct Bar { a: u32, b: u32, c: u32, d: Option<u32>, } ...
code_fim
hard
{ "lang": "rust", "repo": "djg/unsafe-poke", "path": "/tests/test.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: RustisLeague/rustis path: /src/rustis/value.rs use std::collections::{BTreeMap, HashMap, HashSet, VecDeque}; use std::fmt::{Display, Formatter, Result}; #[derive(Clone, PartialEq, Debug)] pub enum Value { Nil, IntValue(i64), StrValue(String), ArrayValue(Vec<Value>), ListValu...
code_fim
hard
{ "lang": "rust", "repo": "RustisLeague/rustis", "path": "/src/rustis/value.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(format!("{}", Value::StrValue("".to_string())), "$0\r\n\r\n"); assert_eq!(format!("{}", Value::StrValue("a".to_string())), "$1\r\na\r\n"); assert_eq!(format!("{}", Value::StrValue("abc def".to_string())), "$7\r\nabc def\r\n"); assert_eq!(format!("{}", Value::StrValue("abc\ndefg"...
code_fim
hard
{ "lang": "rust", "repo": "RustisLeague/rustis", "path": "/src/rustis/value.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: suspend0/aws-sdk-rust path: /sdk/servicecatalogappregistry/src/client.rs M, R>, conf: crate::Config, } /// An ergonomic service client for `AWS242AppRegistry`. /// /// This client allows ergonomic access to a `AWS242AppRegistry`-shaped service. /// Each method corresponds to an endpoint def...
code_fim
hard
{ "lang": "rust", "repo": "suspend0/aws-sdk-rust", "path": "/sdk/servicecatalogappregistry/src/client.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: suspend0/aws-sdk-rust path: /sdk/servicecatalogappregistry/src/client.rs self, input: std::option::Option<crate::model::ResourceType>, ) -> Self { self.inner = self.inner.set_resource_type(input); self } /// <p>The name or ID of the res...
code_fim
hard
{ "lang": "rust", "repo": "suspend0/aws-sdk-rust", "path": "/sdk/servicecatalogappregistry/src/client.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: andrecp/rustbook path: /projects/genericz/src/generic.rs pub fn largest_i32(list: &[i32]) -> &i32 { let mut largest = &list[0]; <|fim_suffix|> for &item in list { if item > largest { largest = item; } } largest } struct Point<T> { x: T, y: T,...
code_fim
hard
{ "lang": "rust", "repo": "andrecp/rustbook", "path": "/projects/genericz/src/generic.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let integer = Point { x: 5, y: 10 }; let float = Point { x: 1.0, y: 4.0 }; }<|fim_prefix|>// repo: andrecp/rustbook path: /projects/genericz/src/generic.rs pub fn largest_i32(list: &[i32]) -> &i32 { let mut largest = &list[0]; for item in list { if item > largest { la...
code_fim
medium
{ "lang": "rust", "repo": "andrecp/rustbook", "path": "/projects/genericz/src/generic.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Emoji::encode(input.as_ref()) } fn decode<I: AsRef<str>>(input: I) -> Result<Vec<u8>> { Emoji::decode(input.as_ref()).map_err(|e| e.into()) } } derive_base_encoding! { /// Base2 (alphabet: 01). Base2, encoding::BASE2; /// Base8 (alphabet: 01234567). Base8, enc...
code_fim
hard
{ "lang": "rust", "repo": "multiformats/rust-multibase", "path": "/src/impls.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: multiformats/rust-multibase path: /src/impls.rs use crate::encoding; use crate::error::Result; use base256emoji::{Base, Emoji}; #[cfg(not(feature = "std"))] use alloc::{string::String, vec::Vec}; macro_rules! derive_base_encoding { ( $(#[$doc:meta] $type:ident, $encoding:expr;)* ) => { ...
code_fim
hard
{ "lang": "rust", "repo": "multiformats/rust-multibase", "path": "/src/impls.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: creativcoder/Rustacian path: /rust_essentials_exercise/chap5/str_op.rs struct Str { data:Vec<char>, len:u32, } impl Str { fn new() -> Self { Str { data:Vec::new(),len:0 } } fn push(&mut self,letter:char) { self.data.push(letter); } fn len(&self) -> u32 { {self.len} } <|fim_suffi...
code_fim
medium
{ "lang": "rust", "repo": "creativcoder/Rustacian", "path": "/rust_essentials_exercise/chap5/str_op.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for i in self.data { print!("{}",i); } } } fn main() { let mut s1 = Str::new(); s1.push('r'); s1.push('u'); s1.push('s'); s1.push('t'); s1.display(); }<|fim_prefix|>// repo: creativcoder/Rustacian path: /rust_essentials_exercise/chap5/str_op.rs struct Str { data:Vec<char>, len:u32, } ...
code_fim
medium
{ "lang": "rust", "repo": "creativcoder/Rustacian", "path": "/rust_essentials_exercise/chap5/str_op.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut entries: Vec<String> = Vec::new(); match archive.list() { Ok(archive) => for entry in archive { match entry { Ok(e) => entries.push(e.filename), Err(e) => return Err(format_err!("{}", e)), } }, Err(e) => retur...
code_fim
hard
{ "lang": "rust", "repo": "casret/rust_opds", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn process_zip(entry: &DirEntry) -> Result<(Option<String>, Vec<String>), Error> { info!("Processing {}", entry.path().display()); let zipfile = std::fs::File::open(&entry.path())?; let mut archive = zip::ZipArchive::new(zipfile)?; let mut comic_info = None; let mut entries = Vec::new...
code_fim
hard
{ "lang": "rust", "repo": "casret/rust_opds", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: casret/rust_opds path: /src/lib.rs #[macro_use] extern crate serde_derive; extern crate argon2rs; extern crate base64; extern crate chrono; extern crate env_logger; extern crate serde; #[macro_use] extern crate failure; extern crate futures; extern crate hyper; #[macro_use] extern crate lazy_st...
code_fim
hard
{ "lang": "rust", "repo": "casret/rust_opds", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: toolness/werewolves-and-wanderer-rs path: /src/sized_enum.rs use std::marker::PhantomData; use enum_primitive::FromPrimitive; use platform::*; // There doesn't seem to be a convenient way to get the "size" or // "range" of an enum's possible values, so we'll make a trait for // that here. // /...
code_fim
hard
{ "lang": "rust", "repo": "toolness/werewolves-and-wanderer-rs", "path": "/src/sized_enum.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|>impl<T: SizedEnum> SizedEnumIterator<T> { fn new() -> Self { Self { current: 0, phantom: PhantomData } } } impl<T: SizedEnum> Iterator for SizedEnumIterator<T> { type Item = T; fn next(&mut self) -> Option<T> { while self.current < T::size() { let result = T::from_usize(self.curren...
code_fim
hard
{ "lang": "rust", "repo": "toolness/werewolves-and-wanderer-rs", "path": "/src/sized_enum.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|>pub struct SizedEnumIterator<T: SizedEnum> { current: usize, phantom: PhantomData<T>, } impl<T: SizedEnum> SizedEnumIterator<T> { fn new() -> Self { Self { current: 0, phantom: PhantomData } } } impl<T: SizedEnum> Iterator for SizedEnumIterator<T> { type Item = T; fn next(&mut self) -> ...
code_fim
hard
{ "lang": "rust", "repo": "toolness/werewolves-and-wanderer-rs", "path": "/src/sized_enum.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gwenn/rustyline path: /src/keys.rs //! Key constants /// #[non_exhaustive] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum KeyPress { UnknownEscSeq, Backspace, // Ctrl('H') BackTab, Char(char), ControlDown, ControlLeft, ControlRight, ControlUp, Ct...
code_fim
hard
{ "lang": "rust", "repo": "gwenn/rustyline", "path": "/src/keys.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>ess::Ctrl('X'), '\x19' => KeyPress::Ctrl('Y'), '\x1a' => KeyPress::Ctrl('Z'), '\x1b' => KeyPress::Esc, // Ctrl-[ '\x1c' => KeyPress::Ctrl('\\'), '\x1d' => KeyPress::Ctrl(']'), '\x1e' => KeyPress::Ctrl('^'), '\x1f' => KeyPress::Ctrl('_'), '\x7...
code_fim
hard
{ "lang": "rust", "repo": "gwenn/rustyline", "path": "/src/keys.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Technolution/rustig path: /lib/panic_analysis/src/lib.rs pe RustigCallGraph = CallGraph<RDPProcedureMetaData, RDPInvocationMetaData, RDPInlineFrameMetaData>; /// Main entry point of the `panic_analysis` crate. /// /// This function accepts some options [AnalysisOptions](struct.AnalysisOptio...
code_fim
hard
{ "lang": "rust", "repo": "Technolution/rustig", "path": "/lib/panic_analysis/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let prc = Procedure { name: "some_name".to_string(), linkage_name: "a::b::name".to_string(), linkage_name_demangled: "a::b::name".to_string(), defining_crate: Crate { name: "crate".to_string(), version: None, ...
code_fim
hard
{ "lang": "rust", "repo": "Technolution/rustig", "path": "/lib/panic_analysis/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Technolution/rustig path: /lib/panic_analysis/src/lib.rs ttern.borrow(), if self.contains_dynamic_invocation { " -- Trace contains dynamic invocation(s)" } else { "" }, self.message ...
code_fim
hard
{ "lang": "rust", "repo": "Technolution/rustig", "path": "/lib/panic_analysis/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn test() { let mut codec = Codec::new(); let test_url = "https://leetcode.com/problems/design-tinyurl"; let tiny_url = codec.encode(test_url.to_string()); let resolve_url = codec.decode(tiny_url); assert_eq!(resolve_url, test_url); }<|fim_prefix|>// repo: kiraclf/leetCodePract...
code_fim
hard
{ "lang": "rust", "repo": "kiraclf/leetCodePractice", "path": "/rust_practice/src/encode_and_decode_tinyurl_535.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kiraclf/leetCodePractice path: /rust_practice/src/encode_and_decode_tinyurl_535.rs use std::collections::HashMap; #[allow(unused)] struct Codec { next_id: i32, map: HashMap<i32, String>, } impl Codec { #[allow(unused)] fn new() -> Self { <|fim_suffix|> #[allow(unused)] //...
code_fim
hard
{ "lang": "rust", "repo": "kiraclf/leetCodePractice", "path": "/rust_practice/src/encode_and_decode_tinyurl_535.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> loop { while player.activespells.contains_key(&spellidx) || (player.mana - chosen_spell.cost) < 0 { //spellidx = rand::thread_rng().gen_range(0..spell_prototypes.len()) as usize; spellidx = ...
code_fim
hard
{ "lang": "rust", "repo": "fhools/aoc2015", "path": "/day22/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fhools/aoc2015 path: /day22/src/main.rs use std::collections::HashMap; use rand::distributions::{Distribution, Uniform}; use rand::Rng; #[derive(Debug, Clone)] struct Spell { name: String, cost: i32, damage: i32, hp_heal: i32, mana_regen: i32, armor_buff: i32, duratio...
code_fim
hard
{ "lang": "rust", "repo": "fhools/aoc2015", "path": "/day22/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> player.hp = player.hp - (BOSS_DAMAGE - (player.armor)); } // println!("player hp: {} mp: {} boss_hp: {}\n\n", player.hp, player.mana, bosshp); player.turn = !player.turn; } // println!("Game ended. Player hp: {}, mp: {}, Boss...
code_fim
hard
{ "lang": "rust", "repo": "fhools/aoc2015", "path": "/day22/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(db.number_of_records(), 3); } #[test] fn validate_protected_number_of_records() { let db = read_test_data_block( TEST_FILE_PATH, DELIMITER, None, &[], &HashMap::default(), &[], 0, ); assert_eq!(db.protected_number_of_reco...
code_fim
hard
{ "lang": "rust", "repo": "microsoft/synthetic-data-showcase", "path": "/packages/core/tests/data_block/block.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: microsoft/synthetic-data-showcase path: /packages/core/tests/data_block/block.rs use sds_core::data_block::DataBlockValue; use std::{collections::HashMap, str::FromStr, sync::Arc}; use crate::utils::{assert_map_equals, read_test_data_block}; const DELIMITER: u8 = b','; const TEST_FILE_PATH: &...
code_fim
hard
{ "lang": "rust", "repo": "microsoft/synthetic-data-showcase", "path": "/packages/core/tests/data_block/block.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: andoriyu/material-design-icons-rs path: /src/materialiconssharp/maps/icon_directions_boat_filled.rs pub struct IconDirectionsBoatFilled { props: crate::Props, } impl yew::Component for IconDirectionsBoatFilled { type Properties = crate::Props; type Message = (); fn create(props: Se...
code_fim
medium
{ "lang": "rust", "repo": "andoriyu/material-design-icons-rs", "path": "/src/materialiconssharp/maps/icon_directions_boat_filled.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let future = AsyncMessageDialog::new() .set_title("About") .set_description(&about_string()) .set_buttons(MessageButtons::Ok) .show() .boxed(); self.future = Some(future); } } fn about_string() -> String { if cfg!(debug_...
code_fim
hard
{ "lang": "rust", "repo": "typon/smplinfo", "path": "/src/ui/about_dialog.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: typon/smplinfo path: /src/ui/about_dialog.rs use futures_lite::{future::Boxed, FutureExt}; use rfd::{AsyncMessageDialog, MessageButtons}; use crate::futures::poll_once_blocking; #[derive(Default)] pub struct AboutDialog { future: Option<Boxed<bool>>, } impl AboutDialog { pub fn is_act...
code_fim
medium
{ "lang": "rust", "repo": "typon/smplinfo", "path": "/src/ui/about_dialog.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if cfg!(debug_assertions) { format!( "{} {} (debug build)", env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION") ) } else { format!("{} {}", env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION")) } }<|fim_prefix|>// repo: typon/smplinfo pat...
code_fim
hard
{ "lang": "rust", "repo": "typon/smplinfo", "path": "/src/ui/about_dialog.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stm32-rs/stm32-rs-nightlies path: /stm32l5/src/stm32l562/sec_gtzc_mpcbb2/mpcbb2_vctr60.rs - B1925"] pub type B1925_W<'a, REG, const O: u8> = crate::BitWriter<'a, REG, O>; #[doc = "Field `B1926` reader - B1926"] pub type B1926_R = crate::BitReader; #[doc = "Field `B1926` writer - B1926"] pub typ...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32l5/src/stm32l562/sec_gtzc_mpcbb2/mpcbb2_vctr60.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> = "Bit 7 - B1927"] #[inline(always)] #[must_use] pub fn b1927(&mut self) -> B1927_W<MPCBB2_VCTR60_SPEC, 7> { B1927_W::new(self) } #[doc = "Bit 8 - B1928"] #[inline(always)] #[must_use] pub fn b1928(&mut self) -> B1928_W<MPCBB2_VCTR60_SPEC, 8> { B1928_W::new...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32l5/src/stm32l562/sec_gtzc_mpcbb2/mpcbb2_vctr60.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>w(self) } #[doc = "Bit 11 - B1931"] #[inline(always)] #[must_use] pub fn b1931(&mut self) -> B1931_W<MPCBB2_VCTR60_SPEC, 11> { B1931_W::new(self) } #[doc = "Bit 12 - B1932"] #[inline(always)] #[must_use] pub fn b1932(&mut self) -> B1932_W<MPCBB2_VCTR60_SPEC,...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32l5/src/stm32l562/sec_gtzc_mpcbb2/mpcbb2_vctr60.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> window::set_view(ctx, &view); graphics::draw(ctx, &self.animation); Ok(()) } } fn main() -> Result<()> { ContextBuilder::new( "crafty-shmup-rs", (WINDOW_WIDTH * WINDOW_SCALE) as u32, (WINDOW_HEIGHT * WINDOW_SCALE) as u32, ) .build()? ....
code_fim
hard
{ "lang": "rust", "repo": "hxhieu/crafty-shmup-rs", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hxhieu/crafty-shmup-rs path: /src/main.rs use peacock::graphics::{self, Animation, Image, Rectangle, View}; use peacock::scenegraph::SceneObject; use peacock::window; use peacock::{Context, ContextBuilder, Result, State}; // TODO: Constant class const WINDOW_SCALE: f32 = 4.0; // TODO: Configura...
code_fim
hard
{ "lang": "rust", "repo": "hxhieu/crafty-shmup-rs", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[macro_use] pub mod io; mod log; mod runtime; pub mod sbi; pub use opensbi_rt_macros::entry;<|fim_prefix|>// repo: luojia65/opensbi-rt path: /src/lib.rs //! A mininal runtime / startup for OpenSBI on RISC-V. #![no_std] #![feature(llvm_asm, global_asm)] #![feature(alloc_error_handler)] #![deny(warnings...
code_fim
easy
{ "lang": "rust", "repo": "luojia65/opensbi-rt", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: luojia65/opensbi-rt path: /src/lib.rs //! A mininal runtime / startup for OpenSBI on RISC-V. <|fim_suffix|>pub use opensbi_rt_macros::entry;<|fim_middle|>#![no_std] #![feature(llvm_asm, global_asm)] #![feature(alloc_error_handler)] #![deny(warnings, missing_docs)] extern crate alloc; #[macro_...
code_fim
medium
{ "lang": "rust", "repo": "luojia65/opensbi-rt", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: thegedge/fittle path: /src/profile/enums/wkt_step_duration.rs use crate::fields::FieldContent; use serde::Serialize; #[derive(Clone, Copy, Debug, Serialize)] #[serde(rename_all = "snake_case")] pub enum WktStepDuration { Calories, Distance, HrGreaterThan, HrLessThan, Open, ...
code_fim
hard
{ "lang": "rust", "repo": "thegedge/fittle", "path": "/src/profile/enums/wkt_step_duration.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: samcday/m451 path: /pac/src/dac/dac_datout.rs #[doc = "Register `DAC_DATOUT` reader"] pub struct R(crate::R<DAC_DATOUT_SPEC>); impl core::ops::Deref for R { type Target = crate::R<DAC_DATOUT_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Target { <|fim_suffix|> &self.0 ...
code_fim
hard
{ "lang": "rust", "repo": "samcday/m451", "path": "/pac/src/dac/dac_datout.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> R(reader) } } #[doc = "Field `DATOUT` reader - DAC 12-bit Output Data\\nThese bits are current digital data for DAC output conversion.\\nIt is loaded from DAC_DAT register and user cannot write it directly."] pub struct DATOUT_R(crate::FieldReader<u16, u16>); impl DATOUT_R { pub(crate) fn ...
code_fim
medium
{ "lang": "rust", "repo": "samcday/m451", "path": "/pac/src/dac/dac_datout.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: forkachild/androgen path: /src/main.rs mod app_info; mod config; mod input; use std::{env, path::{Path, PathBuf}, fs}; use std::io::{ErrorKind}; use app_info::AppInfo; use config::{ TEMPLATE_DIR_STRUCTURE, TEMPLATE_PACKAGE, TEMPLATE_PROJECT_NAME, TEMPLATES_DIR, GENERATED_DIR...
code_fim
hard
{ "lang": "rust", "repo": "forkachild/androgen", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let current_dir = env::current_dir().expect("Current dir not found"); let dir = current_dir.join(GENERATED_DIR).join(name); if !dir.exists() || !dir.is_dir() { fs::create_dir_all(&dir).expect("Failed to create output directory"); } dir } fn get_all_files(path: &Path) -> Vec<...
code_fim
hard
{ "lang": "rust", "repo": "forkachild/androgen", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn get_dest_dir(name: &str) -> PathBuf { let current_dir = env::current_dir().expect("Current dir not found"); let dir = current_dir.join(GENERATED_DIR).join(name); if !dir.exists() || !dir.is_dir() { fs::create_dir_all(&dir).expect("Failed to create output directory"); } dir...
code_fim
hard
{ "lang": "rust", "repo": "forkachild/androgen", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> pub fn new_double_ary(len: usize) -> Oop { let mut elms = Vec::with_capacity(len); elms.resize(len, 0.0); Self::new_double_ary2(elms) } pub fn new_long_ary(len: usize) -> Oop { let mut elms = Vec::with_capacity(len); elms.resize(len, 0); Self::n...
code_fim
hard
{ "lang": "rust", "repo": "fujinjun/jvm", "path": "/crates/vm/src/oop/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Self::new_ref(RefKind::Mirror(v)) } pub fn new_prim_mirror(value_type: ValueType, target: Option<ClassRef>) -> Oop { let java_lang_class = require_class3(None, b"java/lang/Class").unwrap(); let field_values = field::build_inited_field_values(java_lang_class); let v...
code_fim
hard
{ "lang": "rust", "repo": "fujinjun/jvm", "path": "/crates/vm/src/oop/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fujinjun/jvm path: /crates/vm/src/oop/mod.rs #![allow(unused)] use classfile::{BytesRef, ClassFile}; use std::fmt; use std::sync::{Arc, Condvar, Mutex, RwLock}; use crate::runtime::{require_class3, ClassLoader}; use crate::types::*; pub mod ary; pub mod class; pub mod consts; pub mod field; pu...
code_fim
hard
{ "lang": "rust", "repo": "fujinjun/jvm", "path": "/crates/vm/src/oop/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>mod basic; mod original;<|fim_prefix|>// repo: kaj/rsass path: /rsass/tests/spec/libsass_closed_issues/issue_2295/mod.rs //! Tests auto-converted from "sass-spec/spec/libsass-closed-issues/issue_2295" #[allow(unused)] fn runner() -> crate::TestRunner { <|fim_middle|> super::runner().with_cwd("issue_...
code_fim
easy
{ "lang": "rust", "repo": "kaj/rsass", "path": "/rsass/tests/spec/libsass_closed_issues/issue_2295/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kaj/rsass path: /rsass/tests/spec/libsass_closed_issues/issue_2295/mod.rs //! Tests auto-converted from "sass-spec/spec/libsass-closed-issues/issue_2295" <|fim_suffix|>mod basic; mod original;<|fim_middle|>#[allow(unused)] fn runner() -> crate::TestRunner { super::runner().with_cwd("issue_...
code_fim
medium
{ "lang": "rust", "repo": "kaj/rsass", "path": "/rsass/tests/spec/libsass_closed_issues/issue_2295/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> (10..max) .filter(|&x| { get_digits(x) .iter() .map(|&y| factorials[y as usize]) .sum::<u32>() == x }) .sum() }<|fim_prefix|>// repo: clementlee/euler-rs path: /src/problems/p34.rs use crate::lib::get_...
code_fim
medium
{ "lang": "rust", "repo": "clementlee/euler-rs", "path": "/src/problems/p34.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: clementlee/euler-rs path: /src/problems/p34.rs use crate::lib::get_digits; pub fn solution() -> u32 { let factorials: Vec<u32> = (0..=9).map(|x| (1..=x).product()).collect(); <|fim_suffix|> (10..max) .filter(|&x| { get_digits(x) .iter() ...
code_fim
medium
{ "lang": "rust", "repo": "clementlee/euler-rs", "path": "/src/problems/p34.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Sauci/ccgen path: /src/hwsiggen.rs use super::crkcam::cmn::{Edge, Event}; use super::crkcam::{self, cam::*, crk::*}; use super::periph; const CRK_CAM_AUTORELOAD: u32 = 0xFFFF; const NR_OF_DEG_TICKS: u32 = 3_600; const TIM_MIN_FROM_S: u32 = 60; use stm32f1::stm32f103::interrupt; fn wrapping_ad...
code_fim
hard
{ "lang": "rust", "repo": "Sauci/ccgen", "path": "/src/hwsiggen.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Check if this is really an event on the cam channel and clear it // otherwise, return without doing anything if tim.sr.read().cc2if().bit_is_clear() { return; } else { // Get event from the cam list self.cam_ev = self.cam.as_mut().unwr...
code_fim
hard
{ "lang": "rust", "repo": "Sauci/ccgen", "path": "/src/hwsiggen.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rustwasm/wasm-bindgen path: /crates/web-sys/src/features/gen_EffectTiming.rs #![allow(unused_imports)] #![allow(clippy::all)] use super::*; use wasm_bindgen::prelude::*; #[wasm_bindgen] extern "C" { # [wasm_bindgen (extends = :: js_sys :: Object , js_name = EffectTiming)] #[derive(Debug,...
code_fim
hard
{ "lang": "rust", "repo": "rustwasm/wasm-bindgen", "path": "/crates/web-sys/src/features/gen_EffectTiming.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>ing properties should never fail on our dictionary objects" ); let _ = r; self } #[doc = "Change the `iterationStart` field of this object."] #[doc = ""] #[doc = "*This API requires the following crate features to be activated: `EffectTiming`*"] pub fn iteration...
code_fim
hard
{ "lang": "rust", "repo": "rustwasm/wasm-bindgen", "path": "/crates/web-sys/src/features/gen_EffectTiming.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }