text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> fn encode(&self, writer: &mut impl Buffer) {
writer.put_u8(*self as u8);
}
}
macro_rules! encode_as {
($($ty: ty as $prim: ty),* $(,)?) => { $(
impl Encode for $ty {
fn encode_len(&self) -> usize {
mem::size_of::<$prim>()
}
... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/kafka-protocol",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nixpulvis/hell path: /6/feeding/evolution-wire/src/choice.rs
use serde::ser::{Serialize, Serializer};
use serde::ser::impls::TupleVisitor3;
use serde::de::{Deserialize, Deserializer, Error, SeqVisitor, Visitor};
use super::*;
/// The data a player gets to make a choice for the action step.
///
... | code_fim | hard | {
"lang": "rust",
"repo": "nixpulvis/hell",
"path": "/6/feeding/evolution-wire/src/choice.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>struct ChoiceVisitor;
impl Visitor for ChoiceVisitor {
type Value = Choice;
fn visit_seq<V>(&mut self, mut visitor: V) -> Result<Self::Value, V::Error>
where V: SeqVisitor
{
let current_player = try!(visitor.visit());
let before = try!(visitor.visit());
let af... | code_fim | medium | {
"lang": "rust",
"repo": "nixpulvis/hell",
"path": "/6/feeding/evolution-wire/src/choice.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> async fn method_with_return_value(
&mut self,
_dbus: &DBus,
msg_header: &MessageHeader,
) -> Result<i32, (Error, String)> {
println!(
"The sender who send the message: {:?}",
msg_header.get_sender()
);
// The return value of t... | code_fim | hard | {
"lang": "rust",
"repo": "LinkTed/dbus-async-derive",
"path": "/examples/methods.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LinkTed/dbus-async-derive path: /examples/methods.rs
use dbus_async::{Binder, DBus};
use dbus_async_derive::Handler;
use dbus_message_parser::{Error, MessageHeader, Value};
use std::convert::TryInto;
#[derive(Handler)]
#[interface(
"org.example.methods",
method("Method", method),
me... | code_fim | hard | {
"lang": "rust",
"repo": "LinkTed/dbus-async-derive",
"path": "/examples/methods.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Tails8521/parser path: /src/demo/message/bspdecal.rs
use bitbuffer::{BitRead, LittleEndian};
use crate::demo::sendprop::read_bit_coord;
use crate::demo::vector::Vector;
use crate::{ReadResult, Stream};
#[derive(Debug, Clone)]
pub struct BSPDecalMessage {
pub position: Vector,
pub textu... | code_fim | hard | {
"lang": "rust",
"repo": "Tails8521/parser",
"path": "/src/demo/message/bspdecal.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let position = {
let has_x = stream.read()?;
let has_y = stream.read()?;
let has_z = stream.read()?;
Vector {
x: if has_x { read_bit_coord(stream)? } else { 0f32 },
y: if has_y { read_bit_coord(stream)? } else { 0f32 ... | code_fim | hard | {
"lang": "rust",
"repo": "Tails8521/parser",
"path": "/src/demo/message/bspdecal.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// When we create a namesapce, the initial group of replicas is at epoch 1. When a reconfiguration
/// occurs we bump the epoch so when we gossip the information around to start the fsms, we can
/// chose the latest version.
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
pub struct Versio... | code_fim | hard | {
"lang": "rust",
"repo": "digideskio/haret",
"path": "/src/vr/replica.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> msg: rabble::Msg<Msg>,
from: Pid,
correlation_id: Option<CorrelationId>,
output: &mut Vec<Envelope<Msg>>)
{
let correlation_id = correlation_id.map_or(CorrelationId::pid(self.pid.clone()),
... | code_fim | hard | {
"lang": "rust",
"repo": "digideskio/haret",
"path": "/src/vr/replica.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: digideskio/haret path: /src/vr/replica.rs
// Copyright © 2016-2017 VMware, Inc. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
use rabble::{self, Process, Pid, CorrelationId, Envelope};
use funfsm::Fsm;
use msg::Msg;
use super::vr_fsm::VrTypes;
use super::vr_envelope::VrEnvelope;
u... | code_fim | hard | {
"lang": "rust",
"repo": "digideskio/haret",
"path": "/src/vr/replica.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: andoriyu/material-design-icons-rs path: /src/materialiconsround/places/icon_pool.rs
pub struct IconPool {
props: crate::Props,
}
impl yew::Component for IconPool {
type Properties = crate::Props;
type Message = ();
fn create(props: Self::Properties, _: yew::prelude::ComponentLink<S... | code_fim | medium | {
"lang": "rust",
"repo": "andoriyu/material-design-icons-rs",
"path": "/src/materialiconsround/places/icon_pool.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if inflection_points.contains(&value) {
// if we have reached an inflection point
// we'll stop looking and increment the number of paths
// which get to this inflection point
*visited_inflection_points.entry(value).or_insert(0) += 1;
} else ... | code_fim | hard | {
"lang": "rust",
"repo": "boylede/aoc2020",
"path": "/src/day10.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: boylede/aoc2020 path: /src/day10.rs
use crate::PartResult;
use std::collections::HashMap;
// we make some pretty extensive assumptions here.
pub fn part1(lines: &Vec<String>) -> PartResult {
let mut adapters = lines
.iter()
.map(|line| line.parse::<i32>().unwrap())
.... | code_fim | hard | {
"lang": "rust",
"repo": "boylede/aoc2020",
"path": "/src/day10.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // since it is unit test case sync-state should return zero-state not error
let fork: Fork = fork_db();
{
let mut schema = SchemaFork::new(&fork);
assert_eq!(schema.sync_state(), false);
}
}
fn test_failed_scenarios() {
let kp: Keypa... | code_fim | hard | {
"lang": "rust",
"repo": "Talentica/simpleblockchain",
"path": "/src/db_service/src/tests.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Talentica/simpleblockchain path: /src/db_service/src/tests.rs
#[cfg(test)]
mod test_db_service {
use crate::db_fork_ref::*;
use crate::db_layer::{fork_db, patch_db, snapshot_db};
use crate::db_snapshot_ref::*;
use exonum_crypto::Hash;
use exonum_merkledb::{Fork, ObjectHash, S... | code_fim | hard | {
"lang": "rust",
"repo": "Talentica/simpleblockchain",
"path": "/src/db_service/src/tests.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut result = 1;
for c in 2..=col {
result += c;
}
for r in 2..=row {
result += col + r - 2;
}
result
}
fn codes(first: usize) -> impl Iterator<Item = usize> {
std::iter::successors(Some(first), |prev| Some((prev * 252533) % 33554393))
}<|fim_prefix|>// repo... | code_fim | hard | {
"lang": "rust",
"repo": "jmageau/advent_of_code",
"path": "/src/year_2015/day_25.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jmageau/advent_of_code path: /src/year_2015/day_25.rs
pub fn answers() -> String {
answer_one()
}
fn answer_one() -> String {
let (row, col) = parse(&input());
let n = row_col_to_n(row, col);
codes(20151125).nth(n - 1).unwrap().to_string()
}
fn input() -> String {
<|fim_suffix|... | code_fim | hard | {
"lang": "rust",
"repo": "jmageau/advent_of_code",
"path": "/src/year_2015/day_25.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> loop {
// wait tick
let _ = interval.tick().await;
// show metrics
info!("{:?}", subscriber);
}
}<|fim_prefix|>// repo: isgasho/fantoch path: /fantoch/src/run/task/tracer.rs
use tokio::time::Duration;
#[cfg(not(feature = "prof"))]
pub async fn tracer_task(interval... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/fantoch",
"path": "/fantoch/src/run/task/tracer.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // set tracing subscriber
let subscriber = ProfSubscriber::new();
tracing::subscriber::set_global_default(subscriber.clone()).unwrap_or_else(
|e| warn!("tracing global default subscriber already set: {:?}", e),
);
// create tokio interval
let interval = interval.unwrap();
... | code_fim | medium | {
"lang": "rust",
"repo": "isgasho/fantoch",
"path": "/fantoch/src/run/task/tracer.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/fantoch path: /fantoch/src/run/task/tracer.rs
use tokio::time::Duration;
#[cfg(not(feature = "prof"))]
pub async fn tracer_task(interval: Option<Duration>) {
use crate::warn;
match interval {
Some(_) => {
panic!("[tracer_task] tracer show interval was set but... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/fantoch",
"path": "/fantoch/src/run/task/tracer.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> //TODO: zero bss
}
#[no_mangle]
extern "C" fn rust_boot(hartid: usize, _fdt: *const u8) -> ! {
if hartid == 0 {
boot_init();
}
crate::smp_main(hartid)
}<|fim_prefix|>// repo: Phosfor/the_os path: /src/arch/riscv/boot.rs
global_asm!(include_str!("boot.asm"));
<|fim_middle|>fn b... | code_fim | easy | {
"lang": "rust",
"repo": "Phosfor/the_os",
"path": "/src/arch/riscv/boot.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Phosfor/the_os path: /src/arch/riscv/boot.rs
global_asm!(include_str!("boot.asm"));
fn boot_init() {
<|fim_suffix|>#[no_mangle]
extern "C" fn rust_boot(hartid: usize, _fdt: *const u8) -> ! {
if hartid == 0 {
boot_init();
}
crate::smp_main(hartid)
}<|fim_middle|> //TODO:... | code_fim | easy | {
"lang": "rust",
"repo": "Phosfor/the_os",
"path": "/src/arch/riscv/boot.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> crate::smp_main(hartid)
}<|fim_prefix|>// repo: Phosfor/the_os path: /src/arch/riscv/boot.rs
global_asm!(include_str!("boot.asm"));
fn boot_init() {
<|fim_middle|> //TODO: zero bss
}
#[no_mangle]
extern "C" fn rust_boot(hartid: usize, _fdt: *const u8) -> ! {
if hartid == 0 {
boot_in... | code_fim | medium | {
"lang": "rust",
"repo": "Phosfor/the_os",
"path": "/src/arch/riscv/boot.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kpozin/icu4x path: /components/pluralrules/src/data/mod.rs
//! Temporary module with logic required to provide
//! data to the crate.
//!
//! # Examples
//!
//! ```
//! use icu_locale::LanguageIdentifier;
//! use icu_pluralrules::{PluralCategory, PluralRuleType, PluralOperands};
//!
//! use icu_... | code_fim | hard | {
"lang": "rust",
"repo": "kpozin/icu4x",
"path": "/components/pluralrules/src/data/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl RulesSelector {
pub fn select(&self, operands: &PluralOperands) -> PluralCategory {
match self {
Self::Function(ptr) => ptr(operands),
Self::Conditions(conditions) => conditions
.iter()
.find_map(|(category, rule)| {
... | code_fim | hard | {
"lang": "rust",
"repo": "kpozin/icu4x",
"path": "/components/pluralrules/src/data/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
/// Returns mutable reference to custom properties.
fn properties_mut(&mut self) -> &mut Properties;
/// Returns context data containing extra, optional tags. Overrides values found on client telemetry context.
fn tags(&self) -> &ContextTags;
/// Returns mutable reference to custom ... | code_fim | medium | {
"lang": "rust",
"repo": "zhzy0077/appinsights-rs",
"path": "/appinsights/src/telemetry/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zhzy0077/appinsights-rs path: /appinsights/src/telemetry/mod.rs
//! Module for Application Insights telemetry items.
mod availability;
mod event;
mod exception;
mod measurements;
mod metric;
mod page_view;
mod properties;
mod remote_dependency;
mod request;
mod tags;
mod trace;
pub use availabi... | code_fim | medium | {
"lang": "rust",
"repo": "zhzy0077/appinsights-rs",
"path": "/appinsights/src/telemetry/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
/// Returns context data containing extra, optional tags. Overrides values found on client telemetry context.
fn tags(&self) -> &ContextTags;
/// Returns mutable reference to custom tags.
fn tags_mut(&mut self) -> &mut ContextTags;
}<|fim_prefix|>// repo: zhzy0077/appinsights-rs path: /... | code_fim | hard | {
"lang": "rust",
"repo": "zhzy0077/appinsights-rs",
"path": "/appinsights/src/telemetry/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn get_latest_slot(&mut self) -> Slot {
let mut period = time::Duration::from_millis(100);
loop {
let slot_result = self.rpc_client.get_slot_with_commitment(CommitmentConfig::finalized());
match slot_result {
Ok(slot) => {
... | code_fim | hard | {
"lang": "rust",
"repo": "ilmoi/datadragon",
"path": "/src/solana_rpc.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn get_blocks(&self, start_slot: Slot, end_slot: Option<Slot>)
-> ClientResult<Vec<Slot>> {
return self.rpc_client.get_blocks(start_slot, end_slot);
}
pub fn get_latest_slot(&mut self) -> Slot {
let mut period = time::Duration::from_millis(100);
loop {
... | code_fim | hard | {
"lang": "rust",
"repo": "ilmoi/datadragon",
"path": "/src/solana_rpc.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ilmoi/datadragon path: /src/solana_rpc.rs
use std::{thread, time};
use solana_client::rpc_client::RpcClient;
use solana_client::client_error::Result as ClientResult;
use solana_sdk::{
clock::Slot,
commitment_config::CommitmentConfig,
};
use solana_transaction_status::{
EncodedConfir... | code_fim | hard | {
"lang": "rust",
"repo": "ilmoi/datadragon",
"path": "/src/solana_rpc.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.0.get(addr)
}
}
impl<T: ReadMemory> WriteMemory for ReadMemoryWrapper<T> {
fn set(&mut self, _: Address, _: Word) -> VoidResultChip8 {
Err(Error::new("Write not supported for this memory".to_owned()))
}
}
struct WriteMemoryWrapper<T: WriteMemory>(T);
impl<T: WriteMemory... | code_fim | hard | {
"lang": "rust",
"repo": "Davipb/chip-8",
"path": "/src/memory.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Davipb/chip-8 path: /src/memory.rs
use crate::core::{Address, Error, ResultChip8, VoidResultChip8, Word};
use std::fmt::{self, Display, Formatter, Write};
use std::fs::File;
use std::io::Read;
use std::ops::Range;
pub trait ReadMemory {
fn get(&self, addr: Address) -> ResultChip8<Word>;
... | code_fim | hard | {
"lang": "rust",
"repo": "Davipb/chip-8",
"path": "/src/memory.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Hirevo/persist path: /persist-core/src/protocol/mod.rs
use std::collections::HashMap;
use std::fmt::{self, Display};
use std::path::PathBuf;
use serde::{Deserialize, Serialize};
mod request;
mod response;
pub use self::request::*;
pub use self::response::*;
/// The status of a process.
#[der... | code_fim | hard | {
"lang": "rust",
"repo": "Hirevo/persist",
"path": "/persist-core/src/protocol/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> ProcessSpec {
name: info.name,
cmd: info.cmd,
cwd: info.cwd,
env: info.env,
pid_path: info.pid_path,
stdout_path: info.stdout_path,
stderr_path: info.stderr_path,
created_at: info.created_at,
}
... | code_fim | hard | {
"lang": "rust",
"repo": "Hirevo/persist",
"path": "/persist-core/src/protocol/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn my_get_mtime(pop: *mut PMEMobjpool, id: u32)->c_long{
unsafe{
get_metadata_mtime(pop, id as c_int)
}
}
pub fn my_set_ctime(pop: *mut PMEMobjpool, id: u32, ctime: u64)->c_void{
unsafe{
set_ctime(pop, id as c_int, ctime as c_long)
}
}
pub fn my_get_ctime(pop: *mut PM... | code_fim | hard | {
"lang": "rust",
"repo": "coolyjg/my_fusefs_v2.0",
"path": "/src/ffi_wrapper.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn my_set_metadata_size(pop: *mut PMEMobjpool, id: u32, size: usize)->c_void{
unsafe{
set_metadata_size(pop, id as c_int, size as size_t)
}
}
pub fn my_get_size(pop: *mut PMEMobjpool, id: u32)->usize{
unsafe{
get_metadata_size(pop, id as c_int) as usize
}
}
// pub fn ... | code_fim | hard | {
"lang": "rust",
"repo": "coolyjg/my_fusefs_v2.0",
"path": "/src/ffi_wrapper.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: coolyjg/my_fusefs_v2.0 path: /src/ffi_wrapper.rs
extern crate libc;
use libc::c_int;
use libc::size_t;
use libc::c_void;
use libc::c_char;
use libc::c_long;
// use std::ffi::CString;
pub enum PMEMobjpool {}
pub static mut MY_POP_DATA: Option<*mut PMEMobjpool>= None;
pub static mut MY_POP_MD: O... | code_fim | hard | {
"lang": "rust",
"repo": "coolyjg/my_fusefs_v2.0",
"path": "/src/ffi_wrapper.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn init_with_manufacturer_option_works() {
let original_working_directory = env::current_dir().unwrap();
let package = common::create_test_package();
let expected_msi_file = TARGET_WIX_DIR.join(format!(
"{}-0.1.0-x86_64.msi", package.path().file_name().and_then(|o| o.to_st... | code_fim | hard | {
"lang": "rust",
"repo": "MOZGIII/cargo-wix",
"path": "/tests/create.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MOZGIII/cargo-wix path: /tests/create.rs
.child(TARGET_WIX_DIR.as_path()).assert(predicate::path::exists());
package.child(expected_msi_file).assert(predicate::path::exists());
}
#[test]
fn init_with_package_section_fields_works() {
let original_working_directory = env::current_di... | code_fim | hard | {
"lang": "rust",
"repo": "MOZGIII/cargo-wix",
"path": "/tests/create.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MOZGIII/cargo-wix path: /tests/create.rs
t.insert(String::from("description"), Value::from("This is a description"));
t.insert(String::from("documentation"), Value::from("https://www.example.com/docs"));
t.insert(String::from("homepage"),... | code_fim | hard | {
"lang": "rust",
"repo": "MOZGIII/cargo-wix",
"path": "/tests/create.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lpil/decksterity path: /src/engine/dsp_node/mod.rs
mod player_node;
mod volume_node;
use super::dsp::Node;
use self::player_node::PlayerNode;
use self::volume_node::VolumeNode;
<|fim_suffix|> match *self {
DspNode::Master => {}
DspNode::Volume(ref mut volume) => ... | code_fim | hard | {
"lang": "rust",
"repo": "lpil/decksterity",
"path": "/src/engine/dsp_node/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn new_player() -> DspNode {
DspNode::Player(PlayerNode::new())
}
pub fn new_volume() -> DspNode {
DspNode::Volume(VolumeNode::new())
}<|fim_prefix|>// repo: lpil/decksterity path: /src/engine/dsp_node/mod.rs
mod player_node;
mod volume_node;
use super::dsp::Node;
use self::player_node::Pla... | code_fim | hard | {
"lang": "rust",
"repo": "lpil/decksterity",
"path": "/src/engine/dsp_node/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: poma/clap path: /examples/20_subcommands.rs
// Working with subcommands is simple. There are a few key points to remember when working with
// subcommands in clap. First, s are really just Apps. This means they can have their own
// settings, version, authors, args, and even their own subcommand... | code_fim | hard | {
"lang": "rust",
"repo": "poma/clap",
"path": "/examples/20_subcommands.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // The most common way to handle subcommands is via a combined approach using
// `ArgMatches::subcommand` which returns a tuple of both the name and matches
match matches.subcommand() {
("clone", Some(clone_matches)) => {
// Now we have a reference to clone's matches
... | code_fim | hard | {
"lang": "rust",
"repo": "poma/clap",
"path": "/examples/20_subcommands.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MaulingMonkey/jni-bindgen path: /jni-glue/src/refs/argument.rs
use super::*;
/// FFI: Use **Argument\<java::lang::Object\>** instead of jobject. This represents a (null?) function argument.
///
/// Unlike most Java reference types from this library, this *can* be null.
///
/// FFI safe whe... | code_fim | hard | {
"lang": "rust",
"repo": "MaulingMonkey/jni-bindgen",
"path": "/jni-glue/src/refs/argument.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// A [Local](https://www.ibm.com/support/knowledgecenter/en/SSYKE2_8.0.0/com.ibm.java.vm.80.doc/docs/jni_refs.html),
/// non-null, reference to a Java object (+ &Env).
///
/// Much like Local, the inclusion of an Env means this cannot be stored statically or shared between threads.
///
/// **Not FFI Sa... | code_fim | hard | {
"lang": "rust",
"repo": "MaulingMonkey/jni-bindgen",
"path": "/jni-glue/src/refs/argument.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zzhang82/Lets-s_GO_Rust path: /main_CommentOut1.rs
fn main() {
/* types
let x: u64 = 45;
let f = 6.7; //f32
let b:bool = false;
<|fim_suffix|>/* Vectors and loop range
let numbers = 11..51;
let animals = vec!["Rabbit","Dog","Cat"];
for i in numbers {
println... | code_fim | hard | {
"lang": "rust",
"repo": "zzhang82/Lets-s_GO_Rust",
"path": "/main_CommentOut1.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/* Vectors and loop range
let numbers = 11..51;
let animals = vec!["Rabbit","Dog","Cat"];
for i in numbers {
println! ("The number is {}",i);
for (index,j) in animals.iter().enumerate() { //iter for the vectors. and the enumerate for the index of the vectors
printl... | code_fim | hard | {
"lang": "rust",
"repo": "zzhang82/Lets-s_GO_Rust",
"path": "/main_CommentOut1.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ng3rdstmadgke/mtools path: /src/util.rs
/// seq を delimiter で連結した文字列に整形する
///
/// # Arguments
/// * `delimiter` - 区切り文字
/// * `seq` - 連結対象の配列
pub fn join<T: std::fmt::Display>(delimiter: char, seq: &[T]) -> String {
use std::fmt::Write;
let mut ret = String::new();
for e in seq... | code_fim | medium | {
"lang": "rust",
"repo": "ng3rdstmadgke/mtools",
"path": "/src/util.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!("1;2;3;4", join(';', &[1, 2, 3, 4]));
}
}<|fim_prefix|>// repo: ng3rdstmadgke/mtools path: /src/util.rs
/// seq を delimiter で連結した文字列に整形する
///
/// # Arguments
/// * `delimiter` - 区切り文字
/// * `seq` - 連結対象の配列
pub fn join<T: std::fmt::Display>(delimiter: char, seq: &[T]) -> Strin... | code_fim | medium | {
"lang": "rust",
"repo": "ng3rdstmadgke/mtools",
"path": "/src/util.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vsupalov/pokerhandrange-rs path: /src/lib.rs
//! pokerhandrange-rs defines a Range trait and contains a SimpleRange, which
//! can be used to create a range representation with something like
//! new_from_string("AA,AK+"). The resulting SimpleRange can be used to
//! check if any two cards are c... | code_fim | hard | {
"lang": "rust",
"repo": "vsupalov/pokerhandrange-rs",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if components.len() == 0 {
return Err(Error::new(ErrorKind::Other,
"Zero length range string not allowed"));
}
//construct an array with a running sum of combinations
//this is used later to draw cards from the range, weighted by their
... | code_fim | hard | {
"lang": "rust",
"repo": "vsupalov/pokerhandrange-rs",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: celestecote21/Tity3 path: /src/keyboard.rs
use crate::windows::WindowsConf;
pub fn parse_input(data: [u8; 4096], size: usize, config: &WindowsConf) -> ([u8; 4096], usize) {
let mut i = 0;
loop {
if i >= size {
<|fim_suffix|> 0);
}
i += 1;
}
(d... | code_fim | medium | {
"lang": "rust",
"repo": "celestecote21/Tity3",
"path": "/src/keyboard.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ymap()
.iter()
.position(|map| map.keycode == keycode)
{
Some(p) => p,
None => return false,
};
config.get_keymap()[pos].take_action(config);
true
}<|fim_prefix|>// repo: celestecote21/Tity3 path: /src/keyboard.rs
use crate::windows::WindowsConf;
pub fn pa... | code_fim | hard | {
"lang": "rust",
"repo": "celestecote21/Tity3",
"path": "/src/keyboard.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pola-rs/polars path: /crates/polars-core/src/chunked_array/builder/fixed_size_list.rs
use arrow::array::{
Array, MutableArray, MutableFixedSizeListArray, MutablePrimitiveArray, PrimitiveArray,
PushUnchecked,
};
use arrow::types::NativeType;
use polars_utils::unwrap::UnwrapUncheckedReleas... | code_fim | hard | {
"lang": "rust",
"repo": "pola-rs/polars",
"path": "/crates/polars-core/src/chunked_array/builder/fixed_size_list.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub(crate) fn get_fixed_size_list_builder(
inner_type_logical: &DataType,
capacity: usize,
width: usize,
name: &str,
) -> PolarsResult<Box<dyn FixedSizeListBuilder>> {
let phys_dtype = inner_type_logical.to_physical();
let builder = if phys_dtype.is_numeric() {
with_match_... | code_fim | hard | {
"lang": "rust",
"repo": "pola-rs/polars",
"path": "/crates/polars-core/src/chunked_array/builder/fixed_size_list.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cronosun/abin path: /abin/src/spi/unsafe.rs
use crate::spi::{BinData, FnTable};
use crate::SBin;
/// Unsafe interface for `Bin`. This is only to be used if you want to
/// implement your own binary type.
///
/// Note: Naming (the `_`) is a bit awkward: This is intentional: This trait is impleme... | code_fim | hard | {
"lang": "rust",
"repo": "cronosun/abin",
"path": "/abin/src/spi/unsafe.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Gets the function-table.
///
/// # Safety
///
/// This is unsafe. Use this only if you implement your own binary type and you know what
/// you're doing. See the default-implementation for details.
unsafe fn _fn_table(&self) -> &'static FnTable;
/// Wraps this binary i... | code_fim | hard | {
"lang": "rust",
"repo": "cronosun/abin",
"path": "/abin/src/spi/unsafe.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MoritzKn/ggez-snake path: /src/snake.rs
use base_types::*;
use constants::*;
use std::time::Instant;
use utils::random_pos;
<|fim_suffix|>impl Snake {
pub fn new() -> Self {
Snake {
tail: vec![random_pos(&PLAY_AREA)],
velocity: INITIAL_VELOCITY,
s... | code_fim | hard | {
"lang": "rust",
"repo": "MoritzKn/ggez-snake",
"path": "/src/snake.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Snake {
pub fn new() -> Self {
Snake {
tail: vec![random_pos(&PLAY_AREA)],
velocity: INITIAL_VELOCITY,
speed: INITIAL_SPEED,
last_round: Instant::now(),
lost_at: None,
score: 0,
grow: INITIAL_SIZE - 1,
... | code_fim | hard | {
"lang": "rust",
"repo": "MoritzKn/ggez-snake",
"path": "/src/snake.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: twigoftilia/advent_of_code_2019_twigoftilia path: /src/day_9.rs
use crate::int_computer::*;
use crate::util;
static DAY_9_PROGRAM_INPUT: &str = include_str!(r"../input/day-9.txt");
<|fim_suffix|>fn solve_second(program: &[i64]) -> i64 {
let mut computer: Computer = Computer::new(program);
... | code_fim | hard | {
"lang": "rust",
"repo": "twigoftilia/advent_of_code_2019_twigoftilia",
"path": "/src/day_9.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut computer: Computer = Computer::new(program);
computer.inputs.push(2);
computer.compute(false);
computer.outputs.pop().unwrap()
}<|fim_prefix|>// repo: twigoftilia/advent_of_code_2019_twigoftilia path: /src/day_9.rs
use crate::int_computer::*;
use crate::util;
static DAY_9_PROGRAM... | code_fim | hard | {
"lang": "rust",
"repo": "twigoftilia/advent_of_code_2019_twigoftilia",
"path": "/src/day_9.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Arnavion/k8s-openapi path: /src/v1_24/api/batch/v1beta1/cron_job_status.rs
// Generated from definition io.k8s.api.batch.v1beta1.CronJobStatus
/// CronJobStatus represents the current state of a cron job.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct CronJobStatus {
/// A list of p... | code_fim | hard | {
"lang": "rust",
"repo": "Arnavion/k8s-openapi",
"path": "/src/v1_24/api/batch/v1beta1/cron_job_status.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut state = serializer.serialize_struct(
"CronJobStatus",
self.active.as_ref().map_or(0, |_| 1) +
self.last_schedule_time.as_ref().map_or(0, |_| 1) +
self.last_successful_time.as_ref().map_or(0, |_| 1),
)?;
if let Some(value) = &s... | code_fim | hard | {
"lang": "rust",
"repo": "Arnavion/k8s-openapi",
"path": "/src/v1_24/api/batch/v1beta1/cron_job_status.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> &mut self,
position: impl Into<ffi::Vector2>,
size: impl Into<ffi::Vector2>,
color: impl Into<ffi::Color>,
) {
unsafe {
ffi::DrawRectangleV(position.into(), size.into(), color.into());
}
}
/// Draws a color-filled rectangle from `rec... | code_fim | hard | {
"lang": "rust",
"repo": "deltaphc/raylib-rs",
"path": "/raylib/src/core/drawing.rs",
"mode": "spm",
"license": "Zlib",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: deltaphc/raylib-rs path: /raylib/src/core/drawing.rs
tic bezier curves with a control point
#[inline]
fn draw_line_bezier_quad(
&mut self,
start_pos: impl Into<ffi::Vector2>,
end_pos: impl Into<ffi::Vector2>,
control_pos: impl Into<ffi::Vector2>,
t... | code_fim | hard | {
"lang": "rust",
"repo": "deltaphc/raylib-rs",
"path": "/raylib/src/core/drawing.rs",
"mode": "psm",
"license": "Zlib",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: deltaphc/raylib-rs path: /raylib/src/core/drawing.rs
e (Vector version).
#[inline]
fn draw_line_v(
&mut self,
start_pos: impl Into<ffi::Vector2>,
end_pos: impl Into<ffi::Vector2>,
color: impl Into<ffi::Color>,
) {
unsafe {
ffi::Draw... | code_fim | hard | {
"lang": "rust",
"repo": "deltaphc/raylib-rs",
"path": "/raylib/src/core/drawing.rs",
"mode": "psm",
"license": "Zlib",
"source": "the-stack-v2"
} |
<|fim_suffix|> for _ in 0..100 {
println!("{:?}", example.cups);
example.round();
}
println!("{:?}", example.cups);
}
{
let mut v: Vec<usize> = vec![usize::MAX, 10, 4, 9, 1, 8, 2, 6, 3, 7];
for i in 10..1000000 {
v.push(i + 1);
}... | code_fim | hard | {
"lang": "rust",
"repo": "CattleProdigy/advent-of-code-2020",
"path": "/src/bin/aoc_23.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: CattleProdigy/advent-of-code-2020 path: /src/bin/aoc_23.rs
struct Cups1 {
cups: [usize; 9],
current_cup_idx: usize,
}
fn wrap(mut x: i64) -> i64 {
x = (x - 1) % 9;
if x < 0 {
10 + x
} else {
1 + x
}
}
impl Cups1 {
fn round(&mut self) {
let pu... | code_fim | hard | {
"lang": "rust",
"repo": "CattleProdigy/advent-of-code-2020",
"path": "/src/bin/aoc_23.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> {
let mut example = Cups1 {
cups: [3, 8, 9, 1, 2, 5, 4, 6, 7],
current_cup_idx: 0,
};
for _ in 0..10 {
println!("{:?}", example.cups);
example.round();
}
println!("{:?}", example.cups);
}
{
let mut... | code_fim | hard | {
"lang": "rust",
"repo": "CattleProdigy/advent-of-code-2020",
"path": "/src/bin/aoc_23.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: christopherjmedlin/hackman path: /src/cpu/mod.rs
}
// SET y, r[z]
3 => {
if z == 6 {
let val = memory.read_byte(self.reg.hl() + d);
memory.write_byte(val | (1 << y), self.reg.hl() + d);
} else if e... | code_fim | hard | {
"lang": "rust",
"repo": "christopherjmedlin/hackman",
"path": "/src/cpu/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: christopherjmedlin/hackman path: /src/cpu/mod.rs
let mut cycles = 0;
for i in 0..iters {
let opcode = memory.read_byte(self.reg.pc);
cycles += self.run_opcode(opcode, memory, io, false);
}
cycles
}
// mostly for debugging purposes... | code_fim | hard | {
"lang": "rust",
"repo": "christopherjmedlin/hackman",
"path": "/src/cpu/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.reg.b != 0 {
io.output(self.reg.c, mem.read_byte(self.reg.hl()));
let tmp = self.reg.hl();
self.reg.write_hl(tmp + 1);
self.reg.b -= 1;
}
}
// OUTDR
(... | code_fim | hard | {
"lang": "rust",
"repo": "christopherjmedlin/hackman",
"path": "/src/cpu/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: heidsoft/heidsoft-rust path: /hello_world/src/strings.rs
/// 字符串测试
pub fn run(){
let mut hello = String::from("Hello ");
<|fim_suffix|> // Check if empty
println!("Is Empty: {}", hello.is_empty());
// 包含
println!("Contains 'World' {} ", hello.contains("World"));
// 替换
... | code_fim | hard | {
"lang": "rust",
"repo": "heidsoft/heidsoft-rust",
"path": "/hello_world/src/strings.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // 替换
println!("Replace: {} ", hello.replace("World", "There"));
println!("{}", hello);
}<|fim_prefix|>// repo: heidsoft/heidsoft-rust path: /hello_world/src/strings.rs
/// 字符串测试
pub fn run(){
let mut hello = String::from("Hello ");
// Get length
println!("Length: {} ", hello.len... | code_fim | hard | {
"lang": "rust",
"repo": "heidsoft/heidsoft-rust",
"path": "/hello_world/src/strings.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // 包含
println!("Contains 'World' {} ", hello.contains("World"));
// 替换
println!("Replace: {} ", hello.replace("World", "There"));
println!("{}", hello);
}<|fim_prefix|>// repo: heidsoft/heidsoft-rust path: /hello_world/src/strings.rs
/// 字符串测试
pub fn run(){
let mut hello = String... | code_fim | hard | {
"lang": "rust",
"repo": "heidsoft/heidsoft-rust",
"path": "/hello_world/src/strings.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-datetime/zoneinfo-data path: /src/data/EST.rs
// ------
// This file is autogenerated!
// Any changes you make may be overwritten.
// ------
<|fim_suffix|>pub static ZONE: StaticTimeZone<'static> = StaticTimeZone {
name: "EST",
fixed_timespans: FixedTimespanSet {
first: F... | code_fim | medium | {
"lang": "rust",
"repo": "rust-datetime/zoneinfo-data",
"path": "/src/data/EST.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub static ZONE: StaticTimeZone<'static> = StaticTimeZone {
name: "EST",
fixed_timespans: FixedTimespanSet {
first: FixedTimespan {
offset: -18000, // UTC offset -18000, DST offset 0
is_dst: false,
name: Cow::Borrowed("EST"),
},
rest: ... | code_fim | medium | {
"lang": "rust",
"repo": "rust-datetime/zoneinfo-data",
"path": "/src/data/EST.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: procuteboy/inko path: /compiler/src/macros.rs
#![macro_use]
/// Creates a new HashMap
///
/// Example:
///
/// let hash = hash_map!(key => value);
///
macro_rules! hash_map {
( $($key: expr => $value: expr),+ ) => ({
let mut map = $crate::std::collections::HashMap::new();
<|fim... | code_fim | easy | {
"lang": "rust",
"repo": "procuteboy/inko",
"path": "/compiler/src/macros.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> $(set.insert($value);)+
set
});
}<|fim_prefix|>// repo: procuteboy/inko path: /compiler/src/macros.rs
#![macro_use]
/// Creates a new HashMap
///
/// Example:
///
/// let hash = hash_map!(key => value);
///
macro_rules! hash_map {
( $($key: expr => $value: expr),+ ) => ({
... | code_fim | medium | {
"lang": "rust",
"repo": "procuteboy/inko",
"path": "/compiler/src/macros.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let program = vec![
3, 15, 3, 16, 1002, 16, 10, 16, 1, 16, 15, 15, 4, 15, 99, 0, 0,
];
let phase_sequence = [
PhaseSetting::Four,
PhaseSetting::Three,
PhaseSetting::Two,
PhaseSetting::One,
PhaseSetting::Zero,
... | code_fim | hard | {
"lang": "rust",
"repo": "amy-keibler/advent-of-code-2019",
"path": "/src/bin/day-seven.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: amy-keibler/advent-of-code-2019 path: /src/bin/day-seven.rs
use anyhow::anyhow;
use std::collections::VecDeque;
use advent_of_code::intcode_computer::IntcodeComputer;
use advent_of_code::permutations::PermutationsIterator;
fn main() {
let puzzle_input = include_str!("../../data/day-seven-... | code_fim | hard | {
"lang": "rust",
"repo": "amy-keibler/advent-of-code-2019",
"path": "/src/bin/day-seven.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let program = vec![
3, 23, 3, 24, 1002, 24, 10, 24, 1002, 23, -1, 23, 101, 5, 23, 23, 1, 24, 23, 23, 4, 23,
99, 0, 0,
];
let phase_sequence = [
PhaseSetting::Zero,
PhaseSetting::One,
PhaseSetting::Two,
PhaseSet... | code_fim | hard | {
"lang": "rust",
"repo": "amy-keibler/advent-of-code-2019",
"path": "/src/bin/day-seven.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Nitrokey/nitrokey-3-firmware path: /runners/embedded/src/traits/rgb_led.rs
#[derive(Copy, Clone, Debug, PartialEq)]
pub struct Intensities {
pub red: u8,
pub green: u8,
pub blue: u8,
}
#[derive(Copy, Clone, Debug, PartialEq)]
pub enum Color {
Red,
Green,
Blue,
}
impl Fr... | code_fim | medium | {
"lang": "rust",
"repo": "Nitrokey/nitrokey-3-firmware",
"path": "/runners/embedded/src/traits/rgb_led.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Set the intensity for the red LED. 0 turns off the LED.
fn red(&mut self, intensity: u8);
/// Set the intensity for the green LED.
fn green(&mut self, intensity: u8);
/// Set the intensity for the blue LED.
fn blue(&mut self, intensity: u8);
}<|fim_prefix|>// repo: Nitrokey/... | code_fim | hard | {
"lang": "rust",
"repo": "Nitrokey/nitrokey-3-firmware",
"path": "/runners/embedded/src/traits/rgb_led.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Dreistein/novusk path: /drivers/nkuefi/src/boot.rs
use core::fmt::Write;
use crate::kernel;
use uefi::{Handle, ResultExt};
use uefi::table::{Boot, SystemTable};
<|fim_suffix|> system_table.stdout().reset(false)
.expect_success("Couldn't reset display");
writeln!(system_table.std... | code_fim | medium | {
"lang": "rust",
"repo": "Dreistein/novusk",
"path": "/drivers/nkuefi/src/boot.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> writeln!(system_table.stdout(), "{}", "Starting kernel...");
kernel::start_novusk();
}<|fim_prefix|>// repo: Dreistein/novusk path: /drivers/nkuefi/src/boot.rs
use core::fmt::Write;
use crate::kernel;
use uefi::{Handle, ResultExt};
use uefi::table::{Boot, SystemTable};
#[no_mangle]
pub unsafe e... | code_fim | medium | {
"lang": "rust",
"repo": "Dreistein/novusk",
"path": "/drivers/nkuefi/src/boot.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn handler(ctx: Context<CreateCollection>, name: String) -> ProgramResult {
msg!("Create collection");
ctx.accounts.collection.name = vectorize_string(name, 32);
ctx.accounts.collection.authority = ctx.accounts.authority.key();
ctx.accounts.collection.application = ctx.accounts.application.key... | code_fim | hard | {
"lang": "rust",
"repo": "carlomigueldy/platform",
"path": "/apps/bulldozer-programs/programs/bulldozer/src/instructions/create_collection.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: corka149/player-service path: /src/player/persistence.rs
use super::model::Player;
use diesel::prelude::*;
// Database
use super::super::database::*;
pub fn get_player_by_id(player_id: i32) -> Option<Player> {
use super::super::schema::players::dsl::*;
<|fim_suffix|> let results = play... | code_fim | medium | {
"lang": "rust",
"repo": "corka149/player-service",
"path": "/src/player/persistence.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut result: Option<Player> = None;
let connection = establish_connection();
let results = players
.filter(id.eq(player_id))
.limit(1)
.load::<Player>(&connection)
.expect("Error loading player");
for player in results {
result = Some(player);
... | code_fim | medium | {
"lang": "rust",
"repo": "corka149/player-service",
"path": "/src/player/persistence.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let results = players
.filter(id.eq(player_id))
.limit(1)
.load::<Player>(&connection)
.expect("Error loading player");
for player in results {
result = Some(player);
}
result
}<|fim_prefix|>// repo: corka149/player-service path: /src/player/persis... | code_fim | medium | {
"lang": "rust",
"repo": "corka149/player-service",
"path": "/src/player/persistence.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: magurotuna/kuon path: /src/constants.rs
pub use percent_encoding::{AsciiSet, CONTROLS, N<|fim_suffix|>remove(b'-')
.remove(b'.')
.remove(b'_');<|fim_middle|>ON_ALPHANUMERIC};
pub(crate) const FRAGMENT: AsciiSet = NON_ALPHANUMERIC
.remove(b'*')
. | code_fim | medium | {
"lang": "rust",
"repo": "magurotuna/kuon",
"path": "/src/constants.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>remove(b'-')
.remove(b'.')
.remove(b'_');<|fim_prefix|>// repo: magurotuna/kuon path: /src/constants.rs
pub use percent_encoding::{AsciiSet, CONTROLS, NON_ALPHANUMERIC};
pub(crate) const FRAGMENT: Asc<|fim_middle|>iiSet = NON_ALPHANUMERIC
.remove(b'*')
. | code_fim | easy | {
"lang": "rust",
"repo": "magurotuna/kuon",
"path": "/src/constants.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub mod prelude {
pub use super::cgmath::{Angle, ApproxEq, Deg, Rad};
pub use super::clamp::*;
pub use super::color::*;
pub use super::mat::*;
pub use super::model::ray::*;
pub use super::real::*;
pub use super::sample::*;
}
pub use self::prelude::*;<|fim_prefix|>// repo: AirG... | code_fim | hard | {
"lang": "rust",
"repo": "AirGuanZ/rust_painter",
"path": "/03_ol_renderer/src/math/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub trait Clamp<T> {
fn clamp(&self, min_v: T, max_v: T) -> Self;
}
impl Clamp<Real> for Real {
fn clamp(&self, min_v: Real, max_v: Real) -> Self {
self.max(min_v).min(max_v)
}
}
}
pub mod prelude {
pub use super::cgmath::{Angle, ApproxEq, Deg, Rad... | code_fim | medium | {
"lang": "rust",
"repo": "AirGuanZ/rust_painter",
"path": "/03_ol_renderer/src/math/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AirGuanZ/rust_painter path: /03_ol_renderer/src/math/mod.rs
//! Commonly used math tools: matrix, vector, color, ray, ...
extern crate cgmath;
pub mod color;
pub mod mat;
pub mod model;
pub mod sample;
pub mod real {
extern crate std;
pub type Real = f64;
<|fim_suffix|> s... | code_fim | hard | {
"lang": "rust",
"repo": "AirGuanZ/rust_painter",
"path": "/03_ol_renderer/src/math/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
)
;
}
}
}
;
(
value
:
ident
conditionally
in
start
:
expr
=
>
end
:
expr
)
=
>
{
{
let
_start
=
start
;
let
_end
=
end
;
#
[
allow
(
trivial_numeric_casts
unused_comparisons
)
]
if
value
<
_start
|
|
value
>
_end
{
return
Err
(
crate
:
:
error
:
:
ComponentRange
{
name
:
stringify
!
(
value
)
minimum
:
_... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/time/src/lib.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>nused_qualifications
)
]
(
#
[
attr
]
)
*
impl
core
:
:
ops
:
:
op
<
t
>
for
target
{
fn
fn
(
&
mut
self
rhs
:
t
)
{
*
self
=
*
self
sym
rhs
;
}
}
)
+
}
;
}
/
/
/
Implement
AddAssign
for
the
provided
types
.
macro_rules
!
impl_add_assign
{
(
target
:
ty
:
(
(
#
[
attr
:
meta
]
)
*
t
:
ty
)
+
(
)
?
)
=
>
{... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/time/src/lib.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/time/src/lib.rs
/
/
!
#
Feature
flags
/
/
!
/
/
!
This
crate
exposes
a
number
of
features
.
These
can
be
enabled
or
disabled
as
shown
/
/
!
[
in
Cargo
'
s
documentation
]
(
https
:
/
/
doc
.
rust
-
lang
.
org
/
cargo
/
reference
/
features
.
ht... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/time/src/lib.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.