text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: bellegarde-c/gtk4-rs-gio-file-loads-content-crash path: /src/application.rs
use crate::config;
use crate::window::ExampleApplicationWindow;
use gio::ApplicationFlags;
use glib::clone;
use glib::WeakRef;
use gtk::prelude::*;
use gtk::subclass::prelude::*;
use gtk::{gdk, gio, glib};
use gtk_macros... | code_fim | hard | {
"lang": "rust",
"repo": "bellegarde-c/gtk4-rs-gio-file-loads-content-crash",
"path": "/src/application.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.set_accels_for_action("app.quit", &["<primary>q"]);
self.set_accels_for_action("win.show-help-overlay", &["<primary>question"]);
}
fn setup_css(&self) {
let css = gio::File::new_for_uri(
"resource:///org/gtk/bug/resources/css"
);
if let Ok(... | code_fim | hard | {
"lang": "rust",
"repo": "bellegarde-c/gtk4-rs-gio-file-loads-content-crash",
"path": "/src/application.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if left.is_composition(right) {
Relation::Composition
} else if left.is_aggregation(right) {
Relation::Aggregation
} else if left.is_dependency(right) {
Relation::Dependency
} else if left.is_association(right) {
Relation::Ass... | code_fim | medium | {
"lang": "rust",
"repo": "bytesorg/ml",
"path": "/src/core/item/relation.rs",
"mode": "spm",
"license": "LicenseRef-scancode-other-permissive",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a> From<(&'a ItemState<'a>, &'a ItemState<'a>)> for Relation {
fn from((left, right): (&'a ItemState<'a>, &'a ItemState<'a>)) -> Relation {
if left.is_composition(right) {
Relation::Composition
} else if left.is_aggregation(right) {
Relation::Aggregation
... | code_fim | hard | {
"lang": "rust",
"repo": "bytesorg/ml",
"path": "/src/core/item/relation.rs",
"mode": "spm",
"license": "LicenseRef-scancode-other-permissive",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bytesorg/ml path: /src/core/item/relation.rs
use dot::{ArrowShape, Fill, Side};
use super::ItemState;
/// The enumeration `Relation` is the relationship specification from [UML 2.5](http://www.omg.org/spec/UML/2.5) without generalization.
#[derive(Debug, Copy, Clone)]
pub enum Relation {
A... | code_fim | hard | {
"lang": "rust",
"repo": "bytesorg/ml",
"path": "/src/core/item/relation.rs",
"mode": "psm",
"license": "LicenseRef-scancode-other-permissive",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ebkalderon/freedesktop-categories path: /build.rs
#[cfg(feature = "generate-map")]
extern crate freedesktop_categories_codegen as codegen;
<|fim_suffix|> #[cfg(feature = "generate-map")]
codegen::DesktopMenuSpec::new()
.version(codegen::Version::Latest)
.output_file_name(... | code_fim | easy | {
"lang": "rust",
"repo": "ebkalderon/freedesktop-categories",
"path": "/build.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[cfg(feature = "generate-map")]
codegen::DesktopMenuSpec::new()
.version(codegen::Version::Latest)
.output_file_name("map.rs")
.gen_static_map()
.unwrap();
}<|fim_prefix|>// repo: ebkalderon/freedesktop-categories path: /build.rs
#[cfg(feature = "generate-map")]
e... | code_fim | easy | {
"lang": "rust",
"repo": "ebkalderon/freedesktop-categories",
"path": "/build.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Display for Expr {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
match self {
Expr::Tuple(e) => {
f.write_str("(")?;
comma_separated_fmt(f, e, |x, f| x.node.fmt(f), true)?;
f.write_str(")")
}
Expr:... | code_fim | hard | {
"lang": "rust",
"repo": "aiuto/starlark-rust",
"path": "/starlark/src/syntax/ast.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aiuto/starlark-rust path: /starlark/src/syntax/ast.rs
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the ... | code_fim | hard | {
"lang": "rust",
"repo": "aiuto/starlark-rust",
"path": "/starlark/src/syntax/ast.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aiuto/starlark-rust path: /starlark/src/syntax/ast.rs
y applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language g... | code_fim | hard | {
"lang": "rust",
"repo": "aiuto/starlark-rust",
"path": "/starlark/src/syntax/ast.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut ret = vvi[x][y];
if x as i32 - 1 >= 0 && y as i32 - 1 >= 0 && x + 1 < vvi.len() && y + 1 < vvi[0].len() && x + 2 < vvi.len() && y + 2 < vvi[0].len() {
ret *= vvi[x - 1][y - 1] * vvi[x + 1][y + 1] * vvi[x + 2][y + 2];
}
ret
}
// right -> left
fn cal3(vvi: &Vec<Vec<i32>>, x: usize, y: us... | code_fim | hard | {
"lang": "rust",
"repo": "Miloas/project-euler-rust",
"path": "/src/solver/p011.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut ret = vvi[x][y];
if y as i32 - 1 >= 0 && y + 1 < vvi[0].len() && y + 2 < vvi[0].len() {
ret *= vvi[x][y - 1] * vvi[x][y + 1] * vvi[x][y + 2];
}
ret
}
// left -> right
fn cal2(vvi: &Vec<Vec<i32>>, x: usize, y: usize) -> i32 {
let mut ret = vvi[x][y];
if x as i32 - 1 >= 0 && y as i32... | code_fim | hard | {
"lang": "rust",
"repo": "Miloas/project-euler-rust",
"path": "/src/solver/p011.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Miloas/project-euler-rust path: /src/solver/p011.rs
use std::cmp;
pub fn solve() -> i32 {
const S: &'static str = r"
08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08
49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00
81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 03 49 13 ... | code_fim | hard | {
"lang": "rust",
"repo": "Miloas/project-euler-rust",
"path": "/src/solver/p011.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> 11 * factors.iter().fold(0, |acc, x| acc + x)
}
#[test]
fn test_count_presents2() {
assert_eq!(11, count_presents2(1));
assert_eq!(33, count_presents2(2));
assert_eq!(44, count_presents2(3));
assert_eq!(77, count_presents2(4));
assert_eq!(66, count_presents2(5));
assert_eq!(13... | code_fim | hard | {
"lang": "rust",
"repo": "davidsullins/AdventOfCodeRust",
"path": "/src/bin/advent20.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: davidsullins/AdventOfCodeRust path: /src/bin/advent20.rs
// advent20.rs
// factorizing
// Used the first crate I found that did what I needed; turned out to be quite slow, oh well
extern crate tcorp_math_mods;
use std::io;
fn main() {
let mut input = String::new();
io::stdin().read_l... | code_fim | hard | {
"lang": "rust",
"repo": "davidsullins/AdventOfCodeRust",
"path": "/src/bin/advent20.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/native-dialog-rs path: /src/dialog_impl/mac/file.rs
use super::ffi::cocoa::{
INSColor, INSOpenPanel, INSPopUpButton, INSSavePanel, INSStackView, INSTextField, NSColor,
NSEdgeInsets, NSOpenPanel, NSPopUpButton, NSSavePanel, NSStackView, NSStackViewGravity,
NSTextField, NSUserI... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/native-dialog-rs",
"path": "/src/dialog_impl/mac/file.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> unsafe { action_target.set_filters(std::ptr::null()) };
res
} else {
panel.run_modal()
};
match res {
Ok(url) => Ok(Some(url.to_path_buf())),
Err(_) => Ok(None),
}
}
}
fn get_all_allowed_types(filters: &[Fil... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/native-dialog-rs",
"path": "/src/dialog_impl/mac/file.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jfoote/wasmtime path: /crates/c-api/src/lib.rs
_ => panic!("unexpected kind: {}", kind),
}
}
fn from_valtype(ty: &ValType) -> wasm_valkind_t {
match ty {
ValType::I32 => 0,
ValType::I64 => 1,
ValType::F32 => 2,
ValType::F64 => 3,
ValType::A... | code_fim | hard | {
"lang": "rust",
"repo": "jfoote/wasmtime",
"path": "/crates/c-api/src/lib.rs",
"mode": "psm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(finalizer) = self.finalizer {
unsafe {
finalizer(self.env);
}
}
}
}
#[no_mangle]
pub unsafe extern "C" fn wasm_func_new(
store: *mut wasm_store_t,
ty: *const wasm_functype_t,
callback: wasm_func_callback_t,
) -> *mut wasm... | code_fim | hard | {
"lang": "rust",
"repo": "jfoote/wasmtime",
"path": "/crates/c-api/src/lib.rs",
"mode": "spm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jfoote/wasmtime path: /crates/c-api/src/lib.rs
()
.iter()
.map(|e| match e {
Extern::Func(f) => ExternHost::Func(HostRef::new(f.clone())),
Extern::Global(f) => ExternHost::Global(HostRef::new(f.clone())),
Extern::Memory(f) =... | code_fim | hard | {
"lang": "rust",
"repo": "jfoote/wasmtime",
"path": "/crates/c-api/src/lib.rs",
"mode": "psm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: facebookexperimental/rust-shed path: /shed/codegen_includer_proc_macro/build.rs
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under both the MIT license found in the
* LICENSE-MIT file in the root directory of this source tree and the Apache
* Lice... | code_fim | medium | {
"lang": "rust",
"repo": "facebookexperimental/rust-shed",
"path": "/shed/codegen_includer_proc_macro/build.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let lib_rs = Path::new(&env::var("OUT_DIR").unwrap()).join("lib.rs");
fs::copy("tests/fixtures/lib.rs", lib_rs).expect("Failed copying fixtures");
}<|fim_prefix|>// repo: facebookexperimental/rust-shed path: /shed/codegen_includer_proc_macro/build.rs
/*
* Copyright (c) Meta Platforms, Inc. and a... | code_fim | medium | {
"lang": "rust",
"repo": "facebookexperimental/rust-shed",
"path": "/shed/codegen_includer_proc_macro/build.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let eip2930_transaction = Transaction {
nonce: 0.into(),
from: H160::zero(),
to: Some(H160::zero()),
value: 0.into(),
gas: 0.into(),
input: Default::default(),
gas_price: 0.into(),
chain_id: Some(0.into... | code_fim | hard | {
"lang": "rust",
"repo": "input-output-hk/jormungandr",
"path": "/jormungandr/src/jrpc/eth_types/transaction.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: input-output-hk/jormungandr path: /jormungandr/src/jrpc/eth_types/transaction.rs
use super::{bytes::Bytes, number::Number};
use chain_evm::{
ethereum_types::{H160, H256, U256},
transaction::EthereumUnsignedTransaction,
AccessList,
};
use chain_impl_mockchain::evm::{EvmActionType, Evm... | code_fim | hard | {
"lang": "rust",
"repo": "input-output-hk/jormungandr",
"path": "/jormungandr/src/jrpc/eth_types/transaction.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut id: Option<Number> = None;
let mut access_list = None;
let mut max_fee_per_gas = None;
let mut max_priority_fee_per_gas = None;
while let Some(key) = map.next_key()? {
match key {
"type" => {
if id.is_some() {... | code_fim | hard | {
"lang": "rust",
"repo": "input-output-hk/jormungandr",
"path": "/jormungandr/src/jrpc/eth_types/transaction.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stm32-rs/stm32-rs-nightlies path: /stm32g0/src/stm32g031/adc/ccr.rs
#[doc = "Register `CCR` reader"]
pub type R = crate::R<CCR_SPEC>;
#[doc = "Register `CCR` writer"]
pub type W = crate::W<CCR_SPEC>;
#[doc = "Field `PRESC` reader - ADC prescaler"]
pub type PRESC_R = crate::FieldReader<PRESC_A>;
... | code_fim | hard | {
"lang": "rust",
"repo": "stm32-rs/stm32-rs-nightlies",
"path": "/stm32g0/src/stm32g031/adc/ccr.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> variant as u8 != 0
}
}
impl VBATEN_R {
#[doc = "Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> VBATEN_A {
match self.bits {
false => VBATEN_A::Disabled,
true => VBATEN_A::Enabled,
}
}
#[doc = "VBAT channel ... | code_fim | hard | {
"lang": "rust",
"repo": "stm32-rs/stm32-rs-nightlies",
"path": "/stm32g0/src/stm32g031/adc/ccr.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: astral-sh/ruff path: /crates/ruff/src/rules/flake8_pytest_style/rules/mod.rs
pub(crate) use assertion::*;
pub(crate) use fail::*;
pub(crate) use fixture::*;
pub(cra<|fim_suffix|>se patch::*;
pub(crate) use raises::*;
mod assertion;
mod fail;
mod fixture;
mod helpers;
mod imports;
mod marks;
mod... | code_fim | medium | {
"lang": "rust",
"repo": "astral-sh/ruff",
"path": "/crates/ruff/src/rules/flake8_pytest_style/rules/mod.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>rs;
mod imports;
mod marks;
mod parametrize;
mod patch;
mod raises;
mod unittest_assert;<|fim_prefix|>// repo: astral-sh/ruff path: /crates/ruff/src/rules/flake8_pytest_style/rules/mod.rs
pub(crate) use assertion::*;
pub(crate) use fail::*;
pub(crate) use fixture::*;
pub(cra<|fim_middle|>te) use imports:... | code_fim | medium | {
"lang": "rust",
"repo": "astral-sh/ruff",
"path": "/crates/ruff/src/rules/flake8_pytest_style/rules/mod.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/crates.io path: /src/db.rs
use diesel::prelude::*;
use diesel::r2d2::{self, ConnectionManager, CustomizeConnection};
use prometheus::Histogram;
use secrecy::{ExposeSecret, SecretString};
use std::sync::{Arc, Mutex, MutexGuard};
use std::{
ops::{Deref, DerefMut},
time::Duration,... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/crates.io",
"path": "/src/db.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[instrument(skip_all)]
pub fn wait_until_healthy(&self, timeout: Duration) -> Result<(), PoolError> {
match self {
DieselPool::Pool { pool, .. } | DieselPool::BackgroundJobPool { pool } => {
match pool.get_timeout(timeout) {
Ok(_) => Ok(()),... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/crates.io",
"path": "/src/db.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gregokent/tms570 path: /src/dcan4/mod.rs
#[doc = r" Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - CAN Control Register"]
pub ctl: CTL,
#[doc = "0x04 - Error and Status register"]
pub es: ES,
#[doc = "0x08 - Error Counter Register"]
pub errc: ERRC,... | code_fim | hard | {
"lang": "rust",
"repo": "gregokent/tms570",
"path": "/src/dcan4/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> register: ::vcell::VolatileCell<u32>,
}
#[doc = "Transmission Request 34 Register"]
pub mod txrq34;
#[doc = "Transmission Request 56 Register"]
pub struct TXRQ56 {
register: ::vcell::VolatileCell<u32>,
}
#[doc = "Transmission Request 56 Register"]
pub mod txrq56;
#[doc = "Transmission Request 78 Regi... | code_fim | hard | {
"lang": "rust",
"repo": "gregokent/tms570",
"path": "/src/dcan4/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: apache/incubator-milagro-crypto-rust path: /src/roms/rom_brainpool_64.rs
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licens... | code_fim | hard | {
"lang": "rust",
"repo": "apache/incubator-milagro-crypto-rust",
"path": "/src/roms/rom_brainpool_64.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>// Base Bits= 56
// brainpool Modulus
pub const MODULUS: [Chunk; NLEN] = [
0x13481D1F6E5377,
0xF623D526202820,
0x909D838D726E3B,
0xA1EEA9BC3E660A,
0xA9FB57DB,
];
pub const R2MODP: [Chunk; NLEN] = [
0x9E04F49B9A3787,
0x29317218F3CF49,
0x54E8C3CF1DBC89,
0xBB411A3F7559CA,
... | code_fim | hard | {
"lang": "rust",
"repo": "apache/incubator-milagro-crypto-rust",
"path": "/src/roms/rom_brainpool_64.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.root = Rc::new(RefCell::new(tree));
Ok(self.root.clone())
}
fn number_references(&mut self) -> Result<SharedTree, TokenWriterError> {
// Undeclared references
let top = Rc::new(RefCell::new(vec![]));
let stack = Rc::new(RefCell::new(vec![top.clone()]))... | code_fim | hard | {
"lang": "rust",
"repo": "zealousidealroll/binjs-ref",
"path": "/crates/binjs_io/src/multistream.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn string(&mut self, value: Option<&str>) -> Result<Self::Tree, TokenWriterError> {
let value = match (value, &self.options.dictionary_placement) {
(None, _) => None,
(Some(ref s), &DictionaryPlacement::Inline) => {
let mut string = s.to_string();
... | code_fim | hard | {
"lang": "rust",
"repo": "zealousidealroll/binjs-ref",
"path": "/crates/binjs_io/src/multistream.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zealousidealroll/binjs-ref path: /crates/binjs_io/src/multistream.rs
rrow_stack = stack.borrow();
let mut borrow_frame = borrow_stack.last()
.unwrap()
.borrow_mut();
borrow_frame
.push... | code_fim | hard | {
"lang": "rust",
"repo": "zealousidealroll/binjs-ref",
"path": "/crates/binjs_io/src/multistream.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn to_arr(self) -> [T; N] {
self.0.rows[0]
}
pub fn get_elem(&self, n: usize) -> T {
self.0.rows[0][n]
}
pub fn set_elem(&mut self, n: usize, v: T) {
self.0.rows[0][n] = v;
}
pub fn length_squared(self) -> T {
let mut sum = Zero::zero();
for i in 0..N {
sum = sum + self.get_elem... | code_fim | hard | {
"lang": "rust",
"repo": "Nyrox/motokigo",
"path": "/src/builtins/vector.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Nyrox/motokigo path: /src/builtins/vector.rs
use crate::{
ast::TypeKind,
builtins::{BuiltInType, Matrix, Scalar},
};
use num_traits::*;
use std::{
fmt::{Debug, Formatter, Result},
ops::{Add, Div, Mul, Sub},
};
#[repr(C)]
#[derive(Clone, Copy, PartialEq)]
pub struct Vector<T: Scalar, const N... | code_fim | hard | {
"lang": "rust",
"repo": "Nyrox/motokigo",
"path": "/src/builtins/vector.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn dot(self, other: Self) -> T {
let mut sum = Zero::zero();
for i in 0..N {
sum = sum + self.get_elem(i) * other.get_elem(i);
}
sum
}
}
impl<T: Scalar + From<f32>, const N: usize> Vector<T, N> {
pub fn normalize(self) -> Self {
self / self.length().into()
}
}
//TODO: Add a macro to... | code_fim | hard | {
"lang": "rust",
"repo": "Nyrox/motokigo",
"path": "/src/builtins/vector.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn empty() -> Self {
Self {
schema_name: "".to_string(),
table_id: 0,
table_version: None,
table_schema: Arc::new(DataSchema::empty()),
projected_schema: Arc::new(DataSchema::empty()),
table_args: None,
pus... | code_fim | hard | {
"lang": "rust",
"repo": "r-asou/databend",
"path": "/common/planners/src/plan_scan.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: r-asou/databend path: /common/planners/src/plan_scan.rs
// Copyright 2020 Datafuse Labs.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apach... | code_fim | hard | {
"lang": "rust",
"repo": "r-asou/databend",
"path": "/common/planners/src/plan_scan.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut buffer = File::create("wild.txt");
buffer.write("yo this isn't a cli tool but i wish it were");
file.write_all(b"Hello, world!");
}<|fim_prefix|>// repo: kyleoldham/rust-playground path: /write.rs
use std::fs::File;
use std::io::prelude::*;
use std::io::Write;
<|fim_middle|>fn main()... | code_fim | easy | {
"lang": "rust",
"repo": "kyleoldham/rust-playground",
"path": "/write.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kyleoldham/rust-playground path: /write.rs
use std::fs::File;
use std::io::prelude::*;
use std::io::Write;
<|fim_suffix|> let mut buffer = File::create("wild.txt");
buffer.write("yo this isn't a cli tool but i wish it were");
file.write_all(b"Hello, world!");
}<|fim_middle|>fn main()... | code_fim | easy | {
"lang": "rust",
"repo": "kyleoldham/rust-playground",
"path": "/write.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sigp/lighthouse path: /beacon_node/network/src/service/tests.rs
#[cfg(not(debug_assertions))]
#[cfg(test)]
mod tests {
use crate::persisted_dht::load_dht;
use crate::{NetworkConfig, NetworkService};
use beacon_chain::test_utils::BeaconChainHarness;
use beacon_processor::BeaconPro... | code_fim | hard | {
"lang": "rust",
"repo": "sigp/lighthouse",
"path": "/beacon_node/network/src/service/tests.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut config = NetworkConfig::default();
config.set_ipv4_listening_address(std::net::Ipv4Addr::UNSPECIFIED, 21212, 21212);
config.discv5_config.table_filter = |_| true; // Do not ignore local IPs
config.upnp_enabled = false;
config.boot_nodes_enr = enrs.clone();
... | code_fim | hard | {
"lang": "rust",
"repo": "sigp/lighthouse",
"path": "/beacon_node/network/src/service/tests.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let BeaconProcessorChannels {
beacon_processor_tx,
beacon_processor_rx: _beacon_processor_rx,
work_reprocessing_tx,
work_reprocessing_rx: _work_reprocessing_rx,
} = <_>::default();
let _network_service = N... | code_fim | hard | {
"lang": "rust",
"repo": "sigp/lighthouse",
"path": "/beacon_node/network/src/service/tests.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tjwilson90/turbo-hearts path: /server/src/game_endpoints.rs
use crate::{auth_redirect, Games, Lobby};
use tokio::sync::mpsc::UnboundedReceiver;
use tokio_stream::{wrappers::UnboundedReceiverStream, Stream, StreamExt};
use turbo_hearts_api::{
AcceptClaimRequest, ChargeRequest, ClaimRequest, G... | code_fim | hard | {
"lang": "rust",
"repo": "tjwilson90/turbo-hearts",
"path": "/server/src/game_endpoints.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> async fn handle(
games: &Games,
user_id: UserId,
request: AcceptClaimRequest,
) -> Result<impl Reply, Rejection> {
let AcceptClaimRequest { game_id, claimer } = request;
games.accept_claim(game_id, user_id, claimer).await?;
Ok(warp::reply())
}
... | code_fim | hard | {
"lang": "rust",
"repo": "tjwilson90/turbo-hearts",
"path": "/server/src/game_endpoints.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SamirTalwar/advent-of-code path: /2019/AOC_03_1.rs
use std::collections::HashSet;
use std::convert::TryFrom;
use std::io;
use std::io::Read;
use nom::{
character::complete as character, combinator::map, combinator::map_opt, combinator::opt,
multi::many1, sequence::pair, sequence::termin... | code_fim | hard | {
"lang": "rust",
"repo": "SamirTalwar/advent-of-code",
"path": "/2019/AOC_03_1.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut input: String = String::new();
io::stdin().read_to_string(&mut input)?;
let (_, (wire_a, wire_b)) = parse_wire_paths(&input).map_err(errors::debug_to_io)?;
let wire_a_locations = all_locations(&wire_a);
let wire_b_locations = all_locations(&wire_b);
let overlaps = wire_a_l... | code_fim | hard | {
"lang": "rust",
"repo": "SamirTalwar/advent-of-code",
"path": "/2019/AOC_03_1.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> map(
pair(parse_direction, parse::digits),
|(direction, amount)| Movement { direction, amount },
)(input)
}
fn parse_direction(input: &str) -> IResult<&str, Direction> {
map_opt(character::anychar, |c| match c {
'D' => Some(Direction::Down),
'L' => Some(Directi... | code_fim | hard | {
"lang": "rust",
"repo": "SamirTalwar/advent-of-code",
"path": "/2019/AOC_03_1.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(GraphQLObject, Deserialize, Debug)]
pub struct TokenResponse {
access_token: String,
token_type: String,
expires_in: i32,
refresh_token: String,
scope: String,
}
#[derive(Clone, Serialize, Deserialize, GraphQLObject)]
pub struct GuildInfo {
pub id: String,
pub name: S... | code_fim | hard | {
"lang": "rust",
"repo": "Navrin/colour-bot-v2",
"path": "/src/webserver/graphql/models/common.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Navrin/colour-bot-v2 path: /src/webserver/graphql/models/common.rs
use colours::models::ParsedColour;
use db::models::Colour;
#[derive(GraphQLObject, Serialize, Deserialize, Debug, Clone)]
pub struct ColourResponse {
pub id: String,
pub name: String,
pub colour: String,
}
<|fim_suf... | code_fim | hard | {
"lang": "rust",
"repo": "Navrin/colour-bot-v2",
"path": "/src/webserver/graphql/models/common.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: likr/egraph-rs path: /crates/wasm/src/layout/force_simulation/coordinates.rs
use crate::graph::{IndexType, JsGraph};
use petgraph::graph::{node_index, NodeIndex};
use petgraph_layout_force_simulation::{Coordinates, Point};
use std::collections::HashMap;
use wasm_bindgen::prelude::*;
#[wasm_bind... | code_fim | hard | {
"lang": "rust",
"repo": "likr/egraph-rs",
"path": "/crates/wasm/src/layout/force_simulation/coordinates.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn vy(&self, u: usize) -> Option<f32> {
let u = node_index(u);
self.coordinates.vy(u)
}
pub fn len(&self) -> usize {
self.coordinates.len()
}
#[wasm_bindgen(js_name = toJSON)]
pub fn to_json(&self) -> JsValue {
let result = self
.co... | code_fim | hard | {
"lang": "rust",
"repo": "likr/egraph-rs",
"path": "/crates/wasm/src/layout/force_simulation/coordinates.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[wasm_bindgen(js_class = Coordinates)]
impl JsCoordinates {
pub fn x(&self, u: usize) -> Option<f32> {
let u = node_index(u);
self.coordinates.x(u)
}
pub fn y(&self, u: usize) -> Option<f32> {
let u = node_index(u);
self.coordinates.y(u)
}
#[wasm_bind... | code_fim | hard | {
"lang": "rust",
"repo": "likr/egraph-rs",
"path": "/crates/wasm/src/layout/force_simulation/coordinates.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jrutley/advent-of-code path: /2020/day6/src/main.rs
fn main() {
let input: Vec<String> = textfilereader::read_file_by_line("input.txt");
let groups = build_groups(input);
let results = common_letters(groups);
let final_sum: usize = results.iter().map(|x|x.len()).sum();
pri... | code_fim | hard | {
"lang": "rust",
"repo": "jrutley/advent-of-code",
"path": "/2020/day6/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let input = vec!("abc".to_string(),"bcd".to_string(),String::default(), "efg".to_string(),"hij".to_string());
let expected: Vec<Vec<String>> = vec!(vec!("abc".to_string(), "bcd".to_string()), vec!("efg".to_string(), "hij".to_string()));
assert_eq!(build_groups(input), expected);
... | code_fim | hard | {
"lang": "rust",
"repo": "jrutley/advent-of-code",
"path": "/2020/day6/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let input = vec!("abc".to_string());
let expected: Vec<Vec<String>> = vec!(vec!("abc".to_string()));
assert_eq!(build_groups(input), expected);
}
#[test]
fn test_group_multi_line() {
let input = vec!("abc".to_string(),"bcd".to_string());
let expected: V... | code_fim | hard | {
"lang": "rust",
"repo": "jrutley/advent-of-code",
"path": "/2020/day6/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hexgolems/td path: /src/tile.rs
use crate::algebra::Position;
use crate::direction::Dir;
use std::usize;
#[derive(Eq, PartialEq, Hash, Copy, Clone, Debug, Deserialize, Serialize)]
pub enum TileType {
Walk(Dir),
Build,
Spawn,
Target,
Empty,
}
use self::TileType::*;
<|fim_su... | code_fim | hard | {
"lang": "rust",
"repo": "hexgolems/td",
"path": "/src/tile.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn new_from_type(kind: TileType, x: usize, y: usize) -> Self {
let cost = match kind {
Build => 30,
Walk(_) => 1,
Spawn => 1,
Target => 1,
Empty => usize::max_value(),
};
return Self {
kind,
... | code_fim | hard | {
"lang": "rust",
"repo": "hexgolems/td",
"path": "/src/tile.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: povilasb/rust-playground path: /quicksort1/src/main.rs
use std::string::ToString;
use std::cmp::PartialOrd;
use std::clone::Clone;
mod stdio;
use stdio::{read_numbers, readln};
fn main() {
readln(); // skip
let arr = read_numbers::<i64>();
let (left, equal, right) = partition(&arr[... | code_fim | medium | {
"lang": "rust",
"repo": "povilasb/rust-playground",
"path": "/quicksort1/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> readln(); // skip
let arr = read_numbers::<i64>();
let (left, equal, right) = partition(&arr[..], &arr[0]);
println!("{} {} {}", arr_to_str(&left), arr_to_str(&equal),
arr_to_str(&right));
}
fn arr_to_str<T: ToString>(arr: &Vec<T>) -> String {
arr.iter()
.fold("".... | code_fim | medium | {
"lang": "rust",
"repo": "povilasb/rust-playground",
"path": "/quicksort1/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("your guess number is: {}", user_number);
match right_number.cmp(&user_number) {
Ordering::Greater => println!("your number is too less"),
Ordering::Less => println!("your number is too big"),
Ordering::Equal => {
println!("you ... | code_fim | hard | {
"lang": "rust",
"repo": "yxwsbobo/study_rust",
"path": "/src/test_projects/guess_game.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yxwsbobo/study_rust path: /src/test_projects/guess_game.rs
use rand::Rng;
use std::io;
use std::cmp::Ordering;
pub fn start(){
println!("in start guess game");
let right_number = rand::thread_rng().gen_range(1,101);
loop {
println!("please input a number:");
let ... | code_fim | medium | {
"lang": "rust",
"repo": "yxwsbobo/study_rust",
"path": "/src/test_projects/guess_game.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match right_number.cmp(&user_number) {
Ordering::Greater => println!("your number is too less"),
Ordering::Less => println!("your number is too big"),
Ordering::Equal => {
println!("you win!");
break;
}
}
}... | code_fim | hard | {
"lang": "rust",
"repo": "yxwsbobo/study_rust",
"path": "/src/test_projects/guess_game.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LukasKalbertodt/domsl path: /domsl-macro/src/lib.rs
#![feature(drain_filter)]
extern crate proc_macro;
use proc_macro::{TokenStream as TokenStream1};
use proc_macro2::TokenStream;
use crate::error::Error;
mod component;
mod error;
mod jsx;
mod html;
<|fim_suffix|>#[proc_macro_attribute]
p... | code_fim | hard | {
"lang": "rust",
"repo": "LukasKalbertodt/domsl",
"path": "/domsl-macro/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[proc_macro_attribute]
pub fn component(attrs: TokenStream1, input: TokenStream1) -> TokenStream1 {
component::run(attrs.into(), input.into())
.unwrap_or_else(|e| e.stmt_error_tokens())
.into()
}<|fim_prefix|>// repo: LukasKalbertodt/domsl path: /domsl-macro/src/lib.rs
#![feature(dra... | code_fim | hard | {
"lang": "rust",
"repo": "LukasKalbertodt/domsl",
"path": "/domsl-macro/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> jsx::gen(&item, &document)
}
run(input.into())
.unwrap_or_else(|e| e.expr_error_tokens())
.into()
}
#[proc_macro_attribute]
pub fn component(attrs: TokenStream1, input: TokenStream1) -> TokenStream1 {
component::run(attrs.into(), input.into())
.unwrap_or_else... | code_fim | hard | {
"lang": "rust",
"repo": "LukasKalbertodt/domsl",
"path": "/domsl-macro/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: eranfu/leetcode path: /examples/5863_统计特殊四元组.rs
//! [5863. 统计特殊四元组](https://leetcode-cn.com/contest/weekly-contest-257/problems/count-special-quadruplets/)
impl Solution {
pub fn count_quadruplets(nums: Vec<i32>) -> i32 {
let mut count = 0;
Self::count_rec(&nums, 0, 0, &mut ... | code_fim | hard | {
"lang": "rust",
"repo": "eranfu/leetcode",
"path": "/examples/5863_统计特殊四元组.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if nums.is_empty() {
return;
}
if selected_count == 3 && selected_sum == nums[0] {
*count += 1;
}
Self::count_rec(&nums[1..], selected_count, selected_sum, count);
if selected_count < 3 {
Self::count_rec(
&... | code_fim | medium | {
"lang": "rust",
"repo": "eranfu/leetcode",
"path": "/examples/5863_统计特殊四元组.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ambaxter/metis-rs path: /metis-core/tests/static_fact_test.rs
#[macro_use] extern crate itertools;
use itertools::Itertools;
use metis_core_derive::MetisFact;
use std::collections::HashSet;
use metis_core::{EqTest, FactFn, STest, HashEqItemIterator, FieldIdGen, StringInterner, StaticFactHashEq, ... | code_fim | hard | {
"lang": "rust",
"repo": "ambaxter/metis-rs",
"path": "/metis-core/tests/static_fact_test.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn runrunrun<T: MetisFact>(t: T) {
let mut s = StringInterner::new();
s.get_or_intern("nono");
for i in t.exhaustive_hash_eq(&s) {
println!("{:?}", i);
}
}
#[test]
pub fn it_works_2() {
let mut test_box = Test { a: true, e: false, b: 0, c: 0.0f64, d: "nono".into() };
runrunrun(test_b... | code_fim | hard | {
"lang": "rust",
"repo": "ambaxter/metis-rs",
"path": "/metis-core/tests/static_fact_test.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in 0..stage.tiles.len() {
for j in 0..VERT_TILE_NUM {
stage.tiles[i].push(Tile {
rect: sdl2::rect::Rect::new((i as f64 * (GAME_AREA_WIDTH as f64 / HORIZ_TILE_NUM as f64)).round() as i32, (j as f64 * (GAME_AREA_HEIGHT as f64 / VERT_TILE_NUM as f64)).round() as ... | code_fim | hard | {
"lang": "rust",
"repo": "bashawhm/Tiles_2",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bashawhm/Tiles_2 path: /src/main.rs
extern crate sdl2;
use sdl2::event::Event;
use sdl2::keyboard::Keycode;
use sdl2::image::InitFlag;
static NAME: &str = "Tiles 2";
const WIDTH: u32 = 800;
const HEIGHT: u32 = 600;
static FPS: u32 = 60;
const HORIZ_TILE_NUM: usize = 16;
const VERT_TILE_NUM: us... | code_fim | hard | {
"lang": "rust",
"repo": "bashawhm/Tiles_2",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>"#;
fn main() {
console_error_panic_hook::set_once();
let root = document()
.query_selector("#root")
.ok()
.flatten()
.expect_throw("failed to query root element");
let mut bridge =
MarkdownWorker::spawner().spawn_with_loader("/example_markdown_worker... | code_fim | medium | {
"lang": "rust",
"repo": "rustwasm/gloo",
"path": "/examples/markdown/src/bin/example_markdown_app.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rustwasm/gloo path: /examples/markdown/src/bin/example_markdown_app.rs
use example_markdown::MarkdownWorker;
use wasm_bindgen::prelude::*;
use gloo::utils::document;
use gloo::worker::Spawnable;
use wasm_bindgen_futures::spawn_local;
<|fim_suffix|> console_error_panic_hook::set_once();
... | code_fim | medium | {
"lang": "rust",
"repo": "rustwasm/gloo",
"path": "/examples/markdown/src/bin/example_markdown_app.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>define_ap_register!(
/// Identification Register
///
/// The identification register is used to identify
/// an AP.
///
/// It has to be present on every AP.
GenericAp,
IDR,
0x0FC,
[
(REVISION: u8),
(DESIGNER: u16),
(CLASS: ApClass),
... | code_fim | hard | {
"lang": "rust",
"repo": "perlindgren/probe-rs",
"path": "/probe-rs/src/architecture/arm/ap/generic_ap.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: perlindgren/probe-rs path: /probe-rs/src/architecture/arm/ap/generic_ap.rs
//! Generic access port
use super::{AccessPort, ApRegister, Register};
use crate::architecture::arm::ApAddress;
use enum_primitive_derive::Primitive;
use num_traits::cast::{FromPrimitive, ToPrimitive};
#[derive(Debug, P... | code_fim | hard | {
"lang": "rust",
"repo": "perlindgren/probe-rs",
"path": "/probe-rs/src/architecture/arm/ap/generic_ap.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> ApType::JtagComAp
}
}
define_ap!(GenericAp);
define_ap_register!(
/// Identification Register
///
/// The identification register is used to identify
/// an AP.
///
/// It has to be present on every AP.
GenericAp,
IDR,
0x0FC,
[
(REVISION: u8),
... | code_fim | hard | {
"lang": "rust",
"repo": "perlindgren/probe-rs",
"path": "/probe-rs/src/architecture/arm/ap/generic_ap.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let fizzbuzzies = [15, 30, 45, 60];
for x in fizzbuzzies.iter() {
assert_eq!(generate_str(*x), "FizzBuzz");
}
}<|fim_prefix|>// repo: folkengine/rusty-fizzbuzz path: /src/main.rs
struct ModGuard {
val: u32,
display: &'static str
}
fn g... | code_fim | hard | {
"lang": "rust",
"repo": "folkengine/rusty-fizzbuzz",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn is_buzz_test() {
let buzzies = [5, 10, 20];
for x in buzzies.iter() {
assert_eq!(generate_str(*x), "Buzz");
}
}
#[test]
fn is_fizzbuzz_test() {
let fizzbuzzies = [15, 30, 45, 60];
for x in fizzbuzzies.iter() {
assert_eq!(generate_str(*x), "FizzBuzz");
... | code_fim | medium | {
"lang": "rust",
"repo": "folkengine/rusty-fizzbuzz",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: folkengine/rusty-fizzbuzz path: /src/main.rs
struct ModGuard {
val: u32,
display: &'static str
}
fn get_fizzbuzz_guards() -> Vec<ModGuard> {
vec![
ModGuard{val: 3, display: "Fizz"},
ModGuard{val: 5, display: "Buzz"}]
}
fn gen... | code_fim | hard | {
"lang": "rust",
"repo": "folkengine/rusty-fizzbuzz",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // PCLK1 Configuration
// PPRE1: APB Low-speed prescaler (APB1)
// => APB low-speed clock frequency = AHB clock / 4 = 216 Mhz / 4 = 54 MHz
// FIXME: Frequency should not exceed 45 MHz
rcc.cfgr.update(|r| r.set_ppre1(DIVIDE_4));
// PCLK2 Configuration
// PPRE2: APB high-speed pr... | code_fim | hard | {
"lang": "rust",
"repo": "andreytkachenko/stm32f7-discovery",
"path": "/src/system_clock.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> const DIVIDE_2: u8 = 0b100;
const DIVIDE_4: u8 = 0b101;
// PCLK1 Configuration
// PPRE1: APB Low-speed prescaler (APB1)
// => APB low-speed clock frequency = AHB clock / 4 = 216 Mhz / 4 = 54 MHz
// FIXME: Frequency should not exceed 45 MHz
rcc.cfgr.update(|r| r.set_ppre1(DIVID... | code_fim | hard | {
"lang": "rust",
"repo": "andreytkachenko/stm32f7-discovery",
"path": "/src/system_clock.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: andreytkachenko/stm32f7-discovery path: /src/system_clock.rs
use board::rcc::Rcc;
use board::pwr::Pwr;
use board::flash::Flash;
use cortex_m::peripheral;
use core::sync::atomic::{AtomicUsize, Ordering};
static TICKS: AtomicUsize = AtomicUsize::new(0);
pub extern "C" fn systick() {
TICKS.f... | code_fim | hard | {
"lang": "rust",
"repo": "andreytkachenko/stm32f7-discovery",
"path": "/src/system_clock.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: NoamDev/rust-tvm path: /src/stack/integer/serialization/unsigned_big_endian.rs
/*
* Copyright 2018-2020 TON DEV SOLUTIONS LTD.
*
* Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use
* this file except in compliance with the License.
*
* Unless required by applicable ... | code_fim | hard | {
"lang": "rust",
"repo": "NoamDev/rust-tvm",
"path": "/src/stack/integer/serialization/unsigned_big_endian.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Serializer<IntegerData> for UnsignedIntegerBigEndianEncoding {
fn try_serialize(&self, value: &IntegerData) -> Result<BuilderData> {
if value.is_neg() || !value.ufits_in(self.length_in_bits) {
// Spec. 3.2.7
// * If the integer x to be serialized is not in the rang... | code_fim | hard | {
"lang": "rust",
"repo": "NoamDev/rust-tvm",
"path": "/src/stack/integer/serialization/unsigned_big_endian.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut buffer = value.to_bytes_be();
buffer = extend_buffer_be(buffer, self.length_in_bits, false);
BuilderData::with_raw(buffer, self.length_in_bits)
}
}
impl Deserializer<IntegerData> for UnsignedIntegerBigEndianEncoding {
fn deserialize(&self, data: &[u8]) -> IntegerD... | code_fim | hard | {
"lang": "rust",
"repo": "NoamDev/rust-tvm",
"path": "/src/stack/integer/serialization/unsigned_big_endian.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: silkworm-rs/silkworm path: /silkworm_sourcemap/src/span.rs
use std::fmt::Display;
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
pub struct Span {
pub base: u32,
pub len: u32,
}
impl Span {
pub fn new(base: u32, len: u32) -> Self {
Span { base, len }
}
/// Retu... | code_fim | hard | {
"lang": "rust",
"repo": "silkworm-rs/silkworm",
"path": "/silkworm_sourcemap/src/span.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Returns an empty span at the end of the current span.
pub fn empty_end(self) -> Span {
Span::new(self.base + self.len, 0)
}
/// Returns the corresponding slice from source.
///
/// # Panics
///
/// If the span is out=of-bounds for source.
pub fn read(self, ... | code_fim | hard | {
"lang": "rust",
"repo": "silkworm-rs/silkworm",
"path": "/silkworm_sourcemap/src/span.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: colatkinson/telnet_server path: /src/cmds.rs
//! Code related to the various programs that may be run by users.
use std;
use util::Context;
use std::io::Result;
/// The `Command` type.
///
/// Essentially a list of the supported commands on the server.
pub enum Command {
/// Prints out a ... | code_fim | hard | {
"lang": "rust",
"repo": "colatkinson/telnet_server",
"path": "/src/cmds.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("Hi {}! (Most) computers use binary!", cxt.user);
let mut asdf = String::new();
std::io::stdin().read_line(&mut asdf).unwrap();
std::io::stdin().read_line(&mut asdf).unwrap();
println!("[{}]", asdf);
}
impl Command {
/// Runs the current command. Returns a `std::io::Resul... | code_fim | medium | {
"lang": "rust",
"repo": "colatkinson/telnet_server",
"path": "/src/cmds.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: evq/atsaml11xxx path: /src/gclk/mod.rs
#[doc = r" Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - Control"]
pub ctrla: CTRLA,
_reserved0: [u8; 3usize],
#[doc = "0x04 - Synchronization Busy"]
pub syncbusy: SYNCBUSY,
_reserved1: [u8; 24usize],
#[d... | code_fim | hard | {
"lang": "rust",
"repo": "evq/atsaml11xxx",
"path": "/src/gclk/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
register: ::vcell::VolatileCell<u32>,
}
#[doc = "Generic Clock Generator Control"]
pub mod genctrl;
#[doc = "Peripheral Clock Control"]
pub struct PCHCTRL {
register: ::vcell::VolatileCell<u32>,
}
#[doc = "Peripheral Clock Control"]
pub mod pchctrl;<|fim_prefix|>// repo: evq/atsaml11xxx path: /s... | code_fim | hard | {
"lang": "rust",
"repo": "evq/atsaml11xxx",
"path": "/src/gclk/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: flattiverse/connector-rust path: /src/units/player_unit.rs
use crate::controllable::ControllableId;
use crate::events::Completable;
use crate::players::PlayerId;
use crate::units::player_unit_system::PlayerUnitSystem;
use crate::units::player_unit_system_kind::{
ArmorSystem, EnergyConsumingS... | code_fim | hard | {
"lang": "rust",
"repo": "flattiverse/connector-rust",
"path": "/src/units/player_unit.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.hull.complete(&(PlayerUnitSystemKind::Hull, group));
self.cells_energy
.complete(&(PlayerUnitSystemKind::CellsEnergy, group));
self.battery_energy
.complete(&(PlayerUnitSystemKind::BatteryEnergy, group));
self.thruster
.complete(&(Pl... | code_fim | hard | {
"lang": "rust",
"repo": "flattiverse/connector-rust",
"path": "/src/units/player_unit.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.armor.complete(&(PlayerUnitSystemKind::Armor, group));
self.shield.complete(&(PlayerUnitSystemKind::Shield, group));
self.analyzer
.complete(&(PlayerUnitSystemKind::Analyzer, group));
self.cells_particles
.complete(&(PlayerUnitSystemKind::CellsP... | code_fim | hard | {
"lang": "rust",
"repo": "flattiverse/connector-rust",
"path": "/src/units/player_unit.rs",
"mode": "spm",
"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.