text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: JustAPerson/denuos path: /src/kernel/vga.rs
// This file originated from Philipp Oppermann's Rust OS blog series.
// Copyright 2015 Philipp Oppermann. Please see the original license:
// https://github.com/phil-opp/blog_os/blob/master/LICENSE-MIT
// This file has been modified from its original ... | code_fim | hard | {
"lang": "rust",
"repo": "JustAPerson/denuos",
"path": "/src/kernel/vga.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_c_proc(assert: &mut Assertions) {
assert.rb_eq(lazy_eval("::Proc"), unsafe { rb_cProc });
}
#[test]
fn test_c_random(assert: &mut Assertions) {
assert.rb_eq(lazy_eval("::Random"), unsafe { rb_cRandom });
}
#[test]
fn test_c_range(assert: &m... | code_fim | hard | {
"lang": "rust",
"repo": "zvkemp/libcruby-sys",
"path": "/src/ruby.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_e_not_imp_error(assert: &mut Assertions) {
assert.rb_eq(lazy_eval("::NotImplementedError"), unsafe { rb_eNotImpError });
}
#[test]
fn test_e_no_mem_error(assert: &mut Assertions) {
assert.rb_eq(lazy_eval("::NoMemoryError"), unsafe { rb_eNoMemError });
... | code_fim | hard | {
"lang": "rust",
"repo": "zvkemp/libcruby-sys",
"path": "/src/ruby.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zvkemp/libcruby-sys path: /src/ruby.rs
doc.org/core-2.5.1/RuntimeError.html)
///
//+ c-class: error.c `VALUE rb_eRuntimeError`
pub static rb_eRuntimeError: VALUE;
/// The `SecurityError` exception class
///
/// # Ruby Documentation
///
/// * [2.5](https://ruby-do... | code_fim | hard | {
"lang": "rust",
"repo": "zvkemp/libcruby-sys",
"path": "/src/ruby.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fuzz_target!(|data: &[u8]| {
let mut median_tracker = StreamingMedian::new();
for value in data {
median_tracker.insert_and_calculate(*value as u32);
}
});<|fim_prefix|>// repo: insanitybit/sqs-service-helper path: /fuzz/fuzz_targets/fuzz_target_1.rs
#![no_main]
#[macro_use] extern c... | code_fim | easy | {
"lang": "rust",
"repo": "insanitybit/sqs-service-helper",
"path": "/fuzz/fuzz_targets/fuzz_target_1.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: insanitybit/sqs-service-helper path: /fuzz/fuzz_targets/fuzz_target_1.rs
#![no_main]
#[macro_use] extern crate libfuzzer_sys;
extern crate sqs_service_helper;
use sqs_service_helper::autoscaling::*;
<|fim_suffix|> for value in data {
median_tracker.insert_and_calculate(*value as u32... | code_fim | medium | {
"lang": "rust",
"repo": "insanitybit/sqs-service-helper",
"path": "/fuzz/fuzz_targets/fuzz_target_1.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tglanz/deep path: /core/src/graph/traversal/visitor.rs
use super::super::{
node::{Node},
edge::{Edge},
};
<|fim_suffix|> &mut self,
node: &'a Node,
input_edges: &[&'a Edge],
output_edges: &[&'a Edge]);
/// Invoked subsequent to all visitations. Gives ... | code_fim | medium | {
"lang": "rust",
"repo": "tglanz/deep",
"path": "/core/src/graph/traversal/visitor.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn visit_node(
&mut self,
node: &'a Node,
input_edges: &[&'a Edge],
output_edges: &[&'a Edge]);
/// Invoked subsequent to all visitations. Gives a chance for destruction
fn after_visitations(&mut self);
}<|fim_prefix|>// repo: tglanz/deep path: /core/src/graph... | code_fim | medium | {
"lang": "rust",
"repo": "tglanz/deep",
"path": "/core/src/graph/traversal/visitor.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: addaitech/yatta path: /yatta/src/window.rs
sWindowVisible,
RealGetWindowClassW,
SetCursorPos,
SetForegroundWindow,
SetWindowPos,
ShowWindow,
GWL_EXSTYLE,
GWL_STYLE,
HWND_BOTTOM,
SET_WINDOW... | code_fim | hard | {
"lang": "rust",
"repo": "addaitech/yatta",
"path": "/yatta/src/window.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if writ_chars == 0 {
return Err(std::io::Error::last_os_error().into());
}
Ok(String::from_utf16_lossy(&buff[0..writ_chars as usize]))
}
pub fn thread_process_id(&self) -> (u32, u32) {
let mut process_pid: u32 = 0;
let thread_pid = unsafe { Get... | code_fim | hard | {
"lang": "rust",
"repo": "addaitech/yatta",
"path": "/yatta/src/window.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn is_window(self) -> bool {
unsafe { IsWindow(self.hwnd).into() }
}
pub fn is_active(self) -> bool {
self.info().window_status == 1
}
pub fn get_style(&self) -> Result<GwlStyle> {
unsafe {
nullable_to_result(GetWindowLongW(self.hwnd, GWL_STYLE... | code_fim | hard | {
"lang": "rust",
"repo": "addaitech/yatta",
"path": "/yatta/src/window.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: oohugo/Exercicios path: /Project_Euler/rust/src/p23.rs
fn sum_divisors(max: u64) -> Vec<u64> {
let mut sum_div: Vec<u64> = Vec::new();
sum_div.resize_with((max + 1) as usize, Default::default);
for i in 1..max + 1 {
for j in ((i + i)..max).step_by(i as usize) {
su... | code_fim | medium | {
"lang": "rust",
"repo": "oohugo/Exercicios",
"path": "/Project_Euler/rust/src/p23.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn resolution() -> u64 {
const MAX: usize = 28123;
let abundant_numbers = get_abundant(MAX as u64);
let mut sum_abundant: Vec<bool> = Vec::new();
sum_abundant.resize_with(MAX + 1, Default::default);
let max_abun = abundant_numbers.len();
for i in 0..max_abun {
for j in ... | code_fim | hard | {
"lang": "rust",
"repo": "oohugo/Exercicios",
"path": "/Project_Euler/rust/src/p23.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dennisn00/geo_crash path: /src/main.rs
use ggez::{graphics, Context, ContextBuilder, GameResult};
use ggez::event::{self, EventHandler};
use crate::master::Master;
use ggez::graphics::DrawParam;
mod master;
mod player;
mod game_object;
fn main() {
// Make a Context.
let (mut ctx, mut e... | code_fim | medium | {
"lang": "rust",
"repo": "dennisn00/geo_crash",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl EventHandler for MyGame {
fn update(&mut self, _ctx: &mut Context) -> GameResult<()> {
// Update code here...
Ok(())
}
fn draw(&mut self, ctx: &mut Context) -> GameResult<()> {
graphics::clear(ctx, graphics::WHITE);
let r1 = self.master.draw(ctx)?;
... | code_fim | hard | {
"lang": "rust",
"repo": "dennisn00/geo_crash",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: extrawurst/azure-sdk-for-rust path: /services/mgmt/resources/src/package_features_2015_12/operations.rs
#![doc = "generated by AutoRust 0.1.0"]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(unused_imports)]
use crate::models::*;
use reqwest::StatusCode;
use snafu::{ResultExt, Snafu}... | code_fim | hard | {
"lang": "rust",
"repo": "extrawurst/azure-sdk-for-rust",
"path": "/services/mgmt/resources/src/package_features_2015_12/operations.rs",
"mode": "psm",
"license": "LicenseRef-scancode-generic-cla",
"source": "the-stack-v2"
} |
<|fim_suffix|>tion_id: &str,
) -> std::result::Result<FeatureResult, get::Error> {
let client = &operation_config.client;
let uri_str = &format!(
"{}/subscriptions/{}/providers/Microsoft.Features/providers/{}/features/{}",
&operation_config.base_path, subscription_id, resourc... | code_fim | hard | {
"lang": "rust",
"repo": "extrawurst/azure-sdk-for-rust",
"path": "/services/mgmt/resources/src/package_features_2015_12/operations.rs",
"mode": "spm",
"license": "LicenseRef-scancode-generic-cla",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DyrellC/bee-p path: /bee-protocol/src/worker/milestone_validator.rs
// Copyright 2020 IOTA Stiftung
//
// 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://w... | code_fim | hard | {
"lang": "rust",
"repo": "DyrellC/bee-p",
"path": "/bee-protocol/src/worker/milestone_validator.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // TODO only trigger if index == last solid index ?
// TODO trigger only if requester is empty ? And unsynced ?
// Protocol::trigger_transaction_solidification(milestone.hash).await;
}
Err(e) => match e {
MilestoneVali... | code_fim | hard | {
"lang": "rust",
"repo": "DyrellC/bee-p",
"path": "/bee-protocol/src/worker/milestone_validator.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> async fn validate_milestone(&self, tail_hash: Hash) -> Result<Milestone, MilestoneValidatorWorkerError> {
// TODO also do an IncomingBundleBuilder check ?
let mut builder = MilestoneBuilder::<Kerl, M, P>::new(tail_hash);
let mut transaction = tangle()
.get(&tail_has... | code_fim | hard | {
"lang": "rust",
"repo": "DyrellC/bee-p",
"path": "/bee-protocol/src/worker/milestone_validator.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("Before parsing...");
println!("{:?}", parser::top_level("."));
println!("After parsing!");
}<|fim_prefix|>// repo: hcpl/jq-tools path: /src/main.rs
#[macro_use]
extern crate nom;
extern crate semver;
mod ast;
#[macro_use] mod nom_helpers;
#[macro_use] mod lexer;
mod parser;
<|fim_... | code_fim | easy | {
"lang": "rust",
"repo": "hcpl/jq-tools",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hcpl/jq-tools path: /src/main.rs
#[macro_use]
extern crate nom;
extern crate semver;
<|fim_suffix|> println!("Before parsing...");
println!("{:?}", parser::top_level("."));
println!("After parsing!");
}<|fim_middle|>mod ast;
#[macro_use] mod nom_helpers;
#[macro_use] mod lexer;
mod p... | code_fim | medium | {
"lang": "rust",
"repo": "hcpl/jq-tools",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: putterson/zoo_spree path: /dependencies/gfx/src/backend/dx11/src/lib.rs
// Copyright 2016 The Gfx-rs Developers.
//
// 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
//... | code_fim | hard | {
"lang": "rust",
"repo": "putterson/zoo_spree",
"path": "/dependencies/gfx/src/backend/dx11/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> use core::handle::Producer;
self.frame_handles.clear();
self.share.handles.borrow_mut().clean_with(&mut self.context,
|ctx, buffer| {
buffer.mapping().map(|raw| {
// we have exclusive access because it's the last reference
... | code_fim | hard | {
"lang": "rust",
"repo": "putterson/zoo_spree",
"path": "/dependencies/gfx/src/backend/dx11/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mhbielecki/adventofcode path: /2019/intcodecomputer/src/lib.rs
use std::io;
const ADD: i32 = 1;
const MUL: i32 = 2;
const INPUT: i32 = 3;
const OUTPUT: i32 = 4;
const JT: i32 = 5;
const JF: i32 = 6;
const LT: i32 = 7;
const EQ: i32 = 8;
const ADJUST_REL_BASE: i32 = 9;
const HALT: i32 = 99;
pub... | code_fim | hard | {
"lang": "rust",
"repo": "mhbielecki/adventofcode",
"path": "/2019/intcodecomputer/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let first_param = self.get_operand(1);
self.relative_base = (self.relative_base as i64 + first_param) as usize;
self.step(2);
}
pub fn add_custom_input(&mut self, input: i64) {
self.custom_input.push(input);
}
pub fn get_last_output(&mut self) -> i64 {
... | code_fim | hard | {
"lang": "rust",
"repo": "mhbielecki/adventofcode",
"path": "/2019/intcodecomputer/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sagebind/isahc path: /src/util/task.rs
//! Helpers for working with tasks.
use std::task::Waker;
use waker_fn::waker_fn;
<|fim_suffix|>impl WakerExt for Waker {
fn chain(&self, f: impl Fn(&Waker) + Send + Sync + 'static) -> Waker {
let inner = self.clone();
waker_fn(move ||... | code_fim | hard | {
"lang": "rust",
"repo": "sagebind/isahc",
"path": "/src/util/task.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let inner = self.clone();
waker_fn(move || (f)(&inner))
}
}<|fim_prefix|>// repo: sagebind/isahc path: /src/util/task.rs
//! Helpers for working with tasks.
use std::task::Waker;
use waker_fn::waker_fn;
/// Helper methods for working with wakers.
pub(crate) trait WakerExt {
/// ... | code_fim | medium | {
"lang": "rust",
"repo": "sagebind/isahc",
"path": "/src/util/task.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: oharlem/exercism-rust path: /run-length-encoding/src/lib.rs
pub fn encode(source: &str) -> String {
// Example: "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB" -> "12WB12W3B24WB"
// Algorithm:
// - compare symbols with a previous one
// - keep a counter of repetitions
... | code_fim | medium | {
"lang": "rust",
"repo": "oharlem/exercism-rust",
"path": "/run-length-encoding/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> out
}
pub fn decode(source: &str) -> String {
unimplemented!("Return the run-length decoding of {}.", source);
}<|fim_prefix|>// repo: oharlem/exercism-rust path: /run-length-encoding/src/lib.rs
pub fn encode(source: &str) -> String {
// Example: "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWW... | code_fim | medium | {
"lang": "rust",
"repo": "oharlem/exercism-rust",
"path": "/run-length-encoding/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Vidhuran/mentat path: /query-parser/src/error.rs
// Copyright 2016 Mozilla
//
// 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.apache.org/licenses/LICENSE-2... | code_fim | hard | {
"lang": "rust",
"repo": "Vidhuran/mentat",
"path": "/query-parser/src/error.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Clone,Debug,Eq,PartialEq)]
pub enum QueryParseError {
InvalidInput(edn::Value),
EdnParseError(edn::parse::ParseError),
MissingField(edn::Keyword),
FindParseError(FindParseError),
}
pub type FindParseResult = Result<FindSpec, FindParseError>;
pub type QueryParseResult = Result<Fin... | code_fim | medium | {
"lang": "rust",
"repo": "Vidhuran/mentat",
"path": "/query-parser/src/error.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Clone,Debug,Eq,PartialEq)]
pub struct NotAVariableError(pub edn::Value);
#[derive(Clone,Debug,Eq,PartialEq)]
pub enum FindParseError {
Err,
}
#[derive(Clone,Debug,Eq,PartialEq)]
pub enum QueryParseError {
InvalidInput(edn::Value),
EdnParseError(edn::parse::ParseError),
MissingFiel... | code_fim | medium | {
"lang": "rust",
"repo": "Vidhuran/mentat",
"path": "/query-parser/src/error.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut sdram = Sdram{
sdramc,
start_address : 0x7000_0000 as *const u32, //start address defined by the hardware
size : 1 << addressing_bits,
mode : SdramMode::NORMAL
};
let mem_addr = sdram.start_address a... | code_fim | hard | {
"lang": "rust",
"repo": "ju6ge/atsamx7x-hal",
"path": "/src/sdram.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> sdram.set_mode(SdramMode::NORMAL);
let _ = sdram.sdramc.sdramc_mr.read().mode().bits();
asm::dmb();
unsafe { core::ptr::write_volatile(mem_addr, 3); }
//enabele refresh
sdram.sdramc.sdramc_tr.write(|w| unsafe{ w.count().bits(cycle_duration.cycles(config.timing.refresh) as u16 ) });
//retur... | code_fim | hard | {
"lang": "rust",
"repo": "ju6ge/atsamx7x-hal",
"path": "/src/sdram.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ju6ge/atsamx7x-hal path: /src/sdram.rs
//! SDRAM controller setup
// To see an example of how to use this abstraction take a look at:
//
// https://github.com/ju6ge/hd_embedded_rust
use crate::time::{PicoSeconds};
use crate::clock_gen::Clocks;
use crate::delay::Delay;
use crate::ebi::{External... | code_fim | hard | {
"lang": "rust",
"repo": "ju6ge/atsamx7x-hal",
"path": "/src/sdram.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mesalock-linux/crates-sgx path: /vendor/rand/examples/monte-carlo.rs
// Copyright 2018 Developers of the Rand project.
// Copyright 2013-2018 The Rust Project Developers.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// https://www.apache.org/licenses/LICENSE-2.0> or th... | code_fim | hard | {
"lang": "rust",
"repo": "mesalock-linux/crates-sgx",
"path": "/vendor/rand/examples/monte-carlo.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let range = Uniform::new(-1.0f64, 1.0);
let mut rng = rand::thread_rng();
let total = 1_000_000;
let mut in_circle = 0;
for _ in 0..total {
let a = range.sample(&mut rng);
let b = range.sample(&mut rng);
if a * a + b * b <= 1.0 {
in_circle += 1;
... | code_fim | medium | {
"lang": "rust",
"repo": "mesalock-linux/crates-sgx",
"path": "/vendor/rand/examples/monte-carlo.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let t = one_of("+-")(input);
match t {
Ok(a) => {
let (next_input, res) = a;
Ok((
next_input,
match res {
'+' => ast::Opcode::Add,
'-' => ast::Opcode::Sub,
_ => unimplemented... | code_fim | hard | {
"lang": "rust",
"repo": "dezeroku/rustp",
"path": "/src/parser/math.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn expr_number(input: &str) -> IResult<&str, Box<ast::Expr>> {
alt((_expr_number_negative, _expr_number_positive))(input)
}
fn _expr_number_positive(input: &str) -> IResult<&str, Box<ast::Expr>> {
match number(input) {
Ok(a) => {
let (next_input, val) = a;
Ok((next... | code_fim | hard | {
"lang": "rust",
"repo": "dezeroku/rustp",
"path": "/src/parser/math.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dezeroku/rustp path: /src/parser/math.rs
use crate::ast;
use crate::parser::astp;
use nom::{
branch::alt, bytes::complete::tag, bytes::complete::take_while1, character::complete::char,
character::complete::one_of, character::complete::space0, multi::many0, sequence::tuple,
IResult,... | code_fim | hard | {
"lang": "rust",
"repo": "dezeroku/rustp",
"path": "/src/parser/math.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sindrehan/mkl82z7-pac path: /src/smc.rs
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - Power Mode Protection register"]
pub pmprot: crate::Reg<pmprot::PMPROT_SPEC>,
#[doc = "0x01 - Power Mode Control register"]
pub pmctrl: crate::Reg<pmctrl::PMCT... | code_fim | hard | {
"lang": "rust",
"repo": "sindrehan/mkl82z7-pac",
"path": "/src/smc.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>[doc = "Power Mode Protection register"]
pub mod pmprot;
#[doc = "PMCTRL register accessor: an alias for `Reg<PMCTRL_SPEC>`"]
pub type PMCTRL = crate::Reg<pmctrl::PMCTRL_SPEC>;
#[doc = "Power Mode Control register"]
pub mod pmctrl;
#[doc = "STOPCTRL register accessor: an alias for `Reg<STOPCTRL_SPEC>`"]
p... | code_fim | hard | {
"lang": "rust",
"repo": "sindrehan/mkl82z7-pac",
"path": "/src/smc.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JosePedroDias/rust_experiments path: /bevy/src/components.rs
use bevy::prelude::*;
#[derive(Clone, Copy, Debug)]
pub struct TileData {
pub index: usize,
pub original_index: usize,
pub center: Vec3,
pub dims: Vec2,
pub uvs: (f32, f32, f32, f32),
}
<|fim_suffix|>#[derive(Debu... | code_fim | medium | {
"lang": "rust",
"repo": "JosePedroDias/rust_experiments",
"path": "/bevy/src/components.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub struct Credits;
pub struct MainCamera;
pub struct StrokedTile;<|fim_prefix|>// repo: JosePedroDias/rust_experiments path: /bevy/src/components.rs
use bevy::prelude::*;
#[derive(Clone, Copy, Debug)]
pub struct TileData {
pub index: usize,
pub original_index: usize,
pub center: Vec3,
... | code_fim | medium | {
"lang": "rust",
"repo": "JosePedroDias/rust_experiments",
"path": "/bevy/src/components.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 00mjk/stylist-rs path: /packages/stylist-core/src/ast/mod.rs
// this module is documented at stylist::ast
mod block;
mod context;
mod rule;
mod rule_block_content;
mod scope_content;
mod selector;
mod sheet;
mod str_frag;
mod style_attr;
mod to_style_str;
pub use context::StyleContext;
pub us... | code_fim | hard | {
"lang": "rust",
"repo": "00mjk/stylist-rs",
"path": "/packages/stylist-core/src/ast/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_scope_building_with_condition() -> Result<()> {
let test_block = Sheet::from(vec![ScopeContent::Rule(Rule {
condition: vec!["@media only screen and (min-width: 1000px)".into()].into(),
content: vec![
RuleBlockContent::Block(
... | code_fim | hard | {
"lang": "rust",
"repo": "00mjk/stylist-rs",
"path": "/packages/stylist-core/src/ast/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: YutaGoto/daily_atcoder path: /2021-04/abc105_b.rs
use whiteread::parse_line;
use std::process;
fn main() {
<|fim_suffix|> for c in 0..27 {
for d in 0..16 {
let cost: usize = 4*c + 7*d;
if n == cost {
println!("Yes");
process::ex... | code_fim | medium | {
"lang": "rust",
"repo": "YutaGoto/daily_atcoder",
"path": "/2021-04/abc105_b.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for c in 0..27 {
for d in 0..16 {
let cost: usize = 4*c + 7*d;
if n == cost {
println!("Yes");
process::exit(0x0100);
} else if n < cost {
break;
}
}
}
println!("No");
}<|fim_prefix|... | code_fim | medium | {
"lang": "rust",
"repo": "YutaGoto/daily_atcoder",
"path": "/2021-04/abc105_b.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: abh1nav/docker-rust path: /src/methods/image.rs
use serialize::{json, Decodable};
use serialize::json::DecoderError;
use super::super::common::images::Images as Images;
use super::super::http as http;
///
/// GET /images/json
///
<|fim_suffix|>pub fn get_images(socket_path: &str) -> Images {
... | code_fim | hard | {
"lang": "rust",
"repo": "abh1nav/docker-rust",
"path": "/src/methods/image.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let json_object = json::from_str(json_string);
let mut decoder = json::Decoder::new(json_object.unwrap());
Decodable::decode(&mut decoder)
}
pub fn get_images(socket_path: &str) -> Images {
let method = http::GET;
let path = "/images/json?all=0";
let response = http::make_request(socket_path... | code_fim | medium | {
"lang": "rust",
"repo": "abh1nav/docker-rust",
"path": "/src/methods/image.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> &mut self,
partition: String,
start_ts: u64,
end_ts: u64,
) -> Result<(), failure::Error> {
if let Some(writer) = self.segment_writers.get_mut(&partition) {
let (segment_start_ts, segment_end_ts) = writer.segment_ts();
if (segment_start_t... | code_fim | hard | {
"lang": "rust",
"repo": "manigandand/pathivu",
"path": "/src/ingester/ingester.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn flush_if_necessary(
&mut self,
partition: String,
start_ts: u64,
end_ts: u64,
) -> Result<(), failure::Error> {
if let Some(writer) = self.segment_writers.get_mut(&partition) {
let (segment_start_ts, segment_end_ts) = writer.segment_ts();
... | code_fim | hard | {
"lang": "rust",
"repo": "manigandand/pathivu",
"path": "/src/ingester/ingester.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: manigandand/pathivu path: /src/ingester/ingester.rs
/*
* Copyright 2019 Balaji Jinnah and Contributors
*
* 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
*
* h... | code_fim | hard | {
"lang": "rust",
"repo": "manigandand/pathivu",
"path": "/src/ingester/ingester.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn u32_ip4_to_str(d: u32) -> String {
format!(
"{}.{}.{}.{}",
(d & 0xff00_0000) >> 24,
(d & 0x00ff_0000) >> 16,
(d & 0x0000_ff00) >> 8,
d & 0x0000_00ff
)
}
pub fn ipv6_to_str(b: &[u8]) -> String {
format!(
"{:x}{:x}:{:x}{:x}:{:x}{:x}:{:x}{:x... | code_fim | hard | {
"lang": "rust",
"repo": "dumpmemory/netloom_rs",
"path": "/src/util.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dumpmemory/netloom_rs path: /src/util.rs
use chrono;
use log;
pub fn setup_logger() -> Result<(), fern::InitError> {
fern::Dispatch::new()
.format(|out, message, record| {
out.finish(format_args!(
"{}[{}][{}] {}",
chrono::Local::now().form... | code_fim | hard | {
"lang": "rust",
"repo": "dumpmemory/netloom_rs",
"path": "/src/util.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn mac_to_str(addr: &[u8; 6]) -> String {
format!(
"{:02X}:{:02X}:{:02X}:{:02X}:{:02X}:{:02X}",
addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]
)
}
pub fn ipv4_to_str(addr: &[u8; 4]) -> String {
format!("{}.{}.{}.{}", addr[0], addr[1], addr[2], addr[3])
}<|fim_prefix|... | code_fim | hard | {
"lang": "rust",
"repo": "dumpmemory/netloom_rs",
"path": "/src/util.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/developer/ffx/plugins/repository/server/start/src/lib.rs
// Copyright 2022 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use {
anyhow::{Context as _, Result},
... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/developer/ffx/plugins/repository/server/start/src/lib.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[serial_test::serial]
#[test]
fn test_start_failed() {
run_async_test(async {
let mut writer = Writer::new_test(None);
let (sender, receiver) = channel();
let mut sender = Some(sender);
let repos = setup_fake_repos(move |req| match req ... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/developer/ffx/plugins/repository/server/start/src/lib.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: YusukeHosonuma/workspace path: /Rust/tutorial/tutorial_4_11/src/main.rs
// 4.11. 構造体
// 慣習的にアッパーキャメルケースで記述(e.g. PointInSpace)
struct Point {
x: i32,
y: i32,
}
fn main() {
// 構造体
{
let origin = Point { x: 0, y: 0 }; // 順番は元の定義順で無くても良い
println!("The origin is at ... | code_fim | hard | {
"lang": "rust",
"repo": "YusukeHosonuma/workspace",
"path": "/Rust/tutorial/tutorial_4_11/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Unit-like 構造体
//
// 全くメンバを持たない struct を定義できる。
// 空のタプルである () が unit と呼ばれることから、Unit-like と呼ばれる。
{
struct Electron;
let x = Electron;
}
}<|fim_prefix|>// repo: YusukeHosonuma/workspace path: /Rust/tutorial/tutorial_4_11/src/main.rs
// 4.11. 構造体
// 慣習的にアッパーキャメルケース... | code_fim | hard | {
"lang": "rust",
"repo": "YusukeHosonuma/workspace",
"path": "/Rust/tutorial/tutorial_4_11/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let length = Inches(10);
let Inches(integer_length) = length; // パターンマッチで取り出し
println!("length is {} inches", integer_length);
}
// Unit-like 構造体
//
// 全くメンバを持たない struct を定義できる。
// 空のタプルである () が unit と呼ばれることから、Unit-like と呼ばれる。
{
struct Electron;
... | code_fim | medium | {
"lang": "rust",
"repo": "YusukeHosonuma/workspace",
"path": "/Rust/tutorial/tutorial_4_11/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>let mut v = vec![0u32, 1];
for i in 2..(term+1) {
let sum = v[i-1] + v[i-2];
v.push(sum);
}
return v[term];
}<|fim_prefix|>// repo: HappDen/HW3 path: /kek666.rs
use std::io;
fn main() {
loop {
println!("Enter the term that you want to generate!");
let mut term = String::new();
io::stdin().read_line(&mut ... | code_fim | medium | {
"lang": "rust",
"repo": "HappDen/HW3",
"path": "/kek666.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: HappDen/HW3 path: /kek666.rs
use std::io;
fn main() {
loop {
println!("Enter the term that you want to generate!");
let mut term = String::new();
io::stdin().read_line(&mut term)
.ok()
.expect("Failed to read line!");
// convert string to int
let term: usize = match term.trim().parse() {
Ok(num)... | code_fim | medium | {
"lang": "rust",
"repo": "HappDen/HW3",
"path": "/kek666.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jdroenner/rust-gdal path: /src/vector/geometry.rs
use std::ptr::null;
use libc::{c_char, c_int, c_double, c_void};
use std::ffi::CString;
use std::cell::RefCell;
use utils::_string;
use vector::ogr;
/// OGR Geometry
pub struct Geometry {
c_geometry_ref: RefCell<Option<*const c_void>>,
o... | code_fim | hard | {
"lang": "rust",
"repo": "jdroenner/rust-gdal",
"path": "/src/vector/geometry.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub unsafe fn into_c_geometry(mut self) -> *const c_void {
assert!(self.owned);
self.owned = false;
return self.c_geometry();
}
pub fn set_point_2d(&mut self, i: usize, p: (f64, f64)) {
let (x, y) = p;
unsafe { ogr::OGR_G_SetPoint_2D(
self.c... | code_fim | hard | {
"lang": "rust",
"repo": "jdroenner/rust-gdal",
"path": "/src/vector/geometry.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub unsafe fn _get_geometry(&self, n: usize) -> Geometry {
// get the n-th sub-geometry as a non-owned Geometry; don't keep this
// object for long.
let c_geom = ogr::OGR_G_GetGeometryRef(self.c_geometry(), n as c_int);
return Geometry::with_c_geometry(c_geom, false);
... | code_fim | hard | {
"lang": "rust",
"repo": "jdroenner/rust-gdal",
"path": "/src/vector/geometry.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn with_blocking(&mut self, blocking: bool) -> &mut Self {
self.blocking = blocking;
self
}
pub fn new(
max_packets_read: usize,
snaplen: u32,
buffer_size: u32,
bpf: Option<String>,
buffer_for: std::time::Duration,
blocking: ... | code_fim | hard | {
"lang": "rust",
"repo": "protectwise/pcap-async",
"path": "/src/config.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: protectwise/pcap-async path: /src/config.rs
use std;
#[derive(Clone, Debug)]
pub struct Config {
max_packets_read: usize,
snaplen: u32,
buffer_size: u32,
bpf: Option<String>,
buffer_for: std::time::Duration,
blocking: bool,
}
impl Config {
pub fn max_packets_read(&s... | code_fim | hard | {
"lang": "rust",
"repo": "protectwise/pcap-async",
"path": "/src/config.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn buffer_for(&self) -> &std::time::Duration {
&self.buffer_for
}
pub fn with_buffer_for(&mut self, amt: std::time::Duration) -> &mut Self {
self.buffer_for = amt;
self
}
pub fn blocking(&self) -> bool {
self.blocking
}
pub fn with_blockin... | code_fim | hard | {
"lang": "rust",
"repo": "protectwise/pcap-async",
"path": "/src/config.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: eyedeekay/oxy path: /src/reexec.rs
use crate::core::Oxy;
use lazy_static::{__lazy_static_create, __lazy_static_internal, lazy_static};
#[allow(unused_imports)]
use log::{debug, error, info, log, trace, warn};
use transportation::BufferedTransport;
lazy_static! {
static ref CURRENT_EXE: ::s... | code_fim | hard | {
"lang": "rust",
"repo": "eyedeekay/oxy",
"path": "/src/reexec.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>crate fn reexec(args: &[&str]) {
// SECURITYWATCH: We shouldn't reexec if another non-root user has write
// permission on our binary or any parent folder. This is an out-and-out vuln
// if somebody puts oxy in /tmp or something. It should be fine as long as
// we're in /home/user/.cargo/b... | code_fim | hard | {
"lang": "rust",
"repo": "eyedeekay/oxy",
"path": "/src/reexec.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn schedule_ind(act: &Vec<Activity>, id: &String, lat: f64, lon: f64) -> (Allocation, usize) {
let mut lowest: f64 = f64::INFINITY;
let mut lowest_id = &String::new();
let mut i = 0;
let mut j = 0;
for act in act.iter() {
let dist = distance_between_points(lat, lon, act.lat, ac... | code_fim | hard | {
"lang": "rust",
"repo": "zolbatar/functional-comparison",
"path": "/Rust/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut lowest: f64 = f64::INFINITY;
let mut lowest_id = &String::new();
let mut i = 0;
let mut j = 0;
for act in act.iter() {
let dist = distance_between_points(lat, lon, act.lat, act.lon);
if dist < lowest {
lowest = dist;
lowest_id = &act.id;... | code_fim | hard | {
"lang": "rust",
"repo": "zolbatar/functional-comparison",
"path": "/Rust/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zolbatar/functional-comparison path: /Rust/src/main.rs
// rustc -C opt-level=3 -C target-cpu=native greedy.rs
use std::io::prelude::*;
use std::fs::File;
use std::f64;
use std::f64::consts::PI;
use std::path::Path;
static EARTH_RADIUS_M:f64 = 6367450.0;
static CONVERT_RAD:f64 = PI / 180.0;
#[... | code_fim | hard | {
"lang": "rust",
"repo": "zolbatar/functional-comparison",
"path": "/Rust/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Eduardo-Anosa-Evardonie-jr/wallet.rs path: /bindings/node/native/src/classes/account/sync.rs
use std::sync::{Arc, RwLock};
use iota_wallet::{
account::{Account, SyncedAccount},
WalletError,
};
use neon::prelude::*;
use serde::Deserialize;
#[derive(Deserialize, Default)]
pub struct SyncOpti... | code_fim | hard | {
"lang": "rust",
"repo": "Eduardo-Anosa-Evardonie-jr/wallet.rs",
"path": "/bindings/node/native/src/classes/account/sync.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn perform(&self) -> Result<Self::Output, Self::Error> {
let mut acc = self.account.write().unwrap();
let mut synchronizer = acc.sync();
if let Some(address_index) = self.options.address_index {
synchronizer = synchronizer.address_index(address_index);
}
if let Some(gap_limit) ... | code_fim | medium | {
"lang": "rust",
"repo": "Eduardo-Anosa-Evardonie-jr/wallet.rs",
"path": "/bindings/node/native/src/classes/account/sync.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dennisss/dacha path: /pkg/image/src/canny.rs
// Also need to be able to select fixed value for any dimension and take all
// indices matching that
// - Basically generalize selecting a channel
// Support taking absolute value of an entire Array
use core::f32::consts::PI;
enum Direction {
... | code_fim | hard | {
"lang": "rust",
"repo": "dennisss/dacha",
"path": "/pkg/image/src/canny.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for off in negative_offsets.iter() {
if i >= *off && g_mag_suppresed[i - off] > threshold_low {
sets.union_sets(i, i - off);
}
}
}
// Find ids of all sets containing a strong pixel.
// The value in the has... | code_fim | hard | {
"lang": "rust",
"repo": "dennisss/dacha",
"path": "/pkg/image/src/canny.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut v = g_mag[&pos.data[..]];
if v < max {
v = 0;
}
data.push(v)
}
g_mag_iter.step();
}
Array::from(data).reshape(&g_mag.shape)
};
... | code_fim | hard | {
"lang": "rust",
"repo": "dennisss/dacha",
"path": "/pkg/image/src/canny.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>epr(transparent)]
pub struct Layer(pub u64);
impl Default for Layer {
fn default() -> Self {
Self(0)
}
}<|fim_prefix|>// repo: sudachen/svm path: /crates/types/src/transaction/layer.rs
/// Represent a `Layer` of the Spacemesh Protocol
#[derive(D<|fim_middle|>ebug, Clone, Copy, PartialEq,... | code_fim | medium | {
"lang": "rust",
"repo": "sudachen/svm",
"path": "/crates/types/src/transaction/layer.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sudachen/svm path: /crates/types/src/transaction/layer.rs
/// Represent a `Layer` of the Spacemesh Protocol
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[r<|fim_suffix|>or Layer {
fn default() -> Self {
Self(0)
}
}<|fim_middle|>epr(transparent)]
pub struct... | code_fim | medium | {
"lang": "rust",
"repo": "sudachen/svm",
"path": "/crates/types/src/transaction/layer.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(Vec::from("123"), rmc_vec![b'1', b'2', b'3']);
}
from_str_test()
}<|fim_prefix|>// repo: iCodeIN/rmc path: /src/test/stub-tests/Vec/from_str.rs
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0 OR MIT
// rmc-flags: --u... | code_fim | easy | {
"lang": "rust",
"repo": "iCodeIN/rmc",
"path": "/src/test/stub-tests/Vec/from_str.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iCodeIN/rmc path: /src/test/stub-tests/Vec/from_str.rs
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0 OR MIT
// rmc-flags: --use-abs --abs-type rmc
include!{"../../rmc-prelude.rs"}
<|fim_suffix|> assert_eq!(Vec::from("123"), r... | code_fim | easy | {
"lang": "rust",
"repo": "iCodeIN/rmc",
"path": "/src/test/stub-tests/Vec/from_str.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Amanieu/parking_lot path: /core/src/thread_parker/generic.rs
// Copyright 2016 Amanieu d'Antras
//
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
// http://opensource.org/licenses/MIT>, at your o... | code_fim | hard | {
"lang": "rust",
"repo": "Amanieu/parking_lot",
"path": "/core/src/thread_parker/generic.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> ThreadParker {
parked: AtomicBool::new(false),
}
}
#[inline]
unsafe fn prepare_park(&self) {
self.parked.store(true, Ordering::Relaxed);
}
#[inline]
unsafe fn timed_out(&self) -> bool {
self.parked.load(Ordering::Relaxed) != false
}... | code_fim | medium | {
"lang": "rust",
"repo": "Amanieu/parking_lot",
"path": "/core/src/thread_parker/generic.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Add separator and menu
ui.separator();
if ui.button("☰").clicked() {
println!("Menu clicked!");
}
});
});
// Add central panel
egui::CentralPanel::default().show(ctx, |ui| {
ui.heading("Hello world!");
});
}... | code_fim | hard | {
"lang": "rust",
"repo": "buzzybrowser/buzzy",
"path": "/src/ui.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Add address bar
// FIXME: Holding down backspace doesn't work?
// TODO: Select all text when clicking if there is text
// TODO: Make address part of the tab instead of having a single one.
let separator_and_menu_button_width = 50.0;
... | code_fim | hard | {
"lang": "rust",
"repo": "buzzybrowser/buzzy",
"path": "/src/ui.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: buzzybrowser/buzzy path: /src/ui.rs
use bevy::prelude::*;
use bevy_egui::{egui, EguiContext, EguiPlugin};
use crate::address::{Address, AddressEntered};
pub struct SetupUIPlugin;
impl Plugin for SetupUIPlugin {
fn build(&self, app: &mut AppBuilder) {
app
// Set up UI da... | code_fim | hard | {
"lang": "rust",
"repo": "buzzybrowser/buzzy",
"path": "/src/ui.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kieraneglin/ticket-rs path: /src/models.rs
use super::schema::tickets;
use chrono::NaiveDateTime;
<|fim_suffix|>#[derive(Insertable)]
#[table_name = "tickets"]
pub struct NewTicket<'a> {
pub title: &'a str,
pub description: &'a str,
}<|fim_middle|>#[derive(Debug, Queryable, Identifiable... | code_fim | medium | {
"lang": "rust",
"repo": "kieraneglin/ticket-rs",
"path": "/src/models.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Insertable)]
#[table_name = "tickets"]
pub struct NewTicket<'a> {
pub title: &'a str,
pub description: &'a str,
}<|fim_prefix|>// repo: kieraneglin/ticket-rs path: /src/models.rs
use super::schema::tickets;
use chrono::NaiveDateTime;
<|fim_middle|>#[derive(Debug, Queryable, Identifiable... | code_fim | medium | {
"lang": "rust",
"repo": "kieraneglin/ticket-rs",
"path": "/src/models.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn run() {
let mut v: Data = (vec![], vec![]);
parse(&mut v);
let p = part(&mut v);
println!("PART 1: {}", p.0);
println!("PART 2: {}", p.1);
}
#[test]
fn test22() {
let mut v: Data = (vec![], vec![]);
parse(&mut v);
let p = part(&mut v);
assert_eq!(p.0, 32856);
... | code_fim | hard | {
"lang": "rust",
"repo": "fnuttplus/advent",
"path": "/2020/src/day22.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fnuttplus/advent path: /2020/src/day22.rs
use std::fs;
use std::collections::HashSet;
type Data = (Vec<usize>, Vec<usize>);
fn rec(v: &mut (Vec<usize>, Vec<usize>), it: bool) -> (bool, Vec<usize>) {
let mut s: HashSet<String> = HashSet::new();
loop {
let k:String = format!("{:... | code_fim | hard | {
"lang": "rust",
"repo": "fnuttplus/advent",
"path": "/2020/src/day22.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pantsbuild/pants path: /src/rust/engine/fs/brfs/src/syscall_tests.rs
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
// TODO: Write a bunch more syscall-y tests to test that each syscall for each file/directory ... | code_fim | medium | {
"lang": "rust",
"repo": "pantsbuild/pants",
"path": "/src/rust/engine/fs/brfs/src/syscall_tests.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn path_to_cstring(path: &Path) -> CString {
CString::new(path.to_string_lossy().as_bytes().to_owned()).unwrap()
}
fn make_buffer(size: usize) -> Vec<u8> {
let mut buf: Vec<u8> = Vec::new();
buf.resize(size, 0);
buf
}<|fim_prefix|>// repo: pantsbuild/pants path: /src/rust/engine/fs/brfs/src/sysc... | code_fim | hard | {
"lang": "rust",
"repo": "pantsbuild/pants",
"path": "/src/rust/engine/fs/brfs/src/syscall_tests.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/galangua path: /mods/galangua-common/src/framework/vkey.rs
#[derive(Clone, Copy, PartialEq)]
pub enum VKey {
Space,
Retur<|fim_suffix|>
Num0, Num1, Num2, Num3, Num4, Num5, Num6, Num7,
Num8, Num9,
}<|fim_middle|>n,
Escape,
Left,
Right,
Up,
Down,
A,... | code_fim | medium | {
"lang": "rust",
"repo": "isgasho/galangua",
"path": "/mods/galangua-common/src/framework/vkey.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
Num0, Num1, Num2, Num3, Num4, Num5, Num6, Num7,
Num8, Num9,
}<|fim_prefix|>// repo: isgasho/galangua path: /mods/galangua-common/src/framework/vkey.rs
#[derive(Clone, Copy, PartialEq)]
pub enum VKey {
Space,
Retur<|fim_middle|>n,
Escape,
Left,
Right,
Up,
Down,
A,... | code_fim | medium | {
"lang": "rust",
"repo": "isgasho/galangua",
"path": "/mods/galangua-common/src/framework/vkey.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'s> System<'s> for ColorPieceSystem {
type SystemData = (WriteStorage<'s, Piece>, WriteStorage<'s, Tint>);
fn run(&mut self, (mut pieces, mut tints): Self::SystemData) {
for (piece, tint) in (&mut pieces, &mut tints).join() {
match piece.status {
Status::N... | code_fim | medium | {
"lang": "rust",
"repo": "EmanuelBoehm/Rust",
"path": "/boardgame/src/color_piece.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn run(&mut self, (mut pieces, mut tints): Self::SystemData) {
for (piece, tint) in (&mut pieces, &mut tints).join() {
match piece.status {
Status::None => {}
Status::Selected => {
let mut tin = Tint(Srgba::new(0.5, 1., 1., 0.5));... | code_fim | medium | {
"lang": "rust",
"repo": "EmanuelBoehm/Rust",
"path": "/boardgame/src/color_piece.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: EmanuelBoehm/Rust path: /boardgame/src/color_piece.rs
use crate::piece;
use crate::piece::Piece;
use crate::piece::Status;
use amethyst::core::Transform;
use amethyst::ecs::{Join, Read, ReadExpect, System, WriteStorage};
use amethyst::input::{InputHandler, StringBindings};
use amethyst::renderer... | code_fim | medium | {
"lang": "rust",
"repo": "EmanuelBoehm/Rust",
"path": "/boardgame/src/color_piece.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.