text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: segfo/yarust path: /build.rs
use std::process::Command;
use std::env;
use std::path::Path;
fn main() {
let out_dir = env::var("OUT_DIR").unwrap();
// note that there are a number of downsides to this approach, the comments
// below detail how to improve the portability of these com... | code_fim | hard | {
"lang": "rust",
"repo": "segfo/yarust",
"path": "/build.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/RVM1.5 path: /src/cell.rs
use spin::RwLock;
use crate::arch::{HostPageTable, HvPageTable};
use crate::config::{CellConfig, HvSystemConfig};
use crate::consts::{HV_BASE, PER_CPU_SIZE};
use crate::error::HvResult;
use crate::header::HvHeader;
use crate::memory::{
addr::phys_to_virt, G... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/RVM1.5",
"path": "/src/cell.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Init guest physical memory set, create hypervisor page table.
//
// hypervisor
gpm.insert(MemoryRegion::new_with_empty_mapper(
hv_phys_start,
hv_phys_size,
MemFlags::READ | MemFlags::NO_HUGEPAGES,
))?;
// all physical m... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/RVM1.5",
"path": "/src/cell.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> const INPUT: &str = "abc\ndef\n ";
let mut chunks = INPUT.lines().chunks(|line: &&str| !line.trim().is_empty());
let mut chunk = chunks.next().unwrap();
assert_eq!(chunk.next().unwrap(), "abc");
assert_eq!(chunk.next().unwrap(), "def");
assert!(chunk.next... | code_fim | hard | {
"lang": "rust",
"repo": "ForgottenMaster/aoc-2020",
"path": "/src/iter/chunks.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ForgottenMaster/aoc-2020 path: /src/iter/chunks.rs
use std::iter::{Peekable, TakeWhile};
pub struct Chunks<I: Iterator, P> {
iter: Peekable<I>,
predicate: P,
}
impl<I: Iterator + Clone, P: Clone> Clone for Chunks<I, P>
where
<I as Iterator>::Item: Clone,
{
fn clone(&self) -> Se... | code_fim | hard | {
"lang": "rust",
"repo": "ForgottenMaster/aoc-2020",
"path": "/src/iter/chunks.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_two_chunks() {
const INPUT: &str = "abc\ndef\n\nhi";
let mut chunks = INPUT.lines().chunks(|line: &&str| !line.trim().is_empty());
let mut chunk = chunks.next().unwrap();
assert_eq!(chunk.next().unwrap(), "abc");
assert_eq!(chunk.next().unwra... | code_fim | hard | {
"lang": "rust",
"repo": "ForgottenMaster/aoc-2020",
"path": "/src/iter/chunks.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut sum = 0;
for i in 1..101 {
for j in (i + 1)..101 {
sum += 2 * i * j;
}
}
println!("{}", sum);
}<|fim_prefix|>// repo: susisu/ProjectEuler path: /rust/006/main.rs
/*
ProjectEuler 006
Rust / main.rs
copyright (c) 2015 Susisu
<|fim_middle|> ... | code_fim | medium | {
"lang": "rust",
"repo": "susisu/ProjectEuler",
"path": "/rust/006/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: susisu/ProjectEuler path: /rust/006/main.rs
/*
ProjectEuler 006
Rust / main.rs
copyright (c) 2015 Susisu
<|fim_suffix|>fn main() {
let mut sum = 0;
for i in 1..101 {
for j in (i + 1)..101 {
sum += 2 * i * j;
}
}
println!("{}", sum);
}<|fim... | code_fim | easy | {
"lang": "rust",
"repo": "susisu/ProjectEuler",
"path": "/rust/006/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> test_pass!(r"snippet foo() {} snippet bar() {}",
test_def_use_connections_empty);
test_pass!(r"snippet foo() {output c : bit<2>;} snippet fun() { input d : bit<2>;} (foo, fun):c->d,",
test_def_use_connections);
test_pass!(r"snippet foo() {output c : bit<2>[1];} snippet fu... | code_fim | hard | {
"lang": "rust",
"repo": "sluice-project/sluice",
"path": "/src/def_use.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sluice-project/sluice path: /src/def_use.rs
t);
} else {
let var_type = &tree.var_type;
let var_state = VarState::Declared ;
self.packet_table.get_mut(self.current_packet).unwrap().insert(id_name, VariableMetadata{var_type, var_state});
}
} else {
p... | code_fim | hard | {
"lang": "rust",
"repo": "sluice-project/sluice",
"path": "/src/def_use.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sluice-project/sluice path: /src/def_use.rs
VarType { self.var_type }
}
pub struct DefUse<'a> {
current_snippet : &'a str,
current_packet : &'a str,
symbol_table : HashMap<&'a str, HashMap<&'a str, VariableMetadata<'a>>>,
global_table : HashMap<&'a str, VariableMetadata<'a>>,
p... | code_fim | hard | {
"lang": "rust",
"repo": "sluice-project/sluice",
"path": "/src/def_use.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// // impl<'a> Drop for UsartDriver<'a> {
// // fn drop(&mut self) {
// // if let Some(irq_num) = self.irq_num {
// // nvic::set_enabled(irq_num as usize, false);
// // SCB.set_irq_handler(irq_num as usize, None);
// // }
// // }
// // }
// // impl<'a> Poll... | code_fim | hard | {
"lang": "rust",
"repo": "bobbin-rs/bobbin-sdk",
"path": "/mcu/bobbin-stm32/stm32wb55xx/src/ext/usart.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bobbin-rs/bobbin-sdk path: /mcu/bobbin-stm32/stm32wb55xx/src/ext/usart.rs
use bobbin_hal::configure::*;
use bobbin_hal::enabled::*;
use bobbin_hal::serial::*;
use usart::*;
use core::fmt::{self, Write};
#[derive(Debug)]
pub struct Config {
cr1: Cr1,
cr2: Cr2,
cr3: Cr3,
brr: Br... | code_fim | hard | {
"lang": "rust",
"repo": "bobbin-rs/bobbin-sdk",
"path": "/mcu/bobbin-stm32/stm32wb55xx/src/ext/usart.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: evgenykuzyakov/berryfarm path: /contract-rs/berry-farm/src/ft_meta.rs
use crate::*;
use near_contract_standards::fungible_token::metadata::{
FungibleTokenMetadata, FungibleTokenMetadataProvider, FT_METADATA_SPEC,
};
<|fim_suffix|>#[near_bindgen]
impl FungibleTokenMetadataProvider for Farm {... | code_fim | hard | {
"lang": "rust",
"repo": "evgenykuzyakov/berryfarm",
"path": "/contract-rs/berry-farm/src/ft_meta.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[near_bindgen]
impl FungibleTokenMetadataProvider for Farm {
fn ft_metadata(&self) -> FungibleTokenMetadata {
FungibleTokenMetadata {
spec: FT_METADATA_SPEC.to_string(),
name: String::from("Cucumber"),
symbol: String::from("CUCUMBER"),
icon: Som... | code_fim | hard | {
"lang": "rust",
"repo": "evgenykuzyakov/berryfarm",
"path": "/contract-rs/berry-farm/src/ft_meta.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
input! {
q: usize,
l: usize,
}
let mut stack = vec![];
let mut size = 0;
for _ in 0..q {
input! {
query: String,
}
match &*query {
"Push" => {
input! {
n: usize,
... | code_fim | hard | {
"lang": "rust",
"repo": "likr/atcoder",
"path": "/tenka1-2013-qualb/src/bin/b.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> input! {
q: usize,
l: usize,
}
let mut stack = vec![];
let mut size = 0;
for _ in 0..q {
input! {
query: String,
}
match &*query {
"Push" => {
input! {
n: usize,
m: i... | code_fim | hard | {
"lang": "rust",
"repo": "likr/atcoder",
"path": "/tenka1-2013-qualb/src/bin/b.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: likr/atcoder path: /tenka1-2013-qualb/src/bin/b.rs
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;
<|fim_suffix|> input! {
... | code_fim | hard | {
"lang": "rust",
"repo": "likr/atcoder",
"path": "/tenka1-2013-qualb/src/bin/b.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Clone)]
pub struct IR {
pub op: IROp,
pub lhs: Option<usize>,
pub rhs: Option<usize>,
}
pub fn gen_ir(nodes: Vec<Node>) -> Vec<Function> {
let mut ir_nodes = vec![];
ir_nodes;
}<|fim_prefix|>// repo: ryanmcdermott/really-simple-c path: /iterations/01_integer/ir_genera... | code_fim | medium | {
"lang": "rust",
"repo": "ryanmcdermott/really-simple-c",
"path": "/iterations/01_integer/ir_generator.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn gen_ir(nodes: Vec<Node>) -> Vec<Function> {
let mut ir_nodes = vec![];
ir_nodes;
}<|fim_prefix|>// repo: ryanmcdermott/really-simple-c path: /iterations/01_integer/ir_generator.rs
#[derive(Debug, Clone, PartialEq)]
pub enum IROp {
Mov,
Return,
}
#[derive(Clone, Debug)]
pub struct ... | code_fim | medium | {
"lang": "rust",
"repo": "ryanmcdermott/really-simple-c",
"path": "/iterations/01_integer/ir_generator.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ryanmcdermott/really-simple-c path: /iterations/01_integer/ir_generator.rs
#[derive(Debug, Clone, PartialEq)]
pub enum IROp {
Mov,
Return,
}
<|fim_suffix|>#[derive(Debug, Clone)]
pub struct IR {
pub op: IROp,
pub lhs: Option<usize>,
pub rhs: Option<usize>,
}
pub fn gen_ir(n... | code_fim | medium | {
"lang": "rust",
"repo": "ryanmcdermott/really-simple-c",
"path": "/iterations/01_integer/ir_generator.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(not(feature = "host"))]
mod device;<|fim_prefix|>// repo: fossabot/rust-cuda path: /rust-cuda-ptx-jit/src/lib.rs
#![deny(clippy::pedantic)]
#![cfg_attr(not(feature = "host"), no_std)]
<|fim_middle|>#[cfg(feature = "host")]
pub mod host;
| code_fim | easy | {
"lang": "rust",
"repo": "fossabot/rust-cuda",
"path": "/rust-cuda-ptx-jit/src/lib.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fossabot/rust-cuda path: /rust-cuda-ptx-jit/src/lib.rs
#![deny(clippy::pedantic)]
#![cfg_attr(not(feature = "host"), no_std)]
<|fim_suffix|>#[cfg(not(feature = "host"))]
mod device;<|fim_middle|>#[cfg(feature = "host")]
pub mod host;
| code_fim | easy | {
"lang": "rust",
"repo": "fossabot/rust-cuda",
"path": "/rust-cuda-ptx-jit/src/lib.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-datetime/zoneinfo-data path: /src/data/America/Adak.rs
3600
is_dst: true,
name: Cow::Borrowed("HDT"),
}),
(2172740400, FixedTimespan { // 2038-11-07T11:00:00.000 UTC
offset: -36000, // UTC offset -36000, DST offset 0
is_dst... | code_fim | hard | {
"lang": "rust",
"repo": "rust-datetime/zoneinfo-data",
"path": "/src/data/America/Adak.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-datetime/zoneinfo-data path: /src/data/America/Adak.rs
:00:00.000 UTC
offset: -36000, // UTC offset -36000, DST offset 0
is_dst: false,
name: Cow::Borrowed("HST"),
}),
(1173614400, FixedTimespan { // 2007-03-11T12:00:00.000 UTC
... | code_fim | hard | {
"lang": "rust",
"repo": "rust-datetime/zoneinfo-data",
"path": "/src/data/America/Adak.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> offset: -32400, // UTC offset -36000, DST offset 3600
is_dst: true,
name: Cow::Borrowed("HDT"),
}),
(1320577200, FixedTimespan { // 2011-11-06T11:00:00.000 UTC
offset: -36000, // UTC offset -36000, DST offset 0
is_dst: false,
... | code_fim | hard | {
"lang": "rust",
"repo": "rust-datetime/zoneinfo-data",
"path": "/src/data/America/Adak.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: theanirudhvyas/boron path: /src/matcher.rs
use regex::{Captures, Regex};
pub struct Matcher {
pattern: Regex
}
impl Matcher {
pub fn new(pattern: &str) -> Matcher {
Matcher { pattern: Regex::new(format!("^{}$", pattern).as_str()).unwrap() }
}
pub fn is_match(&self, tex... | code_fim | hard | {
"lang": "rust",
"repo": "theanirudhvyas/boron",
"path": "/src/matcher.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn test_url_pattern_match() {
let m = Matcher::new(r"/abc/\d*/hello");
assert!(m.is_match("/abc/1/hello"));
assert!(m.is_match("/abc/23/hello"));
assert_eq!(m.is_match("/abc/1/hello/lol"), false);
}
#[test]
fn test_url_pattern_match_typesafe() {
let m = Matcher::new(r"/abc/\d*... | code_fim | medium | {
"lang": "rust",
"repo": "theanirudhvyas/boron",
"path": "/src/matcher.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: davnav/ftdnomparser path: /src/parser.rs
use nom::IResult;
use nom::branch::alt;
use nom::bytes::complete::{tag, take_until, take_while};
use nom::character::complete::{alpha0, alpha1, alphanumeric1, crlf, digit0, digit1, line_ending, multispace0, multispace1, newline, space1};
use nom::combina... | code_fim | hard | {
"lang": "rust",
"repo": "davnav/ftdnomparser",
"path": "/src/parser.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn recparser(input:&str) -> IResult<&str,Record<&str>>{
let (input,_) = multispace1(input)?;
let (input,_) = tag("record")(input)?;
let (input,_) = multispace1(input)?;
let (input,recordname) = alphanumeric1(input)?;
let (input,_) = take_until(":")(input)?;
let (input,... | code_fim | hard | {
"lang": "rust",
"repo": "davnav/ftdnomparser",
"path": "/src/parser.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Northn/monet-rs path: /src/colors/oklab.rs
use crate::colors::color::Color;
use crate::colors::linearsrgb::LinearSrgb;
//use crate::colors::ciexyz::CieXyz;
use crate::colors::oklch::Oklch;
//use crate::colors::saturation_coefficients::SaturationCoefficients;
pub struct Oklab {
pub l: f64,
... | code_fim | hard | {
"lang": "rust",
"repo": "Northn/monet-rs",
"path": "/src/colors/oklab.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// let l0 = match method {
// ClipMethod::PreserveLightness => coerce_in(l, 0.0, 1.0),
// ClipMethod::AdaptiveTowardsLcusp=> {
// let ld = l - cusp.l;
// let _k = if ld > 0.0 {
// 1.0 - cusp.l
// } else ... | code_fim | hard | {
"lang": "rust",
"repo": "Northn/monet-rs",
"path": "/src/colors/oklab.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// fn find_cusp(a: f64, b: f64) -> LC {
// let s_cusp = Oklab::compute_max_saturation(a, b);
// let rgb_at_max = Oklab {
// l: 1.0,
// a: s_cusp * a,
// b: s_cusp * b
// }.to_linearsrgb();
// let l_cusp = (1.0 / rgb_at_max.b.max(rgb_... | code_fim | hard | {
"lang": "rust",
"repo": "Northn/monet-rs",
"path": "/src/colors/oklab.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RSSchermer/ARWA path: /arwa/src/execution/execution_event_target.rs
use crate::event::typed_event_iterator;
use crate::execution::{ErrorEvent, RejectionHandledEvent, UnhandledRejectionEvent};
pub(crate) mod execution_event_target_seal {
pub trait Seal {
#[doc(hidden)]
fn as_... | code_fim | medium | {
"lang": "rust",
"repo": "RSSchermer/ARWA",
"path": "/arwa/src/execution/execution_event_target.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>typed_event_iterator!(OnError, OnErrorWithOptions, ErrorEvent, "error");
typed_event_iterator!(
OnRejectionHandled,
OnRejectionHandledWithOptions,
RejectionHandledEvent,
"rejectionhandled"
);
typed_event_iterator!(
OnUnhandledRejection,
OnUnhandledRejectionWithOptions,
Unhandle... | code_fim | hard | {
"lang": "rust",
"repo": "RSSchermer/ARWA",
"path": "/arwa/src/execution/execution_event_target.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dcchut/dcc-scryfall path: /tests/deserialize_card_list.rs
use dcc_scryfall::{Card, List};
#[test]
pub fn deserialize_card_list() {
let json = r#"{
"object": "list",
"total_cards": 1,
"has_more": false,
"data": [
{
"object": "card",
"id": "0104b5b3-9376-4ad7-9a77-3e56... | code_fim | hard | {
"lang": "rust",
"repo": "dcchut/dcc-scryfall",
"path": "/tests/deserialize_card_list.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>rd/Details.aspx?multiverseid=439787",
"tcgplayer_decks": "https://decks.tcgplayer.com/magic/deck/search?contains=Ghalta%2C+Primal+Hunger&page=1&partner=Scryfall&utm_campaign=affiliate&utm_medium=scryfall&utm_source=scryfall",
"edhrec": "https://edhrec.com/route/?cc=Ghalta%2C+Primal+Hunger"... | code_fim | hard | {
"lang": "rust",
"repo": "dcchut/dcc-scryfall",
"path": "/tests/deserialize_card_list.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vedangj044/drogue-cloud path: /operator-common/src/controller/base/conditions.rs
use crate::controller::{base::CONDITION_RECONCILED, reconciler::ReconcileError};
use drogue_client::{
core::v1::{ConditionStatus, Conditions},
registry::v1::KafkaAppStatus,
Dialect, Translator,
};
use se... | code_fim | hard | {
"lang": "rust",
"repo": "vedangj044/drogue-cloud",
"path": "/operator-common/src/controller/base/conditions.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // update the global conditions sections
let ready_state = if waiting.is_empty() {
ConditionStatus {
status: Some(true),
..Default::default()
}
} else {
let message = format!("Waiting to become ready: {}", waiting... | code_fim | hard | {
"lang": "rust",
"repo": "vedangj044/drogue-cloud",
"path": "/operator-common/src/controller/base/conditions.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut input: [u32; 6] = [0, 1, 2, 3, 4, 5];
bubble_sort(&mut input, SortMethod::Asc);
for i in 5..=0 {
assert_eq!(5, input[input.len() - i]);
}
}
#[test]
fn test_sort_asc_with_duplicate_items() {
let mut input: [u32; 8] = [5, 4, 3, 4, 2, 1... | code_fim | hard | {
"lang": "rust",
"repo": "XinyueZ/rust-lambda",
"path": "/sort/src/core.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: XinyueZ/rust-lambda path: /sort/src/core.rs
pub enum SortMethod {
Asc,
Desc,
}
pub fn bubble_sort(slice: &mut [u32], method: SortMethod) {
if slice.is_empty() {
return;
}
let mut count = 0;
while count < slice.len() - 1 {
let mut index = 0;
while... | code_fim | hard | {
"lang": "rust",
"repo": "XinyueZ/rust-lambda",
"path": "/sort/src/core.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let res = self.data.find(i);
Ok(res)
}
}
/// This module is a python module implemented in Rust.
#[pymodule]
fn union_find_py(py: Python, m: &PyModule) -> PyResult<()> {
m.add_class::<UFForPython>()?;
Ok(())
}<|fim_prefix|>// repo: Yamp/home_lab path: /langs/rust/pyo3_test/s... | code_fim | hard | {
"lang": "rust",
"repo": "Yamp/home_lab",
"path": "/langs/rust/pyo3_test/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// This module is a python module implemented in Rust.
#[pymodule]
fn union_find_py(py: Python, m: &PyModule) -> PyResult<()> {
m.add_class::<UFForPython>()?;
Ok(())
}<|fim_prefix|>// repo: Yamp/home_lab path: /langs/rust/pyo3_test/src/lib.rs
extern crate disjoint_sets;
use disjoint_sets::Unio... | code_fim | medium | {
"lang": "rust",
"repo": "Yamp/home_lab",
"path": "/langs/rust/pyo3_test/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Yamp/home_lab path: /langs/rust/pyo3_test/src/lib.rs
extern crate disjoint_sets;
use disjoint_sets::UnionFind;
use pyo3::prelude::*;
use pyo3::wrap_pyfunction;
#[pyclass(module="union_find_py")]
struct UFForPython {
data: UnionFind
}
#[pymethods]
impl UFForPython {
#[new]
fn new(... | code_fim | medium | {
"lang": "rust",
"repo": "Yamp/home_lab",
"path": "/langs/rust/pyo3_test/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: foxfriends/paper-wars-server path: /src/schema/query/email.rs
use super::{Context, OperationResult, QueryWrapper};
use anyhow::anyhow;
use chrono::{DateTime, Utc};
use diesel_citext::types::CiString;
use juniper::FieldResult;
pub struct Email {
address: CiString,
}
impl QueryWrapper for Em... | code_fim | hard | {
"lang": "rust",
"repo": "foxfriends/paper-wars-server",
"path": "/src/schema/query/email.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(self.load(context)?.protected_until)
}
/// When this email was created.
fn created_at(&self, context: &Context) -> FieldResult<DateTime<Utc>> {
Ok(self.load(context)?.created_at)
}
/// Whether this is the primary (login and contact) email address for this account.
... | code_fim | medium | {
"lang": "rust",
"repo": "foxfriends/paper-wars-server",
"path": "/src/schema/query/email.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.parent_indexes[x] == x {
return x;
}
let parent = self.parent_indexes[x];
let root = self.find_root_and_compress_path(parent);
self.parent_indexes[x] = root;
self.depths[x] = 0;
return root;
}
fn union(&mut self, x: usize... | code_fim | hard | {
"lang": "rust",
"repo": "apragacz/aoc-2018",
"path": "/day25/constellation.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: apragacz/aoc-2018 path: /day25/constellation.rs
use std::cmp;
use std::io;
use std::io::BufRead;
use std::collections::HashSet;
use std::str::FromStr;
#[derive(Debug, Clone)]
enum ParsePointError{
InvalidFormat(String),
InvalidNumber(String),
}
#[derive(Debug, Clone)]
struct Point {
... | code_fim | hard | {
"lang": "rust",
"repo": "apragacz/aoc-2018",
"path": "/day25/constellation.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> GraphicsPacket::Update(GraphicsUpdate {
bg_args: bg_args,
effect_args: effect_args,
time: data.time
})
}
AudioPacket::Refresh(new_structs) => {
bg_mapper = new_structs.bg_map... | code_fim | hard | {
"lang": "rust",
"repo": "danslocombe/music-visualizer",
"path": "/src/mapper.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: danslocombe/music-visualizer path: /src/mapper.rs
use std::sync::mpsc::{Receiver, Sender};
use common::*;
use expression::Expr;
// used to map inputs to a single graphic object
pub struct Mapper {
pub input_audio: Vec<(Expr, GArg)>,
}
impl Mapper {
pub fn new(input_audio: Vec<(Expr, ... | code_fim | hard | {
"lang": "rust",
"repo": "danslocombe/music-visualizer",
"path": "/src/mapper.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn error (&self, msg:impl Message) { println!("[ERROR] {}",self.format(msg)) }
fn group_begin (&self, msg:impl Message) { println!("{}",self.format(msg)); self.inc_indent() }
fn group_end (&self) { self.dec_indent() }
fn trace_copies(&self) { sel... | code_fim | hard | {
"lang": "rust",
"repo": "npentrel/rust-lib",
"path": "/src/logger/src/enabled.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn trace_copies(&self) { self.trace_copies.enable(&self.path) }
}
#[cfg(target_arch="wasm32")]
impl AnyLogger for Logger {
type Owned = Self;
fn new(path:impl Into<ImString>) -> Self {
let path = path.into();
let trace_copies = default();
Sel... | code_fim | hard | {
"lang": "rust",
"repo": "npentrel/rust-lib",
"path": "/src/logger/src/enabled.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: npentrel/rust-lib path: /src/logger/src/enabled.rs
//! Contains implementation of default logger.
use enso_prelude::*;
use crate::AnyLogger;
use crate::Message;
use enso_shapely::CloneRef;
use std::fmt::Debug;
#[cfg(target_arch = "wasm32")]
use web_sys::console;
#[cfg(target_arch = "wasm32")... | code_fim | hard | {
"lang": "rust",
"repo": "npentrel/rust-lib",
"path": "/src/logger/src/enabled.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> where E: std::fmt::Debug;
fn ignore(self);
}
impl<T, E> ResultExt<T, E> for Result<T, E> {
#[inline]
fn report_with(self, msg: &str)
where E: std::fmt::Debug {
if let Err(e) = self {
println!("{}: {:?}", msg, e);
};
}
#[inline]
fn report(self)
where E: std::fmt::Debug {
... | code_fim | medium | {
"lang": "rust",
"repo": "ScottyThePilot/a3f_sentinel",
"path": "/src/util.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[inline]
fn report(self)
where E: std::fmt::Debug {
if let Err(e) = self {
println!("{:?}", e);
};
}
#[inline]
fn ignore(self) {}
}<|fim_prefix|>// repo: ScottyThePilot/a3f_sentinel path: /src/util.rs
pub trait ResultExt<T, E> {
fn report_with(self, msg: &str)
where E: std... | code_fim | medium | {
"lang": "rust",
"repo": "ScottyThePilot/a3f_sentinel",
"path": "/src/util.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ScottyThePilot/a3f_sentinel path: /src/util.rs
pub trait ResultExt<T, E> {
fn report_with(self, msg: &str)
where E: std::fmt::Debug;
fn report(self)
where E: std::fmt::Debug;
<|fim_suffix|> where E: std::fmt::Debug {
if let Err(e) = self {
println!("{:?}", e);
};
}
... | code_fim | hard | {
"lang": "rust",
"repo": "ScottyThePilot/a3f_sentinel",
"path": "/src/util.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>:exit(1);
}
for arg in std::env::args() {
println!("{}", arg);
}
}<|fim_prefix|>// repo: rcore-os-infohub/ossoc2020-VitalyAnkh-daily path: /Rust/PlayGround/process_args.rs
fn main() {
if std::env::args().any(|ar<|fim_middle|>g| arg == "--kill") {
std::process: | code_fim | easy | {
"lang": "rust",
"repo": "rcore-os-infohub/ossoc2020-VitalyAnkh-daily",
"path": "/Rust/PlayGround/process_args.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>rgs() {
println!("{}", arg);
}
}<|fim_prefix|>// repo: rcore-os-infohub/ossoc2020-VitalyAnkh-daily path: /Rust/PlayGround/process_args.rs
fn main() {
if std::env::args().any(|arg| arg == "--kill") {
std::process:<|fim_middle|>:exit(1);
}
for arg in std::env::a | code_fim | easy | {
"lang": "rust",
"repo": "rcore-os-infohub/ossoc2020-VitalyAnkh-daily",
"path": "/Rust/PlayGround/process_args.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rcore-os-infohub/ossoc2020-VitalyAnkh-daily path: /Rust/PlayGround/process_args.rs
fn main() {
if std::env::args().any(|ar<|fim_suffix|>:exit(1);
}
for arg in std::env::args() {
println!("{}", arg);
}
}<|fim_middle|>g| arg == "--kill") {
std::process: | code_fim | easy | {
"lang": "rust",
"repo": "rcore-os-infohub/ossoc2020-VitalyAnkh-daily",
"path": "/Rust/PlayGround/process_args.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub mod holiday;
pub use self::holiday::Holiday;<|fim_prefix|>// repo: camelmasa/holiday_jp-rust path: /src/lib.rs
#[macro_use]
extern crate lazy_static;
extern crate yaml_rust;
<|fim_middle|>pub mod holiday_jp;
pub use self::holiday_jp::HolidayJp;
pub mod holidays;
pub use self::holidays::Holidays;
| code_fim | medium | {
"lang": "rust",
"repo": "camelmasa/holiday_jp-rust",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: camelmasa/holiday_jp-rust path: /src/lib.rs
#[macro_use]
extern crate lazy_static;
extern crate yaml_rust;
<|fim_suffix|>pub mod holiday;
pub use self::holiday::Holiday;<|fim_middle|>pub mod holiday_jp;
pub use self::holiday_jp::HolidayJp;
pub mod holidays;
pub use self::holidays::Holidays;
| code_fim | medium | {
"lang": "rust",
"repo": "camelmasa/holiday_jp-rust",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: silky/jagger path: /src/solver/benchmarks/jnh12.rs
-37 58 -79 0
9 20 -38 0
-22 30 31 50 65 -88 -97 0
-1 36 -72 0
-15 20 37 -65 83 0
21 58 75 0
-12 18 40 54 -69 -85 -93 0
69 -73 0
-34 -41 0
-7 -12 59 73 -84 95 0
3 29 ... | code_fim | hard | {
"lang": "rust",
"repo": "silky/jagger",
"path": "/src/solver/benchmarks/jnh12.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: silky/jagger path: /src/solver/benchmarks/jnh12.rs
13 -14 -32 -72 75 -87 100 0
20 59 71 -93 0
24 51 -79 81 0
-14 69 0
-7 22 -59 -88 0
-6 26 -40 -52 81 -87 0
-20 -34 40 47 74 -78 -97 0
6 -74 82 0
-68 81 0
-19 35 50 -56 -6... | code_fim | hard | {
"lang": "rust",
"repo": "silky/jagger",
"path": "/src/solver/benchmarks/jnh12.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> -72 93 0
24 62 88 0
24 -45 53 75 81 0
-17 -36 49 -90 -97 0
81 -94 0
-4 -19 -22 -43 -55 79 80 -91 0
21 53 -58 65 92 -93 0
1 -30 33 -42 -45 -81 -86 92 93 0
24 -39 43 0
8 -9 -12 -90 95 0
-14 24 77 -99 0
11 23 ... | code_fim | hard | {
"lang": "rust",
"repo": "silky/jagger",
"path": "/src/solver/benchmarks/jnh12.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>is_everywhere;
pub mod programming_in_toyland;
mod helper;<|fim_prefix|>// repo: ekhall/computationbook-rust path: /src/lib.rs
pub mod the_meaning_of_programs;
pub mod the_simplest_comp<|fim_middle|>uters;
pub mod just_add_power;
pub mod the_ultimate_machine;
pub mod programming_with_nothing;
pub mod un... | code_fim | medium | {
"lang": "rust",
"repo": "ekhall/computationbook-rust",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ekhall/computationbook-rust path: /src/lib.rs
pub mod the_meaning_of_programs;
pub mod the_simplest_comp<|fim_suffix|>is_everywhere;
pub mod programming_in_toyland;
mod helper;<|fim_middle|>uters;
pub mod just_add_power;
pub mod the_ultimate_machine;
pub mod programming_with_nothing;
pub mod un... | code_fim | medium | {
"lang": "rust",
"repo": "ekhall/computationbook-rust",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: merehap/rustdailyprogrammer path: /263.rs
use std::collections::HashMap;
fn main() {
let texts = vec![
"122333444455555666666777777788888888",
"563881467447538846567288767728553786",
"https://www.reddit.com/r/dailyprogrammer",
"int main(int argc, char *argv[]... | code_fim | hard | {
"lang": "rust",
"repo": "merehap/rustdailyprogrammer",
"path": "/263.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> -1.0 * frequencies.iter().map(|(_, &count)| {
let text_len = text.len() as f32;
(count / text_len) * (count / text_len).log(2.0)
}).fold(0.0, |sum, c| sum + c)
}<|fim_prefix|>// repo: merehap/rustdailyprogrammer path: /263.rs
use std::collections::HashMap;
fn main() {
let tex... | code_fim | hard | {
"lang": "rust",
"repo": "merehap/rustdailyprogrammer",
"path": "/263.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: silentsokolov/tocenter path: /src/consts.rs
use std::f32::consts::PI;
pub const DESIRED_FPS: u32 = 60;
pub const DEFAULT_TOLERANCE: f32 = 0.1;
pub const LEVEL_FILL_RADIUS: f32 = 25.0;
pub const LEVEL_SPACE_RADIUS: f32 = 20.0;
pub const LEVEL_RADIUS: f32 = LEVEL_FILL_RADIUS + LEVEL_SPACE_RADIUS;... | code_fim | medium | {
"lang": "rust",
"repo": "silentsokolov/tocenter",
"path": "/src/consts.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>FE_SIZE: u32 = 4;
pub const PLAYER_LIFE: u32 = 3;
pub const PLAYER_START_LEVEL: i32 = 8;
pub const PLAYER_START_ANGLE: f32 = 0.5 * PI;
pub const PI_2: f32 = 2.0 * PI;<|fim_prefix|>// repo: silentsokolov/tocenter path: /src/consts.rs
use std::f32::consts::PI;
pub const DESIRED_FPS: u32 = 60;
pub const DE... | code_fim | hard | {
"lang": "rust",
"repo": "silentsokolov/tocenter",
"path": "/src/consts.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>b const HORIZONTAL_SPEED_MIN: f32 = 0.04;
pub const HORIZONTAL_SPEED_MAX: f32 = 0.20;
pub const VERTICAL_SPEED: f32 = 3.;
pub const GAME_TIME: u64 = 15;
pub const LIFE_SIZE: u32 = 4;
pub const PLAYER_LIFE: u32 = 3;
pub const PLAYER_START_LEVEL: i32 = 8;
pub const PLAYER_START_ANGLE: f32 = 0.5 * PI;
pub co... | code_fim | medium | {
"lang": "rust",
"repo": "silentsokolov/tocenter",
"path": "/src/consts.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> mut buffer: R,
data_attrs: &DatasetAttributes,
grid_position: GridCoord,
block: &mut B,
) -> std::io::Result<()> {
if data_attrs.data_type != T::VARIANT {
return Err(Error::new(
ErrorKind::InvalidInput,
"Attempt to cr... | code_fim | hard | {
"lang": "rust",
"repo": "clbarnes/rust-n5",
"path": "/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl WriteableDataBlock for VecDataBlock<i8> {
fn write_data<W: std::io::Write>(&self, mut target: W) -> std::io::Result<()> {
// Unsafe necessary here because we need a &mut [u8] to avoid doing
// individual writes from the i8 data. This is safe.
let data_ref = unsafe { &*(sel... | code_fim | hard | {
"lang": "rust",
"repo": "clbarnes/rust-n5",
"path": "/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: clbarnes/rust-n5 path: /src/lib.rs
const COORD_SMALLVEC_SIZE: usize = 6;
pub type CoordVec<T> = SmallVec<[T; COORD_SMALLVEC_SIZE]>;
pub type BlockCoord = CoordVec<i32>;
pub type GridCoord = CoordVec<i64>;
lazy_static! {
pub static ref VERSION: Version = {
Version::new(2, 0, 2, "")... | code_fim | hard | {
"lang": "rust",
"repo": "clbarnes/rust-n5",
"path": "/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PacktPublishing/Rust-Standard-Library-Cookbook path: /Chapter10/src/bin/benchmarking.rs
#![feature(test)]
// The test crate was primarily designed for
// the Rust compiler itself, so it has no stability guaranteed
extern crate test;
pub fn slow_fibonacci_recursive(n: u32) -> u32 {
match n {... | code_fim | hard | {
"lang": "rust",
"repo": "PacktPublishing/Rust-Standard-Library-Cookbook",
"path": "/Chapter10/src/bin/benchmarking.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> b.iter(|| {
// test::block_box is "black box" for the compiler and LLVM
// Telling them to not optimize a variable away
let n = test::black_box(20);
slow_fibonacci_recursive(n)
});
}
#[bench]
fn bench_fibonacci_imperative(b: &mut... | code_fim | hard | {
"lang": "rust",
"repo": "PacktPublishing/Rust-Standard-Library-Cookbook",
"path": "/Chapter10/src/bin/benchmarking.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> b.iter(|| {
let n = test::black_box(20);
memoized_fibonacci_recursive(n)
});
}
#[bench]
fn bench_fast_fibonacci_recursive(b: &mut Bencher) {
b.iter(|| {
let n = test::black_box(20);
fast_fibonacci_recursive(n)
});... | code_fim | hard | {
"lang": "rust",
"repo": "PacktPublishing/Rust-Standard-Library-Cookbook",
"path": "/Chapter10/src/bin/benchmarking.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Self::try_from_slice(src).map_err(|err| {
msg!("Failed to deserialize");
msg!(&err.to_string());
ProgramError::InvalidAccountData
})
}
}
impl IsInitialized for RewardManager {
fn is_initialized(&self) -> bool {
self.version != UNINITIALI... | code_fim | medium | {
"lang": "rust",
"repo": "AudiusProject/audius-protocol",
"path": "/solana-programs/reward-manager/program/src/state/reward_manager.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AudiusProject/audius-protocol path: /solana-programs/reward-manager/program/src/state/reward_manager.rs
use super::UNINITIALIZED_VERSION;
use crate::PROGRAM_VERSION;
use borsh::{BorshDeserialize, BorshSerialize};
use solana_program::{
msg,
program_error::ProgramError,
program_pack::{... | code_fim | medium | {
"lang": "rust",
"repo": "AudiusProject/audius-protocol",
"path": "/solana-programs/reward-manager/program/src/state/reward_manager.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub struct C34PlayerInfoAddPlayer {
pub uuid: u128,
pub name: String,
pub properties: Vec<C34PlayerInfoAddPlayerProperty>,
pub gamemode: i32,
pub ping: i32,
pub display_name: Option<String>,
}
pub enum C34PlayerInfo {
AddPlayer(Vec<C34PlayerInfoAddPlayer>),
RemovePlayer(Ve... | code_fim | hard | {
"lang": "rust",
"repo": "hamptonmoore/MCHPRS",
"path": "/src/network/packets/clientbound.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hamptonmoore/MCHPRS path: /src/network/packets/clientbound.rs
0FChatMessage {
fn encode(self) -> PacketEncoder {
let mut buf = Vec::new();
buf.write_string(32767, &self.message);
buf.write_byte(self.position);
PacketEncoder::new(buf, 0x0F)
}
}
pub struct ... | code_fim | hard | {
"lang": "rust",
"repo": "hamptonmoore/MCHPRS",
"path": "/src/network/packets/clientbound.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hamptonmoore/MCHPRS path: /src/network/packets/clientbound.rs
impl ClientBoundPacket for C10MultiBlockChange {
fn encode(self) -> PacketEncoder {
let mut buf = Vec::new();
buf.write_int(self.chunk_x);
buf.write_int(self.chunk_z);
buf.write_varint(self.records... | code_fim | hard | {
"lang": "rust",
"repo": "hamptonmoore/MCHPRS",
"path": "/src/network/packets/clientbound.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fuchsch1234/lpc178x_7x path: /src/iocon/p0_23.rs
#[doc = "Reader of register P0_23"]
pub type R = crate::R<u32, super::P0_23>;
#[doc = "Writer for register P0_23"]
pub type W = crate::W<u32, super::P0_23>;
#[doc = "Register P0_23 `reset()`'s with value 0x01b0"]
impl crate::ResetValue for super::... | code_fim | hard | {
"lang": "rust",
"repo": "fuchsch1234/lpc178x_7x",
"path": "/src/iocon/p0_23.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>> &'a mut W {
self.variant(FUNC_A::ADC0_IN_0)
}
#[doc = "Receive Clock. It is driven by the master and received by the slave. Corresponds to the signal SCK in the I2S-bus specification."]
#[inline(always)]
pub fn i2s_rx_sck(self) -> &'a mut W {
self.variant(FUNC_A::I2S_RX_S... | code_fim | hard | {
"lang": "rust",
"repo": "fuchsch1234/lpc178x_7x",
"path": "/src/iocon/p0_23.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn poll(&mut self) -> Result<Async<Self::Item>, Self::Error> {
let (next, res) = match *self {
UdpQuery::Send { ref mut send, addr, recv_size } => {
let (sock, query) = try_ready!(send.poll());
(
UdpQuery::Recv {
... | code_fim | hard | {
"lang": "rust",
"repo": "hawkinsw/domain",
"path": "/domain-resolv/src/stub/net/udp.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hawkinsw/domain path: /domain-resolv/src/stub/net/udp.rs
use std::io;
use std::net::SocketAddr;
use domain_core::bits::query::{DgramQueryMessage, QueryMessage};
use domain_core::bits::message::Message;
use tokio::net::udp::{RecvDgram, SendDgram, UdpSocket};
use tokio::prelude::{Async, Future};
... | code_fim | hard | {
"lang": "rust",
"repo": "hawkinsw/domain",
"path": "/domain-resolv/src/stub/net/udp.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> let array = create_scalar_array();
for x in 0..1000 {
assert!(array.is_valid(x));
}
let array = create_null_scalar_array();
for x in 0..1000 {
assert!(!array.is_valid(x));
}
}
#[test]
fn test_array_is_null() {
le... | code_fim | hard | {
"lang": "rust",
"repo": "sunli829/yql",
"path": "/libs/dataset/src/array/primitive_array.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_array_value() {
let array = create_array();
let array_i32 = array.downcast_ref::<Int32Array>();
for x in 0..1000 {
if x % 2 == 0 {
assert_eq!(array_i32.value(x), x as i32);
} else {
assert_eq!(array_i32... | code_fim | hard | {
"lang": "rust",
"repo": "sunli829/yql",
"path": "/libs/dataset/src/array/primitive_array.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sunli829/yql path: /libs/dataset/src/array/primitive_array.rs
e,
},
PrimitiveArray::Scalar { value, .. } => value.is_some(),
}
}
fn null_count(&self) -> usize {
if let Some(scalar) = self.to_scalar() {
if scalar.is_none() {
... | code_fim | hard | {
"lang": "rust",
"repo": "sunli829/yql",
"path": "/libs/dataset/src/array/primitive_array.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(ctx)
}
#[cfg(test)]
mod tests {
use super::interpret;
use crate::rules::consts;
use crate::rules::errors::invalid_time_error;
use chrono::prelude::*;
fn fixed_time() -> DateTime<Local> {
// 2019 1st January, Tuesday
Local.ymd(2019, 1, 1).and_hms(0, 0, 1)
}
... | code_fim | hard | {
"lang": "rust",
"repo": "cambricorp/when",
"path": "/src/rules/en/deadline.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // 2019 1st January, Tuesday
Local.ymd(2019, 1, 1).and_hms(0, 0, 1)
}
#[test]
fn test_deadline() {
let result = interpret("in 2 months", false, fixed_time()).unwrap();
assert_eq!(result.get_month(), 3);
let result = interpret("in three months", false, ... | code_fim | hard | {
"lang": "rust",
"repo": "cambricorp/when",
"path": "/src/rules/en/deadline.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cambricorp/when path: /src/rules/en/deadline.rs
use super::combinators::{stub, tokenize_count_symbols, Dist};
use super::common_matchers::match_num;
use super::consts;
use super::errors::{invalid_time_error, SemanticError};
use super::rules::{Context, RuleResult, TokenDesc};
use super::tokens::{... | code_fim | hard | {
"lang": "rust",
"repo": "cambricorp/when",
"path": "/src/rules/en/deadline.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>Input: K = 1
Output: 1
Explanation: The smallest answer is N = 1, which has length 1.
Example 2:
Input: K = 2
Output: -1
Explanation: There is no such positive integer N divisible by 2.
Example 3:
Input: K = 3
Output: 3
Explanation: The smallest answer is N = 111, which has length 3.
Constraints:
... | code_fim | medium | {
"lang": "rust",
"repo": "21eleven/leetcode-solutions",
"path": "/rust/1015_smallest_integer_divisible_by_k/remainde.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 21eleven/leetcode-solutions path: /rust/1015_smallest_integer_divisible_by_k/remainde.rs
/*
1015. Smallest Integer Divisible by K
Medium
Given a positive integer K, you need to find the length of the smallest positive integer N such that N is divisible by K, and N only contains the digit 1.
<|... | code_fim | hard | {
"lang": "rust",
"repo": "21eleven/leetcode-solutions",
"path": "/rust/1015_smallest_integer_divisible_by_k/remainde.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub enum SendStatus {
Sent,
Retry(hyper::Error),
RetryTimeout,
}
#[derive(Debug, thiserror::Error)]
pub enum ClientError<T>
where
T: Send + 'static,
{
#[error("{0}")]
BadRequest(hyper::StatusCode),
#[error("{0}")]
Http(#[from] HttpError<T>),
#[error("{0}")]
Retry(#... | code_fim | hard | {
"lang": "rust",
"repo": "BartVB/logdna-agent-v2",
"path": "/common/http/src/client.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: BartVB/logdna-agent-v2 path: /common/http/src/client.rs
use std::convert::TryInto;
use std::time::{Duration, Instant};
use crate::limit::RateLimiter;
use crate::retry::{self, RetrySender};
use crate::types::body::IngestBodyBuffer;
use crate::types::client::Client as HttpClient;
use crate::types... | code_fim | hard | {
"lang": "rust",
"repo": "BartVB/logdna-agent-v2",
"path": "/common/http/src/client.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// @has inline_default_methods/trait.Bar.html
// @has - '//pre[@class="rust item-decl"]' '// Required method fn bar(&self);'
// @has - '//pre[@class="rust item-decl"]' '// Provided methods fn foo1(&mut self)'
// @has - '//pre[@class="rust item-decl"]' 'fn foo2(&mut self)'
pub use inline_default_methods::B... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/tests/rustdoc/inline-default-methods.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/rust path: /tests/rustdoc/inline-default-methods.rs
// aux-build:inline-default-methods.rs
// ignore-cross-compile
extern crate inline_default_methods;
<|fim_suffix|>// @has inline_default_methods/trait.Baz.html
// @has - '//pre[@class="rust item-decl"]' '// Required methods fn bar1(... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/tests/rustdoc/inline-default-methods.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Global {
pub fn new() -> Self {
Global(Arc::new(HashMap::new()))
}
fn serialize_inner<S>(
inner: &Arc<HashMap<ReplicaId, u64>>,
serializer: S,
) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
use serde::Serialize;
inner.seria... | code_fim | hard | {
"lang": "rust",
"repo": "fdionisi/xray",
"path": "/memo_core/src/time.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fdionisi/xray path: /memo_core/src/time.rs
use crate::serialization;
use crate::Error;
use crate::ReplicaId;
use crate::ReplicaIdExt;
use flatbuffers::{FlatBufferBuilder, WIPOffset};
use serde::{Deserializer, Serializer};
use serde_derive::{Deserialize, Serialize};
use std::cmp::{self, Ordering}... | code_fim | hard | {
"lang": "rust",
"repo": "fdionisi/xray",
"path": "/memo_core/src/time.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.