text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: stm32-rs/stm32-rs-nightlies path: /stm32h7/src/stm32h747cm4/syscfg/ur9.rs #[doc = "Register `UR9` reader"] pub type R = crate::R<UR9_SPEC>; #[doc = "Field `WRPS_2` reader - Write protection for flash bank 2"] pub type WRPS_2_R = crate::FieldReader; #[doc = "Field `PA_BEG_2` reader - Protected ar...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32h7/src/stm32h747cm4/syscfg/ur9.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl Evaluator { pub fn new() -> Evaluator { Evaluator { builtins: builtins::create_builtins(), } } pub fn execute(&self, input: &str) -> io::Result<()> { let args = conv(split_line(input)); if args.len() < 1 { return Err(Error::new(Erro...
code_fim
hard
{ "lang": "rust", "repo": "none-toka/rust-exercise", "path": "/xiao3sh/src/eval/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub struct Evaluator { builtins: HashMap<String, fn(&[String]) -> io::Result<()>>, } impl Evaluator { pub fn new() -> Evaluator { Evaluator { builtins: builtins::create_builtins(), } } pub fn execute(&self, input: &str) -> io::Result<()> { let args = c...
code_fim
hard
{ "lang": "rust", "repo": "none-toka/rust-exercise", "path": "/xiao3sh/src/eval/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: none-toka/rust-exercise path: /xiao3sh/src/eval/mod.rs use std::collections::HashMap; use std::io::{self, Error, ErrorKind}; use std::process::Command; mod builtins; fn split_line(line: &str) -> impl Iterator<Item = &str> { line.trim().split_whitespace() } <|fim_suffix|> pub fn execute...
code_fim
hard
{ "lang": "rust", "repo": "none-toka/rust-exercise", "path": "/xiao3sh/src/eval/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sodiumoxide/sodiumoxide path: /libsodium-sys/tests/crypto/crypto_stream_salsa20.rs // crypto_stream_salsa20.h use libsodium_sys::*; #[test] fn test_crypto_stream_salsa20_keybytes() { <|fim_suffix|>#[test] fn test_crypto_stream_salsa20_noncebytes() { assert!( unsafe { crypto_stream_...
code_fim
medium
{ "lang": "rust", "repo": "sodiumoxide/sodiumoxide", "path": "/libsodium-sys/tests/crypto/crypto_stream_salsa20.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> assert!(unsafe { crypto_stream_salsa20_keybytes() } == crypto_stream_salsa20_KEYBYTES as usize) } #[test] fn test_crypto_stream_salsa20_noncebytes() { assert!( unsafe { crypto_stream_salsa20_noncebytes() } == crypto_stream_salsa20_NONCEBYTES as usize ) }<|fim_prefix|>// repo: sodiumox...
code_fim
easy
{ "lang": "rust", "repo": "sodiumoxide/sodiumoxide", "path": "/libsodium-sys/tests/crypto/crypto_stream_salsa20.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn test_crypto_stream_salsa20_noncebytes() { assert!( unsafe { crypto_stream_salsa20_noncebytes() } == crypto_stream_salsa20_NONCEBYTES as usize ) }<|fim_prefix|>// repo: sodiumoxide/sodiumoxide path: /libsodium-sys/tests/crypto/crypto_stream_salsa20.rs // crypto_stream_salsa20.h ...
code_fim
medium
{ "lang": "rust", "repo": "sodiumoxide/sodiumoxide", "path": "/libsodium-sys/tests/crypto/crypto_stream_salsa20.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>fn poll_future<T>(cx: &mut Context<'_>, fut: impl Future<Output = T>) -> Poll<T> { pin!(fut).poll(cx) } pub(crate) struct Timer { deadline: Instant, key: usize, waker: Option<Waker>, } impl Timer { pub fn new(deadline: Instant) -> Timer { Timer { deadline, ...
code_fim
hard
{ "lang": "rust", "repo": "cssivision/awak", "path": "/src/io/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cssivision/awak path: /src/io/mod.rs mod poller; pub mod reactor; use std::future::Future; use std::io::{self, Read, Write}; use std::os::unix::io::AsRawFd; use std::pin::{pin, Pin}; use std::sync::Arc; use std::task::{ready, Context, Poll, Waker}; use std::time::Instant; use futures_io::{Asyn...
code_fim
hard
{ "lang": "rust", "repo": "cssivision/awak", "path": "/src/io/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Set state to GameOver if player health is less than 1 players.iter(ecs).for_each(|(health, pos)| { if health.current < 1 { new_state = TurnState::GameOver; } if amulet_pos == pos { new_state = TurnState::Victory; } if map.tiles[m...
code_fim
medium
{ "lang": "rust", "repo": "zenoplex/rust_dungeon_crawl", "path": "/src/systems/end_turn.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zenoplex/rust_dungeon_crawl path: /src/systems/end_turn.rs use crate::prelude::*; #[system] #[read_component(Health)] #[read_component(Player)] #[read_component(Point)] #[read_component(AmuletOfYala)] pub fn end_turn(ecs: &SubWorld, #[resource] turn_state: &mut TurnState, #[resource] map: &Map)...
code_fim
hard
{ "lang": "rust", "repo": "zenoplex/rust_dungeon_crawl", "path": "/src/systems/end_turn.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: prangel-git/tictactoe path: /src/lib.rs /// Actions will be a number from 0 to 8 representing a position in the tic tac toe board pub type Action = u8; <|fim_suffix|>pub use gts::abstractions::*; pub use gts::agents::*; pub use gts::tree_search::*;<|fim_middle|>mod agentid; pub use agentid::Age...
code_fim
medium
{ "lang": "rust", "repo": "prangel-git/tictactoe", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub use gts::abstractions::*; pub use gts::agents::*; pub use gts::tree_search::*;<|fim_prefix|>// repo: prangel-git/tictactoe path: /src/lib.rs /// Actions will be a number from 0 to 8 representing a position in the tic tac toe board pub type Action = u8; mod agentid; pub use agentid::AgentId; <|fim_m...
code_fim
easy
{ "lang": "rust", "repo": "prangel-git/tictactoe", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: probe-rs/probe-rs path: /target-gen/tests/extract_pack.rs use assert_cmd::Command; const NORDIC_SAMPLE_PACK: &str = "tests/test_data/NordicSemiconductor.nRF_DeviceFamilyPack.8.32.1.pack"; #[test] fn missing_output_directory() { let mut cmd = Command::cargo_bin("target-gen").unwrap(); ...
code_fim
medium
{ "lang": "rust", "repo": "probe-rs/probe-rs", "path": "/target-gen/tests/extract_pack.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // extract an example pack cmd.arg("pack").arg(NORDIC_SAMPLE_PACK); cmd.assert().failure().stderr(predicates::str::contains( "the following required arguments were not provided:", )); } #[test] fn extract_target_specs() { // create a temporary directory let temp = assert_...
code_fim
medium
{ "lang": "rust", "repo": "probe-rs/probe-rs", "path": "/target-gen/tests/extract_pack.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/factory/factory_store_providers/src/main.rs r(MiscFactoryStoreProviderRequestStream), PlayReadyFactoryStoreProvider(PlayReadyFactoryStoreProviderRequestStream), WeaveFactoryStoreProvider(WeaveFactoryStoreProviderRequestStream), WidevineFactoryStoreProvider...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/factory/factory_store_providers/src/main.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> let mut fs = ServiceFs::new(); fs.dir("svc") .add_fidl_service(IncomingServices::AlphaFactoryStoreProvider) .add_fidl_service(IncomingServices::CastCredentialsFactoryStoreProvider) .add_fidl_service(IncomingServices::MiscFactoryStoreProvider) .add_fidl_service(Incom...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/factory/factory_store_providers/src/main.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/factory/factory_store_providers/src/main.rs V_CLASS_BLOCK: &str = "/dev/class/block"; let dir = fuchsia_fs::directory::open_in_namespace(DEV_CLASS_BLOCK, fio::OpenFlags::RIGHT_READABLE)?; device_watcher::wait_for_device_with( &dir, |de...
code_fim
hard
{ "lang": "rust", "repo": "gnoliyil/fuchsia", "path": "/src/factory/factory_store_providers/src/main.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: magj2006/Essential-Rust path: /robot-simulator/src/lib.rs // The code below is a stub. Just enough to satisfy the compiler. // In order to pass the tests you can add-to or change any of this code. #[derive(PartialEq, Debug)] pub enum Direction { North, East, South, West, } #[de...
code_fim
hard
{ "lang": "rust", "repo": "magj2006/Essential-Rust", "path": "/robot-simulator/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub fn turn_right(self) -> Self { match self.direction { Direction::North => Self { direction: Direction::East, ..self }, Direction::East => Self { direction: Direction::South, ..self ...
code_fim
hard
{ "lang": "rust", "repo": "magj2006/Essential-Rust", "path": "/robot-simulator/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MingweiSamuel/spinach path: /lib/src/lattice/ord.rs use super::*; pub struct Max<T: Ord> { _phantom: std::marker::PhantomData<T>, } impl<T: Ord> Lattice for Max<T> {} pub struct MaxRepr<T: Ord> { _phantom: std::marker::PhantomData<T>, } impl<T: Ord + Clone> LatticeRepr for MaxRepr<T> ...
code_fim
hard
{ "lang": "rust", "repo": "MingweiSamuel/spinach", "path": "/lib/src/lattice/ord.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> this } } // TODO: use num traits for all variants of this. impl Top for MaxRepr<u64> { fn is_top(this: &Self::Repr) -> bool { &u64::MAX == this } fn top() -> Self::Repr { u64::MAX } }<|fim_prefix|>// repo: MingweiSamuel/spinach path: /lib/src/lattice/ord.rs ...
code_fim
hard
{ "lang": "rust", "repo": "MingweiSamuel/spinach", "path": "/lib/src/lattice/ord.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cryptonemo/bellman path: /src/util_cs/mod.rs use crate::LinearCombination; use ff::PrimeField; pub mod bench_cs; pub mod metric_cs; pub mod test_cs; pub type Constraint<Scalar> = ( LinearCombination<Scalar>, LinearCombination<Scalar>, LinearCombination<Scalar>, String, ); pub ...
code_fim
hard
{ "lang": "rust", "repo": "cryptonemo/bellman", "path": "/src/util_cs/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Delta::ConstraintMismatch(m.0, m.1.clone(), m.2.clone()) } else if equal { Delta::Equal } else { Delta::Different } } } #[allow(clippy::large_enum_variant)] #[derive(Clone, Debug, PartialEq)] pub enum Delta<Scalar: PrimeField> { Equal, ...
code_fim
hard
{ "lang": "rust", "repo": "cryptonemo/bellman", "path": "/src/util_cs/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub fn set_global( operands: &[Operand], stack: &mut ValueStack, globals: &Globals, ) -> Result<(), RuntimeError> { let index: usize = operands[0].into(); let v = pop(stack)?; let value = globals .get(index) .ok_or(RuntimeError::UndefinedGlobalError)?; let mut g...
code_fim
hard
{ "lang": "rust", "repo": "bokuweb/yaw", "path": "/src/vm/instructions/variables.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn get_global( operands: &[Operand], stack: &mut ValueStack, globals: &Globals, ) -> Result<(), RuntimeError> { let index: usize = operands[0].into(); let value = globals .get(index) .ok_or(RuntimeError::UndefinedGlobalError)?; let value = value.borrow(); st...
code_fim
hard
{ "lang": "rust", "repo": "bokuweb/yaw", "path": "/src/vm/instructions/variables.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bokuweb/yaw path: /src/vm/instructions/variables.rs use crate::types::*; use crate::vm::{Globals, RuntimeError}; use super::super::value_stack::ValueStack; use super::pop; pub fn get_local( operands: &[Operand], stack: &mut ValueStack, locals: &[RuntimeValue], ) -> Result<(), Runti...
code_fim
hard
{ "lang": "rust", "repo": "bokuweb/yaw", "path": "/src/vm/instructions/variables.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: samsartor/infloop path: /src/main.rs #[macro_use] extern crate arrayref; extern crate num; <|fim_suffix|> println!("{:?}", CellType::Peg.solve_sides(&[Some(false), None, Some(false), Some(false)])); }<|fim_middle|>mod castutils; mod solver; use solver::CellType; fn main() {
code_fim
medium
{ "lang": "rust", "repo": "samsartor/infloop", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn main() { println!("{:?}", CellType::Peg.solve_sides(&[Some(false), None, Some(false), Some(false)])); }<|fim_prefix|>// repo: samsartor/infloop path: /src/main.rs #[macro_use] extern crate arrayref; extern crate num; <|fim_middle|>mod castutils; mod solver; use solver::CellType;
code_fim
easy
{ "lang": "rust", "repo": "samsartor/infloop", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[repr(C)] pub struct nsIInterfaceInfoManagerVTable { pub __base: nsISupportsVTable, /* nsIInterfaceInfo getInfoForIID (in nsIIDPtr iid); */ pub getInfoForIID: unsafe extern "C" fn (this: *const nsIInterfaceInfoManager, iid: *const nsIID, _retval: *mut *const nsIInterfaceInfo) -> nsresult, ...
code_fim
hard
{ "lang": "rust", "repo": "mystor/dist-xprs-example", "path": "/rt/nsIInterfaceInfoManager.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: mystor/dist-xprs-example path: /rt/nsIInterfaceInfoManager.rs // // DO NOT EDIT. THIS FILE IS GENERATED FROM ../../../dist/idl/nsIInterfaceInfoManager.idl // #[repr(C)] pub struct nsIInterfaceInfoManager { vtable: *const nsIInterfaceInfoManagerVTable, /// This field is a phantomdata ...
code_fim
hard
{ "lang": "rust", "repo": "mystor/dist-xprs-example", "path": "/rt/nsIInterfaceInfoManager.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /* nsIInterfaceInfo getInfoForName (in string name); */ pub getInfoForName: unsafe extern "C" fn (this: *const nsIInterfaceInfoManager, name: *const libc::c_char, _retval: *mut *const nsIInterfaceInfo) -> nsresult, } impl nsIInterfaceInfoManager { /* nsIInterfaceInfo getInfoForIID (in nsIID...
code_fim
hard
{ "lang": "rust", "repo": "mystor/dist-xprs-example", "path": "/rt/nsIInterfaceInfoManager.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> dbg!("after writing with offset 4"); flash.write_u32(WHERE + 4, 0x1234_5678).unwrap(); hprintln!("{:#034x}", flash.read_u128(0x4_0000)).ok(); hprintln!("{:#034x}", flash.read_u128(0x4_0010)).ok(); hprintln!("{:#034x}", flash.read_u128(0x4_0020)).ok(); let mut read_buf = [0u8; 16...
code_fim
hard
{ "lang": "rust", "repo": "nickray/lpc55-hal", "path": "/examples/flash.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nickray/lpc55-hal path: /examples/flash.rs #![no_main] #![no_std] extern crate panic_semihosting; use cortex_m_rt::entry; use cortex_m_semihosting::{dbg, hprintln}; use lpc55_hal as hal; use hal::prelude::*; #[repr(C)] #[allow(dead_code)] enum FlashCommands { Init = 0x0, PowerDown = 0...
code_fim
hard
{ "lang": "rust", "repo": "nickray/lpc55-hal", "path": "/examples/flash.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let data: [u8; 4] = [0x7, 0x2, 0x3, 0x4]; let mut buf = [0u8; 512]; buf[..4].copy_from_slice(&data); flash.write_native(WHERE, &generic_array::GenericArray::from_slice(&buf)).unwrap(); buf[0] = 37; // // buf[3] = 37; flash.write_native(WHERE, &generic_array::GenericArray::from...
code_fim
hard
{ "lang": "rust", "repo": "nickray/lpc55-hal", "path": "/examples/flash.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tuxxi/OS-Project path: /src/os/os.rs use crate::os::allocator::Allocator; use crate::os::dispatcher::Dispatcher; use crate::os::memory::MemoryRange; use crate::os::process::{ProcessControlBlock, PID}; use crate::records::{OSParams, ProcessData}; use itertools::sorted; use std::collections::{Has...
code_fim
hard
{ "lang": "rust", "repo": "tuxxi/OS-Project", "path": "/src/os/os.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // check if simulation is finished if self.running_processes.is_empty() && self.input_queue.is_empty() { println!( "OS simulation finished at clock time {}.", self.master_clock ); break; ...
code_fim
hard
{ "lang": "rust", "repo": "tuxxi/OS-Project", "path": "/src/os/os.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let every_n = self.input_params.every_n_units; let mut dispatcher = Dispatcher::new(); loop { // increment the master clock self.master_clock += 1; //check if we exceeded the clock limit if self.master_clock > self.clock_limit { ...
code_fim
hard
{ "lang": "rust", "repo": "tuxxi/OS-Project", "path": "/src/os/os.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: KyussCaesar/dataframes1 path: /src/mutate/mod.rs //! `mutate` use rayon::prelude::*; <|fim_suffix|>impl<R: Record> DataFrame<R> { /// Create or alter columns using `Mutation`. pub fn mutate<M: Mutation<R>>(&self, mutation: M) -> DataFrame<R> { self.transform(|mut r| { mutat...
code_fim
easy
{ "lang": "rust", "repo": "KyussCaesar/dataframes1", "path": "/src/mutate/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl<R: Record> DataFrame<R> { /// Create or alter columns using `Mutation`. pub fn mutate<M: Mutation<R>>(&self, mutation: M) -> DataFrame<R> { self.transform(|mut r| { mutation(&mut r); r }) } }<|fim_prefix|>// repo: KyussCaesar/dataframes1 path: /src/mutate/mod.rs //! `mutate` ...
code_fim
easy
{ "lang": "rust", "repo": "KyussCaesar/dataframes1", "path": "/src/mutate/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: frankhart2018/rust-learn path: /ch-18-patterns-and-matching/destructuring/src/main.rs struct Point { x: i32, y: i32, } #[allow(unused)] enum Message { Quit, Move { x: i32, y: i32 }, Write(String), ChangeColor(i32, i32, i32), } #[allow(unused)] enum Color { Rgb(i32, ...
code_fim
hard
{ "lang": "rust", "repo": "frankhart2018/rust-learn", "path": "/ch-18-patterns-and-matching/destructuring/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let msg = Message::ChangeColor(0, 160, 255); match msg { Message::Quit => { println!("The Quit variant has no data to destructure."); } Message::Move { x, y} => { println!("Move in the x direction {} and in the y direction {}", x, y); } ...
code_fim
hard
{ "lang": "rust", "repo": "frankhart2018/rust-learn", "path": "/ch-18-patterns-and-matching/destructuring/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Destructuring structures with literal values let p = Point { x: 0, y: 7 }; match p { Point { x , y: 0 } => println!("On the x axis at {}", x), Point { x: 0, y } => println!("On the y axis at {}", y), Point { x, y } => println!("On neither axis: ({}, {})", x, y) ...
code_fim
hard
{ "lang": "rust", "repo": "frankhart2018/rust-learn", "path": "/ch-18-patterns-and-matching/destructuring/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Get the exponent let mask = (1 << EXPONENT_BITS) - 1; let mask = mask << MANTISSA_BITS; let exponent = v & mask; if exponent == 0 { // Offset the exponent properly let exponent = $float::MIN_EXP as $int; // Save the sign bit ...
code_fim
hard
{ "lang": "rust", "repo": "Popog/beagle-rs", "path": "/src/num.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Popog/beagle-rs path: /src/num.rs e of `self` constrained to the range [`min_val`, `max_val`] /// The returned value is computed as min(max(self, `min_val`), `mal_val`). fn clamp(self, min: Rhs, max: Rhs) -> Self::Output; } /// Types that implement exponential functions pub trait Exp { ...
code_fim
hard
{ "lang": "rust", "repo": "Popog/beagle-rs", "path": "/src/num.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Popog/beagle-rs path: /src/num.rs `true` if this number is neither infinite nor `NaN`. fn is_finite(self) -> Self::Bool; /// Returns `true` if the number is neither zero, infinite, /// [subnormal][subnormal], or `NaN`. fn is_normal(self) -> Self::Bool; /// Returns the floati...
code_fim
hard
{ "lang": "rust", "repo": "Popog/beagle-rs", "path": "/src/num.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: poma/clap path: /tests/opts.rs mod utils; use clap::{App, Arg, ArgMatches, ArgSettings, ErrorKind}; #[cfg(feature = "suggestions")] static DYM: &str = "error: Found argument '--optio' which wasn't expected, or isn't valid in this context \tDid you mean --option? If you tried to supply `--o...
code_fim
hard
{ "lang": "rust", "repo": "poma/clap", "path": "/tests/opts.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn leading_hyphen_pass() { let r = App::new("mvae") .arg(Arg::from("-o [opt]... 'some opt'").setting(ArgSettings::AllowHyphenValues)) .try_get_matches_from(vec!["", "-o", "-2", "3"]); assert!(r.is_ok()); let m = r.unwrap(); assert!(m.is_present("o")); assert_eq!...
code_fim
hard
{ "lang": "rust", "repo": "poma/clap", "path": "/tests/opts.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if let Some(ref w) = statement.predicate { f.write_char(' ')?; f.write_str("where")?; f.write_char(' ')?; self.visit_predicate(w, f)?; } if let Some(ref g) = statement.group { f.write_char(...
code_fim
hard
{ "lang": "rust", "repo": "cch123/n-sql", "path": "/src/generator/oracle.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if let Some(ref g) = statement.group { f.write_char(' ')?; f.write_str("group")?; f.write_char(' ')?; f.write_str("by")?; f.write_char(' ')?; self.visit_expressions(&g.elements, f)?; ...
code_fim
hard
{ "lang": "rust", "repo": "cch123/n-sql", "path": "/src/generator/oracle.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cch123/n-sql path: /src/generator/oracle.rs // Copyright 2019 The n-sql Project Developers. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your //...
code_fim
hard
{ "lang": "rust", "repo": "cch123/n-sql", "path": "/src/generator/oracle.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: stm32-rs/stm32-rs-nightlies path: /stm32f4/src/stm32f411/otg_fs_host/hc/intmsk.rs #[doc = "Register `INTMSK` reader"] pub type R = crate::R<INTMSK_SPEC>; #[doc = "Register `INTMSK` writer"] pub type W = crate::W<INTMSK_SPEC>; #[doc = "Field `XFRCM` reader - Transfer completed mask"] pub type XFR...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32f4/src/stm32f411/otg_fs_host/hc/intmsk.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn txerrm(&self) -> TXERRM_R { TXERRM_R::new(((self.bits >> 7) & 1) != 0) } #[doc = "Bit 8 - Babble error mask"] #[inline(always)] pub fn bberrm(&self) -> BBERRM_R { BBERRM_R::new(((self.bits >> 8) & 1) != 0) } #[doc = "Bit 9 - Frame overrun mask"] #[inline(alw...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32f4/src/stm32f411/otg_fs_host/hc/intmsk.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>ut self) -> TXERRM_W<INTMSK_SPEC, 7> { TXERRM_W::new(self) } #[doc = "Bit 8 - Babble error mask"] #[inline(always)] #[must_use] pub fn bberrm(&mut self) -> BBERRM_W<INTMSK_SPEC, 8> { BBERRM_W::new(self) } #[doc = "Bit 9 - Frame overrun mask"] #[inline(always...
code_fim
hard
{ "lang": "rust", "repo": "stm32-rs/stm32-rs-nightlies", "path": "/stm32f4/src/stm32f411/otg_fs_host/hc/intmsk.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let atik = s.chars().nth(i + k).unwrap(); if (atjk > atik) { i = j; break; } else if (atjk < atik) { break; } k += 1; } ...
code_fim
hard
{ "lang": "rust", "repo": "pourplusquoi/learn-rust", "path": "/leetcode/1163.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> break; } k += 1; } j += k - 1; } j += 1; } String::from(&s[i..]) } }<|fim_prefix|>// repo: pourplusquoi/learn-rust path: /leetcode/1163.rs impl Solution { pub fn last_s...
code_fim
hard
{ "lang": "rust", "repo": "pourplusquoi/learn-rust", "path": "/leetcode/1163.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pourplusquoi/learn-rust path: /leetcode/1163.rs impl Solution { pub fn last_substring(s: String) -> String { let mut i = 0; let mut j = 1; while let Some(atj) = s.chars().nth(j) { let ati = s.chars().nth(i).un<|fim_suffix|> break; ...
code_fim
hard
{ "lang": "rust", "repo": "pourplusquoi/learn-rust", "path": "/leetcode/1163.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let l = stdin.lock().lines().next().unwrap().unwrap(); let n = i32::from_str(&l).unwrap(); let a = ans(n); println!("{}",a); }<|fim_prefix|>// repo: a143753/AOJ path: /0007.rs use std::io::prelude::*; use std::str::FromStr; fn ans(n:i32) -> i32 { <|fim_middle|> let mut s...
code_fim
medium
{ "lang": "rust", "repo": "a143753/AOJ", "path": "/0007.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: a143753/AOJ path: /0007.rs use std::io::prelude::*; use std::str::FromStr; <|fim_suffix|> let mut s:f64 = 100000.0; for _ in 0..n { s = (s * 1.05 / 1000.0).ceil() * 1000.0; } s as i32 } fn main() { let stdin = std::io::stdin(); let l = stdin.lock(...
code_fim
easy
{ "lang": "rust", "repo": "a143753/AOJ", "path": "/0007.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let stdin = std::io::stdin(); let l = stdin.lock().lines().next().unwrap().unwrap(); let n = i32::from_str(&l).unwrap(); let a = ans(n); println!("{}",a); }<|fim_prefix|>// repo: a143753/AOJ path: /0007.rs use std::io::prelude::*; use std::str::FromStr; fn ans(n:i32) ...
code_fim
medium
{ "lang": "rust", "repo": "a143753/AOJ", "path": "/0007.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: babydragon/iot_center path: /src/main.rs extern crate rusqlite; extern crate rumqtt; extern crate serde; extern crate serde_json; #[macro_use] extern crate serde_derive; extern crate chan_signal; #[macro_use] extern crate log; extern crate log4rs; extern crate toml; mod config; mod storage; mo...
code_fim
medium
{ "lang": "rust", "repo": "babydragon/iot_center", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> sink.save(&iot_message); }); info!("finish to init mqtt"); let signal = chan_signal::notify(&[Signal::INT, Signal::TERM]); signal.recv().unwrap(); }<|fim_prefix|>// repo: babydragon/iot_center path: /src/main.rs extern crate rusqlite; extern crate rumqtt; extern crate serde; ex...
code_fim
hard
{ "lang": "rust", "repo": "babydragon/iot_center", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: benjamingb/rust-gql path: /src/graphql_schema.rs use crate::todo::*; use async_graphql::{Context, FieldResult}; use sqlx::postgres::PgPool; <|fim_suffix|>pub struct MutationRoot; #[async_graphql::Object] impl MutationRoot {}<|fim_middle|>#[async_graphql::Object] impl Todo { async fn id(&s...
code_fim
hard
{ "lang": "rust", "repo": "benjamingb/rust-gql", "path": "/src/graphql_schema.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[async_graphql::Object] impl QueryRoot { async fn todos(&self, ctx: &Context<'_>) -> FieldResult<Vec<Todo>> { let pool = ctx.data::<PgPool>()?; let items = Todo::list(pool).await?; Ok(items) } } pub struct MutationRoot; #[async_graphql::Object] impl MutationRoot {}<|fim_...
code_fim
medium
{ "lang": "rust", "repo": "benjamingb/rust-gql", "path": "/src/graphql_schema.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn parse_value<'a>(scratch: &'a mut Vec<u8>, val: &[u8]) -> PolarsResult<BorrowedValue<'a>> { scratch.clear(); scratch.extend_from_slice(val); // 0 because it is row by row simd_json::to_borrowed_value(scratch) .map_err(|e| PolarsError::ComputeError(format!("{e}").into())) } /// I...
code_fim
hard
{ "lang": "rust", "repo": "pola-rs/polars", "path": "/crates/polars-json/src/ndjson/file.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> self.number_of_rows = read_rows(&mut self.reader, &mut self.rows, self.remaining)?; self.remaining -= self.number_of_rows; Ok(()) } fn get(&self) -> Option<&Self::Item> { if self.number_of_rows > 0 { Some(&self.rows[..self.number_of_rows]) } els...
code_fim
hard
{ "lang": "rust", "repo": "pola-rs/polars", "path": "/crates/polars-json/src/ndjson/file.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: pola-rs/polars path: /crates/polars-json/src/ndjson/file.rs use std::io::BufRead; use arrow::datatypes::DataType; use fallible_streaming_iterator::FallibleStreamingIterator; use indexmap::IndexSet; use polars_error::*; use simd_json::BorrowedValue; /// Reads up to a number of lines from `reade...
code_fim
hard
{ "lang": "rust", "repo": "pola-rs/polars", "path": "/crates/polars-json/src/ndjson/file.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bonhamjp/JBTracer path: /src/rendering/intersection_tests.rs #[cfg(test)] mod tests { use crate::rendering::math::Color; use crate::rendering::math::Matrix4x4; use crate::rendering::shapes::shape::Shape; use crate::rendering::shapes::Sphere; use crate::rendering::Material; us...
code_fim
hard
{ "lang": "rust", "repo": "bonhamjp/JBTracer", "path": "/src/rendering/intersection_tests.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn hit_returns_intersection_with_smallest_t_if_all_positive() { let transform = Matrix4x4::translate(5.0, -3.0, 2.0); let material = Material::solid(0.1, 0.9, 0.9, 200.0, 0.0, 0.0, 1.0, Color::new(1.0, 1.0, 1.0, 1.0), Matrix4x4::identity()); let sphere = Sphere::new(transform, mate...
code_fim
hard
{ "lang": "rust", "repo": "bonhamjp/JBTracer", "path": "/src/rendering/intersection_tests.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chigraph/chigraph-rs path: /src/context.rs use std::collections::HashMap; use module::Module; use graph::DataType; struct Context { modules: HashMap<String, Box<Module>>, } impl Context { fn new() -> Context { Context { modules: HashMap::new(), } } ...
code_fim
medium
{ "lang": "rust", "repo": "chigraph/chigraph-rs", "path": "/src/context.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let ty = module.node_type(type_name)?; return Some(ty); } }<|fim_prefix|>// repo: chigraph/chigraph-rs path: /src/context.rs use std::collections::HashMap; use module::Module; use graph::DataType; struct Context { modules: HashMap<String, Box<Module>>, } impl Context ...
code_fim
hard
{ "lang": "rust", "repo": "chigraph/chigraph-rs", "path": "/src/context.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // find the colon let colon = name.find(':')?; let module_name = name[..colon]; let type_name = name[colon+1..]; let module = self.modules.get(module_name)?; let ty = module.node_type(type_name)?; return Some(ty); ...
code_fim
medium
{ "lang": "rust", "repo": "chigraph/chigraph-rs", "path": "/src/context.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: krummelur/rust-pong path: /src/number_helpers.rs /// Converts an i32 to an Array of u8 /// Returns a u8 Array representing the 32-bit value /// /// # Arguments /// /// * `x` - An i32 that holds the value to be converted pub fn i32_to_array_of_u8(x:i32) -> [u8;4] { let b1 : u8 = ((x >> 24)...
code_fim
medium
{ "lang": "rust", "repo": "krummelur/rust-pong", "path": "/src/number_helpers.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>n [b1, b2, b3, b4] } /// interprets an u8 ArraySlice as a single 32-bit integer /// Returns an i32 representing the u8 /// /// # Arguments /// /// * `array` - An u8 Array slice of length 4 that holds the values to be interpreted pub fn as_i32(array: &[u8]) -> i32 { ((array[0] as i32) << 24) + (...
code_fim
medium
{ "lang": "rust", "repo": "krummelur/rust-pong", "path": "/src/number_helpers.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> write_wav("out/offhook.wav", 44100, quantize_samples::<i16>( make_samples(15.0, 44100, |t: f64| -> f64 { if t % 0.2 < 0.1 { 0.25 * ( SineWave(1400.0)(t) + SineWave(2060.0)(t) + SineWave(2450.0)(t) +...
code_fim
hard
{ "lang": "rust", "repo": "infinityb/synthrs", "path": "/examples/telecoms.rs", "mode": "spm", "license": "LicenseRef-scancode-public-domain", "source": "the-stack-v2" }
<|fim_suffix|> write_wav("out/fastbusysignal.wav", 44100, quantize_samples::<i16>( make_samples(15.0, 44100, |t: f64| -> f64 { if t % 0.5 < 0.25 { 0.5 * (SineWave(480.0)(t) + SineWave(620.0)(t)) } else { 0.0 }...
code_fim
hard
{ "lang": "rust", "repo": "infinityb/synthrs", "path": "/examples/telecoms.rs", "mode": "spm", "license": "LicenseRef-scancode-public-domain", "source": "the-stack-v2" }
<|fim_prefix|>// repo: infinityb/synthrs path: /examples/telecoms.rs #![feature(unboxed_closures)] extern crate synthrs; use synthrs::synthesizer::{ make_samples, quantize_samples }; use synthrs::wave::SineWave; use synthrs::writer::write_wav; fn main() { write_wav("out/dialtone.wav", 44100, quantize_sa...
code_fim
hard
{ "lang": "rust", "repo": "infinityb/synthrs", "path": "/examples/telecoms.rs", "mode": "psm", "license": "LicenseRef-scancode-public-domain", "source": "the-stack-v2" }
<|fim_prefix|>// repo: unknownue/Vulkan path: /base/src/texture.rs use ash::vk; use gli::GliTexture; use crate::ci::vma::{VmaImage, VmaBuffer, VmaAllocationCI}; use crate::ci::image::{ImageCI, ImageViewCI, ImageBarrierCI, SamplerCI}; use crate::ci::buffer::BufferCI; use crate::ci::VkObjectBuildableCI; use crate::c...
code_fim
hard
{ "lang": "rust", "repo": "unknownue/Vulkan", "path": "/base/src/texture.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let sub_range = vk::ImageSubresourceRange { aspect_mask: vk::ImageAspectFlags::COLOR, base_mip_level: 0, level_count: tex_2d.levels() as vkuint, base_array_layer: 0, layer_count: 1, }; // I...
code_fim
hard
{ "lang": "rust", "repo": "unknownue/Vulkan", "path": "/base/src/texture.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if an == 0 { if bn > 0 { self.from_b(m, bn)? } } else if bn == 0 { if an > 0 { self.from_a(m, an)? } } else { // neither a nor b are 0 let am: usize = an / 2; // pick...
code_fim
hard
{ "lang": "rust", "repo": "rklaehn/interval-rs", "path": "/vec-set/src/binary_merge.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rklaehn/interval-rs path: /vec-set/src/binary_merge.rs use std::cmp::Ordering; /// Basically a convenient to use bool to allow aborting a piece of code early using ? pub(crate) type EarlyOut = Option<()>; /// The read part of the merge state that is needed for the binary merge algorithm /// it...
code_fim
hard
{ "lang": "rust", "repo": "rklaehn/interval-rs", "path": "/vec-set/src/binary_merge.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// merge `an` elements from a and `bn` elements from b into the result fn merge0(&self, m: &mut M, an: usize, bn: usize) { if an == 0 { if bn > 0 { self.from_b(m, bn); } } else if bn == 0 { if an > 0 { self.from_a...
code_fim
hard
{ "lang": "rust", "repo": "rklaehn/interval-rs", "path": "/vec-set/src/binary_merge.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: superf0sh/solana path: /src/fullnode.rs clone()); let exit = Arc::new(AtomicBool::new(false)); let bank_info = &bank_forks_info[0]; let bank = bank_forks[bank_info.bank_id].clone(); info!("starting PoH... {} {}", bank.tick_height(), bank.last_id(),); let...
code_fim
hard
{ "lang": "rust", "repo": "superf0sh/solana", "path": "/src/fullnode.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if rotation_info.leader_id == self.id { let transition = if was_leader { debug!("{:?} remaining in leader role", self.id); FullnodeReturnType::LeaderToLeaderRotation } else { debug!("{:?} rotating to leader role", self.id); ...
code_fim
hard
{ "lang": "rust", "repo": "superf0sh/solana", "path": "/src/fullnode.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let new_vote_account_tx = VoteTransaction::fund_staking_account(active_keypair, vote_account_id, *last_id, 1, 1); let new_vote_account_entry = next_entry_mut(&mut last_entry_hash, 1, vec![new_vote_account_tx]); // 3) Create vote entry let vote_tx = VoteTransaction::new_vote(&votin...
code_fim
hard
{ "lang": "rust", "repo": "superf0sh/solana", "path": "/src/fullnode.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> match result { Ok(tasks) => HttpResponse::Ok().json(tasks), Err(err) => HttpResponse::NotFound().body(err.to_string()), } } pub async fn get(id: web::Path<u32>) -> impl Responder { println!("got id: {:?}", id.into_inner()); HttpResponse::Ok...
code_fim
hard
{ "lang": "rust", "repo": "longfellowone/vd-app", "path": "/server/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>async fn data() -> impl Responder { HttpResponse::Ok().json(Task { id: Uuid::new_v4(), name: "data".to_string(), }) } mod postgres { use super::Task; use actix_web::{web, HttpResponse, Responder}; use sqlx::PgPool; use uuid::Uuid; pub async fn list(db: web::Da...
code_fim
hard
{ "lang": "rust", "repo": "longfellowone/vd-app", "path": "/server/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: longfellowone/vd-app path: /server/src/main.rs mod configuration; use actix_cors::Cors; use actix_web::{web, App, HttpResponse, HttpServer, Responder}; use anyhow::Result; use configuration::Configuration; use serde::{Deserialize, Serialize}; use sqlx::postgres::PgPoolOptions; use sqlx::FromRow...
code_fim
hard
{ "lang": "rust", "repo": "longfellowone/vd-app", "path": "/server/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> loop { if buttons.button1_pressed() { leds.led0_off(); } else { leds.led0_on(); } delay.delay_ms(500u16); if !buttons.button0_pressed() { leds.led1_on(); } delay.delay_ms(500u16); leds.led1_off(); ...
code_fim
medium
{ "lang": "rust", "repo": "chrysn/thunderboard-sltb001a", "path": "/examples/blink.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chrysn/thunderboard-sltb001a path: /examples/blink.rs //! Blink an LED while running the other one continuously, while monitoring the buttons to change //! the behavior. //! //! The example runs in a tight loop and only occasionally reads out the buttons (rather than //! sleeping, using interrup...
code_fim
hard
{ "lang": "rust", "repo": "chrysn/thunderboard-sltb001a", "path": "/examples/blink.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>use cortex_m_rt::entry; use embedded_hal::blocking::delay::DelayMs; #[entry] fn main() -> ! { let board = thunderboard_sltb001a::Board::new(); let mut leds = board.leds; let buttons = board.buttons; let mut delay = board.delay; let mut pic = board.pic; let mut count = 1; loo...
code_fim
medium
{ "lang": "rust", "repo": "chrysn/thunderboard-sltb001a", "path": "/examples/blink.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ZeWaka/auxtools path: /auxtools/src/sigscan/windows.rs use std::mem; use std::ptr; use winapi::shared::minwindef; use winapi::um::libloaderapi; use winapi::um::processthreadsapi; use winapi::um::psapi; pub struct Scanner { _module: minwindef::HMODULE, data_begin: *mut u8, data_end: *mut u8,...
code_fim
hard
{ "lang": "rust", "repo": "ZeWaka/auxtools", "path": "/auxtools/src/sigscan/windows.rs", "mode": "psm", "license": "GPL-1.0-or-later", "source": "the-stack-v2" }
<|fim_suffix|> let mut module_info_wrapper = mem::MaybeUninit::<psapi::MODULEINFO>::zeroed(); if psapi::GetModuleInformation( processthreadsapi::GetCurrentProcess(), module, module_info_wrapper.as_mut_ptr(), mem::size_of::<psapi::MODULEINFO>() as u32, ) == 0 { libloaderapi::FreeLibrary(mo...
code_fim
hard
{ "lang": "rust", "repo": "ZeWaka/auxtools", "path": "/auxtools/src/sigscan/windows.rs", "mode": "spm", "license": "GPL-1.0-or-later", "source": "the-stack-v2" }
<|fim_prefix|>// repo: whtcorpsinc/einsteindb-prod path: /edb/lenin/fidel_client/src/config.rs // Copyright 2020 WHTCORPS INC Project Authors. Licensed Under Apache-2.0 use std::error::Error; use violetabftstore::interlock::::config::ReadableDuration; /// The configuration for a FIDel Client. /// /// By default duri...
code_fim
hard
{ "lang": "rust", "repo": "whtcorpsinc/einsteindb-prod", "path": "/edb/lenin/fidel_client/src/config.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> pub fn validate(&self) -> Result<(), Box<dyn Error>> { if self.lightlikepoints.is_empty() { return Err("please specify fidel.lightlikepoints.".into()); } if self.retry_log_every == 0 { return Err("fidel.retry_log_every cannot be <=0".into()); } ...
code_fim
hard
{ "lang": "rust", "repo": "whtcorpsinc/einsteindb-prod", "path": "/edb/lenin/fidel_client/src/config.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if self.retry_log_every == 0 { return Err("fidel.retry_log_every cannot be <=0".into()); } if self.retry_max_count < -1 { return Err("fidel.retry_max_count cannot be < -1".into()); } Ok(()) } } #[causet(test)] mod tests { use super...
code_fim
hard
{ "lang": "rust", "repo": "whtcorpsinc/einsteindb-prod", "path": "/edb/lenin/fidel_client/src/config.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Ok(partitions.join(" ")) } #[cfg(test)] mod tests { use super::*; #[test] fn encrypt_only_letters() { let message = "Hello Morse"; let cipher = encode(message); assert_eq!( cipher, ".... . .-.. .-.. --- / -- --- .-. ... .".to_string() ...
code_fim
hard
{ "lang": "rust", "repo": "TheAlgorithms/Rust", "path": "/src/ciphers/morse_code.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TheAlgorithms/Rust path: /src/ciphers/morse_code.rs use std::collections::HashMap; use std::io; const UNKNOWN_CHARACTER: &str = "........"; const _UNKNOWN_MORSE_CHARACTER: &str = "_"; pub fn encode(message: &str) -> String { let dictionary = _morse_dictionary(); message .chars(...
code_fim
hard
{ "lang": "rust", "repo": "TheAlgorithms/Rust", "path": "/src/ciphers/morse_code.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> //match guess.cmp(&secret_number.to_string()) { // Ordering::Less => println!("Too small"), // Ordering::Greater => println!("Too big"), // Ordering::Equal => println!("Too win"), //} match guess.cmp(&secret_number) { Ordering::Less => ...
code_fim
medium
{ "lang": "rust", "repo": "feniljain/rust-projects", "path": "/guessing_game/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: feniljain/rust-projects path: /guessing_game/src/main.rs use rand::{thread_rng, Rng}; use std::cmp::Ordering; use std::io; fn main() { println!("!!!!Guess The Number!!!!"); let mut rng = thread_rng(); let secret_number: u32 = rng.gen_range(0, 101); //println!("{}", secret_numb...
code_fim
hard
{ "lang": "rust", "repo": "feniljain/rust-projects", "path": "/guessing_game/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }