text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: superphunthyme/raytracer path: /src/sphere.rs
use crate::aabb::AABB;
use crate::hitable::HitRecord;
use crate::hitable::Hitable;
use crate::material::Material;
use crate::ray::Ray;
use crate::vec3::Vector3;
#[derive(Clone)]
pub struct Sphere {
center: Vector3,
radius: f32,
material:... | code_fim | hard | {
"lang": "rust",
"repo": "superphunthyme/raytracer",
"path": "/src/sphere.rs",
"mode": "psm",
"license": "Zlib",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/object/src/write/mod.rs
add_section
(
&
mut
self
segment
:
Vec
<
u8
>
name
:
Vec
<
u8
>
kind
:
SectionKind
)
-
>
SectionId
{
let
id
=
SectionId
(
self
.
sections
.
len
(
)
)
;
self
.
sections
.
push
(
Section
{
segment
name
kind
size
:
0
align... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/object/src/write/mod.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>ustive
]
pub
enum
StandardSection
{
Text
Data
ReadOnlyData
ReadOnlyDataWithRel
ReadOnlyString
UninitializedData
Tls
/
/
/
Zero
-
fill
TLS
initializers
.
Unsupported
for
COFF
.
UninitializedTls
/
/
/
TLS
variable
structures
.
Only
supported
for
Mach
-
O
.
TlsVariables
/
/
/
Common
data
.
Only
supported
for... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/object/src/write/mod.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/object/src/write/mod.rs
s
(
)
_
=
>
unimplemented
!
(
)
}
}
fn
subsection_info
(
&
self
section
:
StandardSection
value
:
&
[
u8
]
)
-
>
(
&
'
static
[
u8
]
Vec
<
u8
>
SectionKind
)
{
let
(
segment
section
kind
)
=
self
.
section_info
(
section... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/object/src/write/mod.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> no_kwargs!(vm, args);
let (cls, start, stop, step): (
&PyObjectRef,
Option<&PyObjectRef>,
Option<&PyObjectRef>,
Option<&PyObjectRef>,
) = match args.args.len() {
0 | 1 => Err(vm.new_type_error("slice() must have at least one arguments.".to_owned())),
... | code_fim | hard | {
"lang": "rust",
"repo": "dkaste/RustPython",
"path": "/vm/src/obj/objslice.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn init(context: &PyContext) {
let slice_type = &context.slice_type;
extend_class!(context, slice_type, {
"__new__" => context.new_rustfunc(slice_new),
"start" => context.new_property(PySliceRef::start),
"stop" => context.new_property(PySliceRef::stop),
"step" ... | code_fim | hard | {
"lang": "rust",
"repo": "dkaste/RustPython",
"path": "/vm/src/obj/objslice.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dkaste/RustPython path: /vm/src/obj/objslice.rs
use num_bigint::BigInt;
use crate::function::PyFuncArgs;
use crate::pyobject::{PyContext, PyObjectRef, PyRef, PyResult, PyValue, TypeProtocol};
use crate::vm::VirtualMachine;
use super::objint;
use crate::obj::objtype::PyClassRef;
#[derive(Debug... | code_fim | hard | {
"lang": "rust",
"repo": "dkaste/RustPython",
"path": "/vm/src/obj/objslice.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub(crate) use backends::*;
pub(crate) use states::*;<|fim_prefix|>// repo: hasp-rs/hasp path: /hasp/src/ops/mod.rs
// Copyright (c) The hasp Contributors
// SPDX-License-Identifier: MIT OR Apache-2.0
<|fim_middle|>mod backends;
mod states;
| code_fim | easy | {
"lang": "rust",
"repo": "hasp-rs/hasp",
"path": "/hasp/src/ops/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hasp-rs/hasp path: /hasp/src/ops/mod.rs
// Copyright (c) The hasp Contributors
// SPDX-License-Identifier: MIT OR Apache-2.0
<|fim_suffix|>pub(crate) use backends::*;
pub(crate) use states::*;<|fim_middle|>mod backends;
mod states;
| code_fim | easy | {
"lang": "rust",
"repo": "hasp-rs/hasp",
"path": "/hasp/src/ops/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn attach_list_table() {
let table = AttachList::read(test_data::ATTACHLIST_TABLE.into()).unwrap();
assert_eq!(table.glyph_count(), 2);
assert_eq!(table.attach_point_offsets().len(), 2);
let attach_point = table.attach_points().get(1).unwrap();
assert_eq!(attach_point.point_ind... | code_fim | hard | {
"lang": "rust",
"repo": "chromium/chromium",
"path": "/third_party/rust/read_fonts/v0_10/crate/src/tests/test_gdef.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chromium/chromium path: /third_party/rust/read_fonts/v0_10/crate/src/tests/test_gdef.rs
use types::{GlyphId, MajorMinor};
use super::*;
use crate::tables::layout::{ClassDefFormat2, DeltaFormat, DeviceOrVariationIndex};
use font_test_data::gdef as test_data;
#[test]
fn gdef_header() {
let t... | code_fim | hard | {
"lang": "rust",
"repo": "chromium/chromium",
"path": "/third_party/rust/read_fonts/v0_10/crate/src/tests/test_gdef.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn caretvalueformat3() {
let table = CaretValueFormat3::read(test_data::CARETVALUEFORMAT3_TABLE.into()).unwrap();
assert_eq!(table.coordinate(), 1206);
let DeviceOrVariationIndex::Device(device) = table.device().unwrap() else {
panic!("not a device table");
};
assert_eq... | code_fim | hard | {
"lang": "rust",
"repo": "chromium/chromium",
"path": "/third_party/rust/read_fonts/v0_10/crate/src/tests/test_gdef.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> //所有权转移
let s = "hello";
let handle2 = thread::spawn(move || {
println!("s in spawned thread:{}", s);
});
handle2.join().unwrap();
//消息传递
let (tx, rx) = mpsc::channel();
thread::spawn(move || {
let val = String::from("hi");
tx.send(val).unwrap();
... | code_fim | hard | {
"lang": "rust",
"repo": "qatix/RustBase",
"path": "/src/mythread.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
//消息传递
let (tx, rx) = mpsc::channel();
thread::spawn(move || {
let val = String::from("hi");
tx.send(val).unwrap();
});
let received = rx.recv().unwrap();
println!("Got:{}", received);
}<|fim_prefix|>// repo: qatix/RustBase path: /src/mythread.rs
use std::sync::mp... | code_fim | medium | {
"lang": "rust",
"repo": "qatix/RustBase",
"path": "/src/mythread.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: qatix/RustBase path: /src/mythread.rs
use std::sync::mpsc;
use std::thread;
use std::time::Duration;
fn spawn_function() {
for i in 0..5 {
println!("spawned thread print:{}", i);
thread::sleep(Duration::from_millis(10));
}
}
pub fn thread_test() {
thread::spawn(spaw... | code_fim | hard | {
"lang": "rust",
"repo": "qatix/RustBase",
"path": "/src/mythread.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ki { right: 7, down: 1 }.ski(&hills);
total *= toboggan_trajectory_1::Ski { right: 1, down: 2 }.ski(&hills);
total.to_string()
}<|fim_prefix|>// repo: pfesenmeier/advent_of_code_2020 path: /src/toboggan_trajectory_2.rs
use crate::toboggan_trajectory_1;
pub fn run(file: &str) -> String {
let hi... | code_fim | medium | {
"lang": "rust",
"repo": "pfesenmeier/advent_of_code_2020",
"path": "/src/toboggan_trajectory_2.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>down: 1 }.ski(&hills);
total *= toboggan_trajectory_1::Ski { right: 5, down: 1 }.ski(&hills);
total *= toboggan_trajectory_1::Ski { right: 7, down: 1 }.ski(&hills);
total *= toboggan_trajectory_1::Ski { right: 1, down: 2 }.ski(&hills);
total.to_string()
}<|fim_prefix|>// repo: pfesenmeier/... | code_fim | medium | {
"lang": "rust",
"repo": "pfesenmeier/advent_of_code_2020",
"path": "/src/toboggan_trajectory_2.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pfesenmeier/advent_of_code_2020 path: /src/toboggan_trajectory_2.rs
use crate::toboggan_trajectory_1;
pub fn run(file: &str) -> String {
let hills: Vec<&str> = file.split_ascii_whitespace().collect();
let mut total = toboggan_trajectory_1::Ski { right: 1, down: 1 }.ski(&hills);
total... | code_fim | medium | {
"lang": "rust",
"repo": "pfesenmeier/advent_of_code_2020",
"path": "/src/toboggan_trajectory_2.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: patahene/rrt path: /examples/teapot.rs
use once_cell::sync::Lazy;
use rrt::camera::Camera;
use rrt::hit::HittableList;
use rrt::model::load_obj;
use rrt::renderer::rendering;
use rrt::vec3::Vec3;
const NX: u32 = 1920 / 2;
const NY: u32 = 1080 / 2;
const NS: u32 = 100;
<|fim_suffix|> Camera:... | code_fim | hard | {
"lang": "rust",
"repo": "patahene/rrt",
"path": "/examples/teapot.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn test_scene() -> HittableList {
let mut world = HittableList::new();
let teapot = load_obj("model/teapot.obj").unwrap();
for t in teapot {
world.list.push(t);
}
dbg!(world.list.len());
world
}
fn main() {
let start = std::time::SystemTime::now();
rendering(NX, N... | code_fim | hard | {
"lang": "rust",
"repo": "patahene/rrt",
"path": "/examples/teapot.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Iterator)]
struct Numbers<'a> {
numbers: ::core::slice::Iter<'a, i32>,
}<|fim_prefix|>// repo: reynoldsbd/derive_more path: /tests/iterator.rs
#![allow(dead_code, unused_imports)]
#[macro_use]
extern crate derive_more;
<|fim_middle|>#[derive(Iterator)]
struct MyVec<'a>(::core::slice::Iter<'... | code_fim | medium | {
"lang": "rust",
"repo": "reynoldsbd/derive_more",
"path": "/tests/iterator.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: reynoldsbd/derive_more path: /tests/iterator.rs
#![allow(dead_code, unused_imports)]
#[macro_use]
extern crate derive_more;
<|fim_suffix|>#[derive(Iterator)]
struct Numbers<'a> {
numbers: ::core::slice::Iter<'a, i32>,
}<|fim_middle|>#[derive(Iterator)]
struct MyVec<'a>(::core::slice::Iter<'... | code_fim | medium | {
"lang": "rust",
"repo": "reynoldsbd/derive_more",
"path": "/tests/iterator.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ataffanel/crazyflie2-stm-bootloader-rs path: /src/syslink.rs
use embedded_hal::serial;
use embedded_hal::digital::v2::InputPin;
#[derive(Clone)]
pub struct SyslinkPacket {
pub packet_type: u8,
pub buffer: [u8; 32],
pub length: usize,
cksum: u16,
}
impl Default for SyslinkPacke... | code_fim | hard | {
"lang": "rust",
"repo": "ataffanel/crazyflie2-stm-bootloader-rs",
"path": "/src/syslink.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn send(&mut self, packet: &SyslinkPacket) -> nb::Result<(), nb::Error<()>> {
nb::block!(self.tx.write(0xbc)).ok();
nb::block!(self.tx.write(0xcf)).ok();
nb::block!(self.tx.write(packet.packet_type)).ok();
nb::block!(self.tx.write(packet.length as u8)).ok();
... | code_fim | hard | {
"lang": "rust",
"repo": "ataffanel/crazyflie2-stm-bootloader-rs",
"path": "/src/syslink.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JustinUnger/rust path: /splitter/src/splitter.rs
//use std::rand::random;
extern crate rand;
use std::env;
use std::path::Path;
use std::fs::File;
use rand::Rng;
fn main() {
let args: env::Args = env::args();
if args.count() != 2 {
println!("Usage: {} <inputfile>", args.nth(0... | code_fim | hard | {
"lang": "rust",
"repo": "JustinUnger/rust",
"path": "/splitter/src/splitter.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn split(msg_bytes: &[u8], mut share1: File, mut share2: File) {
let mut random_bytes: Vec<u8> = vec![];
let mut rng = rand::thread_rng();
// This is not cryptographically strong randomness!
// (For entertainment purposes only.)
for _ in 0..msg_bytes.len() {
let random_byte = ... | code_fim | medium | {
"lang": "rust",
"repo": "JustinUnger/rust",
"path": "/splitter/src/splitter.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: laopo001/leetcode-rust path: /src/main.rs
#![allow(unused)]
use leetcode::base::{num_to_string, string_to_num, JsArray, ListNode, TreeNode};
use leetcode::find_common_characters;
use leetcode::longest_palindromic_substring;
use leetcode::remove_nth_node_from_end_of_list;
use std::cell::Re... | code_fim | hard | {
"lang": "rust",
"repo": "laopo001/leetcode-rust",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> t.baz();
}
let foo = Foo;
static_dispatch(&foo);
dynamic_dispatch(&foo);
///
let mut arr = vec![1];
let q = arr.find_mut(|&x| x == 1).unwrap();
*q = *q + 9;
println!("{:?}", *q);
///
let mut a = vec![1, 2];
let mut count = 0;
a.for_e... | code_fim | hard | {
"lang": "rust",
"repo": "laopo001/leetcode-rust",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match mt {
MsgType::DuplicateRuleIdentifier => ErrorMsg {
short: "rule with the same identifier is already defined".into(),
extended: None,
},
MsgType::InvalidRuleIdentifier => ErrorMsg {
short: "expected rule identifier followed by an assignment token '=', '/... | code_fim | hard | {
"lang": "rust",
"repo": "anweiss/cddl",
"path": "/src/error.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: anweiss/cddl path: /src/error.rs
use std::fmt;
#[cfg(target_arch = "wasm32")]
use serde::Serialize;
#[cfg(not(feature = "std"))]
use alloc::string::String;
#[cfg_attr(target_arch = "wasm32", derive(Serialize))]
#[derive(Debug, Clone)]
pub struct ErrorMsg {
pub short: String,
pub extended:... | code_fim | hard | {
"lang": "rust",
"repo": "anweiss/cddl",
"path": "/src/error.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut gpioa = dp.GPIOA.split(& mut rcc.ahb);
// set pin to open drain output mode
let mut pa3 = gpioa.pa3.into_open_drain_output(&mut gpioa.moder,&mut gpioa.otyper);
pa3.internal_pull_up(&mut gpioa.pupdr,true);
// infinite loop begin
loop{
// wait for 2sec make sure D... | code_fim | hard | {
"lang": "rust",
"repo": "jamil4321/dht_sensor_rust",
"path": "/example/example_code.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jamil4321/dht_sensor_rust path: /example/example_code.rs
#![no_std]
#![no_main]
#[allow(unused_extern_crates)] // NOTE(allow) bug rust-lang/rust53964
extern crate panic_itm; // panic handler
use cortex_m::{iprint, iprintln};
use cortex_m_rt::entry;
use f3::hal::delay::Delay;
use f3::hal::{prelu... | code_fim | hard | {
"lang": "rust",
"repo": "jamil4321/dht_sensor_rust",
"path": "/example/example_code.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match oc {
1 => { // add
self.set_param(2, self.get_param(0)? + self.get_param(1)?)?;
self.ip += 4;
},
2 => { // mul
self.set_param(2, self.get_param(0)? * self.get_param(1)?)?;
... | code_fim | hard | {
"lang": "rust",
"repo": "matushorvath/xzintbit",
"path": "/vms/rust/ic.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: matushorvath/xzintbit path: /vms/rust/ic.rs
use std::env;
use std::fs;
use std::io;
use std::io::prelude::*;
struct Vm {
ip: usize,
rb: i32,
mem: Vec<i32>
}
impl Vm {
pub fn new() -> Vm {
Vm {
ip: 0,
rb: 0,
mem: vec![0; 64]
}
... | code_fim | hard | {
"lang": "rust",
"repo": "matushorvath/xzintbit",
"path": "/vms/rust/ic.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Use Stellar Test Network.
pub fn test_network() -> Network {
Network::new(String::from(TESTNET))
}
}<|fim_prefix|>// repo: sphinxc0re/stellar-rs path: /src/network.rs
use util;
const PUBLIC: &str = "Public Global Stellar Network ; September 2015";
const TESTNET: &str = "Test SDF N... | code_fim | hard | {
"lang": "rust",
"repo": "sphinxc0re/stellar-rs",
"path": "/src/network.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sphinxc0re/stellar-rs path: /src/network.rs
use util;
const PUBLIC: &str = "Public Global Stellar Network ; September 2015";
const TESTNET: &str = "Test SDF Network ; September 2015";
/// Network class is used to specify which Stellar network you want to use.
/// Each network has a `network_pa... | code_fim | hard | {
"lang": "rust",
"repo": "sphinxc0re/stellar-rs",
"path": "/src/network.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn match_ascii() {
assert_eq!(Any.parse("hello"), Ok(Span::new(0..1, 'h')));
}
#[test]
fn match_utf8() {
assert_eq!(Any.parse("💩"), Ok(Span::new(0..4, '💩')));
}
#[test]
fn match_grapheme() {
assert_eq!(Any.parse("नि"), Ok(Span::new(0..3, ... | code_fim | hard | {
"lang": "rust",
"repo": "connec/packrs",
"path": "/src/expression/any.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: connec/packrs path: /src/expression/any.rs
//! An expression that consumes any single character.
//!
//! See [`crate::any`].
use crate::error::UnexpectedEndOfInput;
use crate::parser::Parser;
use crate::span::Span;
/// The struct returned from [`crate::any`].
pub struct Any;
<|fim_suffix|> ... | code_fim | hard | {
"lang": "rust",
"repo": "connec/packrs",
"path": "/src/expression/any.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: InputUsername/adventofcode path: /2015/day16/src/main.rs
use std::collections::HashMap;
fn parse_sample() -> HashMap<String, u32> {
let s = "children: 3
cats: 7
samoyeds: 2
pomeranians: 3
akitas: 0
vizslas: 0
goldfish: 5
trees: 3
cars: 2
perfumes: 1";
s.lines()
.map(|l| {
... | code_fim | hard | {
"lang": "rust",
"repo": "InputUsername/adventofcode",
"path": "/2015/day16/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for (i, properties) in input.iter().enumerate() {
let count = properties
.iter()
.filter(|&(p, n)| sample.get(p).unwrap() == n)
.count();
if count > max_count {
max_count = count;
max = i;
}
}
println!("{}", ... | code_fim | hard | {
"lang": "rust",
"repo": "InputUsername/adventofcode",
"path": "/2015/day16/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> {
let camera = self
.camera
.upgrade()
.expect("Failed to upgrade camera handle.");
let mut borrowed_camera = camera.borrow_mut();
borrowed_camera.target.x = ... | code_fim | hard | {
"lang": "rust",
"repo": "deadshot465/demo_game",
"path": "/src/game/scenes/game_scene.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> {
let camera = self
.camera
.upgrade()
.expect("Failed to upgrade camera handle.");
let mut borrowed_camera = camera.borrow_mut();
borrowed_camera.target.x = x;
borrowed_camera.target.y = y;
... | code_fim | hard | {
"lang": "rust",
"repo": "deadshot465/demo_game",
"path": "/src/game/scenes/game_scene.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: deadshot465/demo_game path: /src/game/scenes/game_scene.rs
ntities.insert(entity_name.to_string(), entity);
entity
}
fn add_model(
&mut self,
file_name: &'static str,
position: Vec3A,
scale: Vec3A,
rotation: Vec3A,
color: Vec4,
... | code_fim | hard | {
"lang": "rust",
"repo": "deadshot465/demo_game",
"path": "/src/game/scenes/game_scene.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: adrianncovaci/somipp-labs path: /simple-cli/src/to_do/help.rs
pub fn help() {
println!();
println!("Available commands: ");
println!();
//todo command
println!("to-do module helps you manage to-do notes");
println!("{:<4}todo get -> lists the created notes", "");
prin... | code_fim | hard | {
"lang": "rust",
"repo": "adrianncovaci/somipp-labs",
"path": "/simple-cli/src/to_do/help.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ex", "");
println!();
//clr
println!("clr -> clears the screen");
println!();
//touch
println!("touch -> creates a new emtpy file");
println!("{:<4}touch file.txt -> creates a an empty .txt file", "");
println!();
//ls
println!("ls -> lists files from the directory"... | code_fim | hard | {
"lang": "rust",
"repo": "adrianncovaci/somipp-labs",
"path": "/simple-cli/src/to_do/help.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(true, Solution::can_jump(vec![2, 3, 1, 1, 4]));
assert_eq!(false, Solution::can_jump(vec![3, 2, 1, 0, 4]));
}<|fim_prefix|>// repo: MSDimos/leetcode-rust2018 path: /Q55-jump-game/src/main.rs
struct Solution {}
impl Solution {
pub fn can_jump(nums: Vec<i32>) -> bool {
let m... | code_fim | medium | {
"lang": "rust",
"repo": "MSDimos/leetcode-rust2018",
"path": "/Q55-jump-game/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MSDimos/leetcode-rust2018 path: /Q55-jump-game/src/main.rs
struct Solution {}
impl Solution {
pub fn can_jump(nums: Vec<i32>) -> bool {
let mut max_pos = 0;
let mut end_pos = 0;
let len = nums.len() as i32;
<|fim_suffix|> assert_eq!(true, Solution::can_jump(vec![... | code_fim | hard | {
"lang": "rust",
"repo": "MSDimos/leetcode-rust2018",
"path": "/Q55-jump-game/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> my_collection.push(my_struct_1.clone());
//my_collection.push(my_struct_2);
let mut my_collection: Vec<Box<dyn MyTrait>> = vec![];
my_collection.push(Box::new(my_struct_1));
my_collection.push(Box::new(my_struct_2));
}<|fim_prefix|>// repo: nuxeh/rusty-examples path: /examples/trait... | code_fim | medium | {
"lang": "rust",
"repo": "nuxeh/rusty-examples",
"path": "/examples/trait_object.rs",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|> my_collection.push(Box::new(my_struct_1));
my_collection.push(Box::new(my_struct_2));
}<|fim_prefix|>// repo: nuxeh/rusty-examples path: /examples/trait_object.rs
trait MyTrait {}
#[derive(Clone)]
struct MyStruct1 (u8);
struct MyStruct2 (u8);
impl MyTrait for MyStruct1 {}
impl MyTrait for MyStr... | code_fim | hard | {
"lang": "rust",
"repo": "nuxeh/rusty-examples",
"path": "/examples/trait_object.rs",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nuxeh/rusty-examples path: /examples/trait_object.rs
trait MyTrait {}
#[derive(Clone)]
struct MyStruct1 (u8);
struct MyStruct2 (u8);
impl MyTrait for MyStruct1 {}
impl MyTrait for MyStruct2 {}
fn main() {
<|fim_suffix|> let mut my_collection: Vec<Box<dyn MyTrait>> = vec![];
my_collect... | code_fim | hard | {
"lang": "rust",
"repo": "nuxeh/rusty-examples",
"path": "/examples/trait_object.rs",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|>// Arabic joining masks.
pub const ISOL_MASK: u8 = 1;
pub const INIT_MASK: u8 = 2;
pub const MEDI_MASK: u8 = 4;
pub const FINA_MASK: u8 = 8;
pub const MED2_MASK: u8 = 16;
pub const FIN2_MASK: u8 = 32;
pub const FIN3_MASK: u8 = 64;
pub const NONE_MASK: u8 = 0;
// Hangul jamo masks.
pub const LJMO_MASK: u8... | code_fim | hard | {
"lang": "rust",
"repo": "geom3trik/swash",
"path": "/src/shape/feature.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: geom3trik/swash path: /src/shape/feature.rs
//! Feature constants.
use super::internal::{raw_tag, RawTag};
// Default tag used in various places.
pub const _DFLT: RawTag = raw_tag(b"DFLT");
// Substitution features.
pub const CCMP: RawTag = raw_tag(b"ccmp");
pub const LOCL: RawTag = raw_tag(b... | code_fim | hard | {
"lang": "rust",
"repo": "geom3trik/swash",
"path": "/src/shape/feature.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.word(if lit.value { "true" } else { "false" });
}
fn lit_verbatim(&mut self, token: &Literal) {
self.word(token.to_string());
}
}<|fim_prefix|>// repo: ric2b/Vivaldi-browser path: /chromium/third_party/rust/prettyplease/v0_1/crate/src/lit.rs
use crate::algorithm::Printer... | code_fim | hard | {
"lang": "rust",
"repo": "ric2b/Vivaldi-browser",
"path": "/chromium/third_party/rust/prettyplease/v0_1/crate/src/lit.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ric2b/Vivaldi-browser path: /chromium/third_party/rust/prettyplease/v0_1/crate/src/lit.rs
use crate::algorithm::Printer;
use proc_macro2::Literal;
use syn::{Lit, LitBool, LitByte, LitByteStr, LitChar, LitFloat, LitInt, LitStr};
impl Printer {
pub fn lit(&mut self, lit: &Lit) {
match... | code_fim | hard | {
"lang": "rust",
"repo": "ric2b/Vivaldi-browser",
"path": "/chromium/third_party/rust/prettyplease/v0_1/crate/src/lit.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: matt-williams/rust-ens path: /examples/set_multihash.rs
extern crate ens;
extern crate web3;
use web3::futures::Future;
use ens::ENS;
use std::env;
fn main() {
let ens_addr = env::vars().filter(|(k, _)| k == "ENS_ADDR" ).next().map(|(_, v)| v);
let ens_root = env::vars().filter(|(k, _)... | code_fim | medium | {
"lang": "rust",
"repo": "matt-williams/rust-ens",
"path": "/examples/set_multihash.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> ens.set_multihash(&ens_root, &ens_name, new_multihash.clone()).wait().expect("set_multihash");
println!("new multihash: {:?}", new_multihash);
}<|fim_prefix|>// repo: matt-williams/rust-ens path: /examples/set_multihash.rs
extern crate ens;
extern crate web3;
use web3::futures::Future;
use ens... | code_fim | medium | {
"lang": "rust",
"repo": "matt-williams/rust-ens",
"path": "/examples/set_multihash.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn long_valid_password_without_anagrams() {
assert_eq!(
1,
count_passwords_without_anagrams(&["iiii oiii ooii oooi oooo".to_owned()])
);
}
#[test]
fn another_invalid_password_with_anagrams() {
assert_eq!(
0,
... | code_fim | hard | {
"lang": "rust",
"repo": "attilahorvath/advent-of-code-2017",
"path": "/day04/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(
1,
count_passwords_without_anagrams(&["iiii oiii ooii oooi oooo".to_owned()])
);
}
#[test]
fn another_invalid_password_with_anagrams() {
assert_eq!(
0,
count_passwords_without_anagrams(&["oiii ioii iioi iiio".... | code_fim | hard | {
"lang": "rust",
"repo": "attilahorvath/advent-of-code-2017",
"path": "/day04/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: attilahorvath/advent-of-code-2017 path: /day04/src/lib.rs
pub fn count_valid_passwords(passwords: &[String]) -> usize {
passwords.iter().filter(|p| valid_password(p)).count()
}
pub fn count_passwords_without_anagrams(passwords: &[String]) -> usize {
passwords.iter().filter(|p| !contains... | code_fim | hard | {
"lang": "rust",
"repo": "attilahorvath/advent-of-code-2017",
"path": "/day04/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: parasyte/pixels path: /examples/minimal-tao/src/main.rs
#![deny(clippy::all)]
#![forbid(unsafe_code)]
use error_iter::ErrorIter as _;
use log::error;
use pixels::{Error, Pixels, SurfaceTexture};
use tao::dpi::LogicalSize;
use tao::event::{Event, KeyEvent, WindowEvent};
use tao::event_loop::{Con... | code_fim | hard | {
"lang": "rust",
"repo": "parasyte/pixels",
"path": "/examples/minimal-tao/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl World {
/// Create a new `World` instance that can draw a moving box.
fn new() -> Self {
Self {
box_x: 24,
box_y: 16,
velocity_x: 1,
velocity_y: 1,
}
}
/// Update the `World` internal state; bounce the box around the scr... | code_fim | hard | {
"lang": "rust",
"repo": "parasyte/pixels",
"path": "/examples/minimal-tao/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(
translate_path_to_unix("d:\\test\\file.txt".to_string()),
"/mnt/d/test/file.txt"
);
assert_eq!(
translate_path_to_unix("C:\\Users\\test\\a space.txt".to_string()),
"/mnt/c/Users/test/a space.txt"
);
}
#[test]
fn unix_to_win_path_trans() {
as... | code_fim | hard | {
"lang": "rust",
"repo": "jswh/wslexe",
"path": "/src/processor.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jswh/wslexe path: /src/processor.rs
use std::borrow::Cow;
use std::env;
use std::io::{self, Write};
use std::path::{Component, Path, Prefix, PrefixComponent};
use std::process;
use std::process::{Command, Stdio};
use regex::bytes::Regex;
fn get_drive_letter(pc: &PrefixComponent) -> Option<Stri... | code_fim | hard | {
"lang": "rust",
"repo": "jswh/wslexe",
"path": "/src/processor.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn win_to_unix_path_trans() {
assert_eq!(
translate_path_to_unix("d:\\test\\file.txt".to_string()),
"/mnt/d/test/file.txt"
);
assert_eq!(
translate_path_to_unix("C:\\Users\\test\\a space.txt".to_string()),
"/mnt/c/Users/test/a space.txt"
);
}
#[test... | code_fim | hard | {
"lang": "rust",
"repo": "jswh/wslexe",
"path": "/src/processor.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn action(action: &GoAction) -> String;
fn column(x: usize) -> String;
fn line(y: usize) -> String;
}<|fim_prefix|>// repo: flegac/rust-mcts path: /go-lib/src/display/goshow.rs
use std::ops::Deref;
use bit_set::BitSet;
use crate::board::go_state::GoState;
use board::stones::group::GoGroup;
... | code_fim | hard | {
"lang": "rust",
"repo": "flegac/rust-mcts",
"path": "/go-lib/src/display/goshow.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: flegac/rust-mcts path: /go-lib/src/display/goshow.rs
use std::ops::Deref;
use bit_set::BitSet;
use crate::board::go_state::GoState;
use board::stones::group::GoGroup;
use board::stones::grouprc::GoGroupRc;
use board::stones::stone::Stone;
use display::range::Range2;
use rust_tools::screen::lay... | code_fim | medium | {
"lang": "rust",
"repo": "flegac/rust-mcts",
"path": "/go-lib/src/display/goshow.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Self::group(board, group.borrow().deref())
}
fn cell(xy: (usize, usize)) -> String;
fn cells(board: &GoState, stone: Stone, cells: &BitSet) -> String;
fn stone(stone: Stone) -> String;
fn action(action: &GoAction) -> String;
fn column(x: usize) -> String;
fn line(y: us... | code_fim | hard | {
"lang": "rust",
"repo": "flegac/rust-mcts",
"path": "/go-lib/src/display/goshow.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Sroka/arc_level_generator path: /src/generator/types/visible_world.rs
use ncollide3d::bounding_volume::AABB;
use serde::{Serialize, Deserialize};
use cr<|fim_suffix|>ze, Deserialize)]
pub struct VisibleWorld {
#[serde(serialize_with = "serialize_aabb", deserialize_with = "deserialize_aabb")]... | code_fim | medium | {
"lang": "rust",
"repo": "Sroka/arc_level_generator",
"path": "/src/generator/types/visible_world.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>e_aabb", deserialize_with = "deserialize_aabb")]
pub world_bounds: AABB<f32>,
}<|fim_prefix|>// repo: Sroka/arc_level_generator path: /src/generator/types/visible_world.rs
use ncollide3d::bounding_volume::AABB;
use serde::{Serialize, Deserialize};
use crate::generator::types::{serialize_aabb, deseria... | code_fim | medium | {
"lang": "rust",
"repo": "Sroka/arc_level_generator",
"path": "/src/generator/types/visible_world.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ze, Deserialize)]
pub struct VisibleWorld {
#[serde(serialize_with = "serialize_aabb", deserialize_with = "deserialize_aabb")]
pub world_bounds: AABB<f32>,
}<|fim_prefix|>// repo: Sroka/arc_level_generator path: /src/generator/types/visible_world.rs
use ncollide3d::bounding_volume::AABB;
use serd... | code_fim | medium | {
"lang": "rust",
"repo": "Sroka/arc_level_generator",
"path": "/src/generator/types/visible_world.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sdbondi/bn-api path: /db/src/models/reports.rs
bug, Serialize, Deserialize, PartialEq, Queryable, QueryableByName)]
pub struct TicketSalesRow {
#[sql_type = "Nullable<dUuid>"]
pub organization_id: Option<Uuid>,
#[sql_type = "Nullable<dUuid>"]
pub event_id: Option<Uuid>,
#[sql... | code_fim | hard | {
"lang": "rust",
"repo": "sdbondi/bn-api",
"path": "/db/src/models/reports.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> event_id: Option<Uuid>,
organization_id: Option<Uuid>,
start: Option<NaiveDateTime>,
end: Option<NaiveDateTime>,
conn: &PgConnection,
) -> Result<Vec<EventSummarySalesResult>, DatabaseError> {
//First get the sales summary
let query_sales = inclu... | code_fim | hard | {
"lang": "rust",
"repo": "sdbondi/bn-api",
"path": "/db/src/models/reports.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let rows: Vec<TicketSalesRow> = q
.get_results(conn)
.to_db_error(ErrorCode::QueryError, "Could not fetch ticket sales")?;
Ok(rows)
}
}
impl TicketCountRow {
pub fn fetch(
event_id: Option<Uuid>,
organization_id: Option<Uuid>,
group_... | code_fim | hard | {
"lang": "rust",
"repo": "sdbondi/bn-api",
"path": "/db/src/models/reports.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SoundRabbit/soldoresol path: /src/component/molecule/tab_modeless.rs
if let Some(self_container_rect) = self.container_rect.as_ref() {
if container_rect.width != self_container_rect.width {
let margin_ratio = self.loc[0] / (self_container_rect.width - self.size[... | code_fim | hard | {
"lang": "rust",
"repo": "SoundRabbit/soldoresol",
"path": "/src/component/molecule/tab_modeless.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SoundRabbit/soldoresol path: /src/component/molecule/tab_modeless.rs
t::Props> + Unpin> Update
for TabModeless<Content, TabName>
where
Content::Props: Clone,
{
fn on_assemble(self: Pin<&mut Self>) -> Cmd<Self> {
Cmd::list(self.state.borrow_mut().cmds.drain(..).collect())
... | code_fim | hard | {
"lang": "rust",
"repo": "SoundRabbit/soldoresol",
"path": "/src/component/molecule/tab_modeless.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Self::styled(Html::div(
Attributes::new()
.index_id(self.state.borrow().modeless_id.to_string())
.string("data-modeless-id", self.state.borrow().modeless_id.to_string())
.class(Self::class("base"))
.style("z-index", format... | code_fim | hard | {
"lang": "rust",
"repo": "SoundRabbit/soldoresol",
"path": "/src/component/molecule/tab_modeless.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jackonelli/advent_of_code path: /2020/src/bin/19.rs
use regex::Regex;
use std::collections::HashMap;
use std::fs::File;
use std::io::prelude::*;
use std::str::Split;
type Rules = HashMap<usize, Rule>;
type Candidates = Vec<String>;
fn main() {
let file = "input/19/input";
//let file = ... | code_fim | hard | {
"lang": "rust",
"repo": "jackonelli/advent_of_code",
"path": "/2020/src/bin/19.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let rules = rules.trim().lines();
let mut parsed_rules = Rules::new();
for line in rules {
let mut tmp = line.split(": ");
let rule_num = tmp
.next()
.expect("No rule num")
.parse::<usize>()
.expect("rule num parse");
let... | code_fim | hard | {
"lang": "rust",
"repo": "jackonelli/advent_of_code",
"path": "/2020/src/bin/19.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn for_loop() -> i32 {
let mut out = 0;
for _ in 0..10 {
out += 1;
}
return out;
}
fn while_loop() -> i32 {
let mut out = 0;
while out < 10 {
out += 1;
}
return out;
}<|fim_prefix|>// repo: calewis/LearnRust path: /variables_chap3/src/main.rs
use rand::Rng... | code_fim | hard | {
"lang": "rust",
"repo": "calewis/LearnRust",
"path": "/variables_chap3/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn while_loop() -> i32 {
let mut out = 0;
while out < 10 {
out += 1;
}
return out;
}<|fim_prefix|>// repo: calewis/LearnRust path: /variables_chap3/src/main.rs
use rand::Rng;
fn main() {
// Mutability
let mut x = 5;
println!("x is: {}", x);
x = 6;
println!("x... | code_fim | hard | {
"lang": "rust",
"repo": "calewis/LearnRust",
"path": "/variables_chap3/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: calewis/LearnRust path: /variables_chap3/src/main.rs
use rand::Rng;
fn main() {
// Mutability
let mut x = 5;
println!("x is: {}", x);
x = 6;
println!("x is: {}", x);
// Shadowing
let y = 5;
let y = y + 1;
let y = y * 2;
println!("The value of y is: {}",... | code_fim | medium | {
"lang": "rust",
"repo": "calewis/LearnRust",
"path": "/variables_chap3/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>e]
pub fn operand1(&self) -> OPERAND1R {
let bits = {
const MASK: u8 = 255;
const OFFSET: u8 = 16;
((self.bits >> OFFSET) & MASK as u32) as u8
};
OPERAND1R { bits }
}
#[doc = "Bits 24:25 - NUM_PADS1"]
#[inline]
pub fn num_pads... | code_fim | hard | {
"lang": "rust",
"repo": "ferrous-systems/imxrt1052",
"path": "/src/flexspi/lut/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ferrous-systems/imxrt1052 path: /src/flexspi/lut/mod.rs
#[doc = r" Value read from the register"]
pub struct R {
bits: u32,
}
#[doc = r" Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::LUT {
#[doc = r" Modifies the contents of the register"]
#[inline]
... | code_fim | hard | {
"lang": "rust",
"repo": "ferrous-systems/imxrt1052",
"path": "/src/flexspi/lut/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chee-chyuan/trin path: /src/main.rs
use std::env;
use std::sync::Arc;
use discv5::TalkRequest;
use log::{debug, info};
use tokio::sync::mpsc;
use tokio::sync::RwLock;
use trin_core::jsonrpc::handlers::{
HistoryNetworkEndpoint, JsonRpcHandler, PortalEndpoint, StateNetworkEndpoint,
};
use tr... | code_fim | hard | {
"lang": "rust",
"repo": "chee-chyuan/trin",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> tokio::spawn(state_events.process_requests());
}
None => panic!("State network selected, but state event handler not initialized!"),
}
// hacky test: make sure we establish a session with the boot node
p2p.ping_bootno... | code_fim | hard | {
"lang": "rust",
"repo": "chee-chyuan/trin",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if trin_config
.networks
.iter()
.any(|val| val == HISTORY_NETWORK)
{
let history_network_discovery = Arc::clone(&discovery);
let history_portalnet_config = portalnet_config.clone();
let history_overlay_db = Arc::clone(&db);
// Spawn History... | code_fim | hard | {
"lang": "rust",
"repo": "chee-chyuan/trin",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>RIDL!{#[uuid(0x28ecf94e, 0x3510, 0x3a3e, 0x8b, 0xd1, 0xf8, 0x66, 0xf4, 0x5f, 0x3b, 0x06)]
interface _KeyContainerPermissionAccessEntryCollection(_KeyContainerPermissionAccessEntryCollectionVtbl): IDispatch(IDispatchVtbl)
{}} //ICollection
RIDL!{#[uuid(0x293187ea, 0x5f88, 0x316f, 0x86, 0xa5, 0x53, 0x3b,... | code_fim | hard | {
"lang": "rust",
"repo": "ZerothLaw/mscorlib-rs-sys",
"path": "/src/source/system/security/permissions/keycontainerpermission.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ZerothLaw/mscorlib-rs-sys path: /src/source/system/security/permissions/keycontainerpermission.rs
// keycontainerpermission.rs - MIT License
// MIT License
// Copyright (c) 2018 Tyler Laing (ZerothLaw)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of ... | code_fim | hard | {
"lang": "rust",
"repo": "ZerothLaw/mscorlib-rs-sys",
"path": "/src/source/system/security/permissions/keycontainerpermission.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug)]
struct BagContent {
pub quantity: u8,
pub bag_type: String,
}
impl BagContent {
pub fn from(input: &str) -> Option<BagContent> {
let mut chars = input.chars();
let quantity: u8 = match chars.next() {
None => return None,
Some(c) => c.to... | code_fim | hard | {
"lang": "rust",
"repo": "Dyr-El/advent_of_code_2020",
"path": "/mantono-rust/src/days/day7.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Dyr-El/advent_of_code_2020 path: /mantono-rust/src/days/day7.rs
use std::{collections::HashMap, sync::Arc};
use regex::Regex;
/// Due to recent aviation regulations, many rules (your puzzle input) are being enforced about bags and their contents; bags must be color-coded and must contain speci... | code_fim | hard | {
"lang": "rust",
"repo": "Dyr-El/advent_of_code_2020",
"path": "/mantono-rust/src/days/day7.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl BagContent {
pub fn from(input: &str) -> Option<BagContent> {
let mut chars = input.chars();
let quantity: u8 = match chars.next() {
None => return None,
Some(c) => c.to_digit(10).unwrap() as u8,
};
let bag_type: String = chars.skip(1).colle... | code_fim | hard | {
"lang": "rust",
"repo": "Dyr-El/advent_of_code_2020",
"path": "/mantono-rust/src/days/day7.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Operation response type that associates a property bag with an underlying HTTP response.
/// This type represents the response in the Tower `Service` in middleware so that middleware
/// can share information with each other via the properties.
#[derive(Debug)]
pub struct Response {
/// The underl... | code_fim | hard | {
"lang": "rust",
"repo": "mnts26/aws-sdk-rust",
"path": "/sdk/smithy-http/src/operation.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Request {
/// Creates a new operation `Request` with the given `inner` HTTP request.
pub fn new(inner: http::Request<SdkBody>) -> Self {
Request {
inner,
properties: SharedPropertyBag::new(),
}
}
/// Creates a new operation `Request` from its p... | code_fim | hard | {
"lang": "rust",
"repo": "mnts26/aws-sdk-rust",
"path": "/sdk/smithy-http/src/operation.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mnts26/aws-sdk-rust path: /sdk/smithy-http/src/operation.rs
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
use crate::body::SdkBody;
use crate::property_bag::{PropertyBag, SharedPropertyBag};
use std::borrow::Cow;
use std::er... | code_fim | hard | {
"lang": "rust",
"repo": "mnts26/aws-sdk-rust",
"path": "/sdk/smithy-http/src/operation.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> unsafe {
assert_eq!(
CString::new("0.6.0").unwrap().as_c_str(),
CStr::from_ptr(libcypher_parser_version())
);
let stmt = "MATCH (n) RETURN n";
let result = cypher_uparse(
CString::new(stmt).unwrap().as_... | code_fim | hard | {
"lang": "rust",
"repo": "favilo/libcypher-parser-sys",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let type_string = CStr::from_ptr(cypher_astnode_typestr(tipe));
assert_eq!(CString::new("statement").unwrap().as_c_str(), type_string,);
cypher_parse_result_free(result);
}
}
}<|fim_prefix|>// repo: favilo/libcypher-parser-sys path: /src/lib.rs
#![allow(no... | code_fim | hard | {
"lang": "rust",
"repo": "favilo/libcypher-parser-sys",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: favilo/libcypher-parser-sys path: /src/lib.rs
#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
#[cfg(test)]
mod tests {
use super::*;
use std::{
ffi::{CStr, CString},
ptr::nul... | code_fim | hard | {
"lang": "rust",
"repo": "favilo/libcypher-parser-sys",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tikv/async-speed-limit path: /src/clock.rs
// Copyright 2019 TiKV Project Authors. Licensed under MIT or Apache-2.0.
//! Clocks
#[cfg(feature = "standard-clock")]
use futures_timer::Delay;
#[cfg(feature = "standard-clock")]
use std::time::Instant;
use std::{
convert::TryInto,
fmt::Debu... | code_fim | hard | {
"lang": "rust",
"repo": "tikv/async-speed-limit",
"path": "/src/clock.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl ManualClockContent {
fn now(&self) -> Nanoseconds {
Nanoseconds(self.now.load(Ordering::SeqCst))
}
fn set_time(&self, time: u64) {
let old_time = self.now.swap(time, Ordering::SeqCst);
assert!(old_time <= time, "cannot move the time backwards");
let waker... | code_fim | hard | {
"lang": "rust",
"repo": "tikv/async-speed-limit",
"path": "/src/clock.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T> MonteCarloModelClone for T
where
T: 'static + MonteCarloModel + Clone,
{
fn clone_box(&self) -> Box<dyn MonteCarloModel> {
Box::new(self.clone())
}
}
impl Clone for Box<dyn MonteCarloModel> {
fn clone(&self) -> Box<dyn MonteCarloModel> {
self.clone_box()
}
}
/... | code_fim | hard | {
"lang": "rust",
"repo": "avhz/QuantMath",
"path": "/src/models/mod.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.