text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: utilForever/BOJ path: /Rust/18237 - The Order of Matrix Multiplication 3.rs
use io::Write;
use std::{cmp::Ordering, collections::BinaryHeap, io, str};
pub struct UnsafeScanner<R> {
reader: R,
buf_str: Vec<u8>,
buf_iter: str::SplitAsciiWhitespace<'static>,
}
impl<R: io::BufRead> Uns... | code_fim | hard | {
"lang": "rust",
"repo": "utilForever/BOJ",
"path": "/Rust/18237 - The Order of Matrix Multiplication 3.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: proximax-storage/rust-xpx-chain-sdk path: /src/helpers/utils_hex.rs
/*
* Copyright 2018 ProximaX Limited. All rights reserved.
* Use of this source code is governed by the Apache 2.0
* license that can be found in the LICENSE file.
*/
<|fim_suffix|> re.is_match(input)
}
pub fn hex_decod... | code_fim | medium | {
"lang": "rust",
"repo": "proximax-storage/rust-xpx-chain-sdk",
"path": "/src/helpers/utils_hex.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let re = Regex::new(r"^[a-fA-F0-9]+$").unwrap();
re.is_match(input)
}
pub fn hex_decode(data: &str) -> Vec<u8> {
hex::decode(data)
.map_err(|err| panic!("Failed to decode hex data {} : {}", data, err))
.unwrap()
}
pub fn hex_encode(bytes: &[u8]) -> String {
hex::encode(b... | code_fim | medium | {
"lang": "rust",
"repo": "proximax-storage/rust-xpx-chain-sdk",
"path": "/src/helpers/utils_hex.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gltf-rs/gltf-viewer path: /src/render/node.rs
use std::rc::Rc;
use std::path::Path;
use gltf;
use collision::{Aabb, Union};
use controls::CameraParams;
use render::math::*;
use render::mesh::Mesh;
use render::Root;
use render::camera::Camera;
use importdata::ImportData;
pub struct Node {
... | code_fim | hard | {
"lang": "rust",
"repo": "gltf-rs/gltf-viewer",
"path": "/src/render/node.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> bounds: Aabb3::zero(),
}
}
pub fn update_transform(&mut self, root: &mut Root, parent_transform: &Matrix4) {
self.final_transform = *parent_transform;
if !self.matrix.is_identity() {
self.final_transform = self.final_transform * self.matrix;
... | code_fim | hard | {
"lang": "rust",
"repo": "gltf-rs/gltf-viewer",
"path": "/src/render/node.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn write_byte(&mut self, address: u16, value: u8){
if address == 0xFF02 && value == 0x81 {
print!("{}", self.read_byte(0xff01) as char);
}
match address {
0xff01 => self.sb = value,
0xff02 => self.sc = value,
n => unreachable!... | code_fim | hard | {
"lang": "rust",
"repo": "ElijahWoelbing/rust-dmg",
"path": "/src/serial.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ElijahWoelbing/rust-dmg path: /src/serial.rs
pub struct Serial {
sb: u8,
sc: u8,
}
impl Serial {
pub fn new() -> Self{
Self {
sb: 0,
sc: 0,
}
}
<|fim_suffix|> pub fn write_byte(&mut self, address: u16, value: u8){
if address ==... | code_fim | hard | {
"lang": "rust",
"repo": "ElijahWoelbing/rust-dmg",
"path": "/src/serial.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: i-dentify/echarge-vnext path: /rust/car/lib/src/persistence/read/mod.rs
use std::env;
use mongodb::Client;
use mongodb::options::ClientOptions;
<|fim_suffix|>pub async fn get_client() -> Client {
let connection_string = env::var("MONGODB_CONNECTION_STRING").expect("MONGODB_CONNECTION_STRIN... | code_fim | easy | {
"lang": "rust",
"repo": "i-dentify/echarge-vnext",
"path": "/rust/car/lib/src/persistence/read/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub async fn get_client() -> Client {
let connection_string = env::var("MONGODB_CONNECTION_STRING").expect("MONGODB_CONNECTION_STRING not set!");
let options = ClientOptions::parse(connection_string).await.expect("Unable to parse read connection string");
Client::with_options(options).unwrap()... | code_fim | easy | {
"lang": "rust",
"repo": "i-dentify/echarge-vnext",
"path": "/rust/car/lib/src/persistence/read/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: harpsword/tex-rs path: /src/tex_the_program/section_1043.rs
//! ` `
// @<Declare act...@>=
// procedure app_space; {handle spaces when |space_factor<>1000|}
/// handle spaces when `space_factor<>1000`
#[allow(unused_variables)]
pub(crate) fn app_space(globals: &mut TeXGlobals) -> TeXResult<()> {... | code_fim | hard | {
"lang": "rust",
"repo": "harpsword/tex-rs",
"path": "/src/tex_the_program/section_1043.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>e crate::section_0004::TeXGlobals;
use crate::section_0081::TeXResult;
use crate::section_0115::null;
use crate::section_0115::pointer;
use crate::section_0118::link;
use crate::section_0150::glue_ref_count;
use crate::section_0151::new_spec;
use crate::section_0152::new_param_glue;
use crate::section_015... | code_fim | hard | {
"lang": "rust",
"repo": "harpsword/tex-rs",
"path": "/src/tex_the_program/section_1043.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hummans/feeless path: /src/cli/address.rs
use crate::cli::StringOrStdin;
use clap::Clap;
#[derive(Clap)]
pub struct AddressOpts {
#[clap(subcommand)]
command: Command,
}
<|fim_suffix|>#[derive(Clap)]
pub enum Command {
ToPublic(Public),
}
#[derive(Clap)]
pub struct Public {
ad... | code_fim | hard | {
"lang": "rust",
"repo": "hummans/feeless",
"path": "/src/cli/address.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Clap)]
pub struct Public {
address: StringOrStdin<crate::Address>,
}<|fim_prefix|>// repo: hummans/feeless path: /src/cli/address.rs
use crate::cli::StringOrStdin;
use clap::Clap;
#[derive(Clap)]
pub struct AddressOpts {
#[clap(subcommand)]
command: Command,
}
impl AddressOpts {
... | code_fim | medium | {
"lang": "rust",
"repo": "hummans/feeless",
"path": "/src/cli/address.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jonasdresch/6502-rust-emulator path: /tests/branch_ops.rs
use emulator6502::*;
use rstest::*;
mod fixtures;
use fixtures::{mem_branch, Operation};
#[rstest]
// BCC
#[case::bcc_branch_forward_if_carry_is_clear(mem_branch(Cpu::BCC_RELATIVE, 0x8, true, false, RESET_EXEC_ADDRESS), 0)]
#[case::bcc_... | code_fim | hard | {
"lang": "rust",
"repo": "jonasdresch/6502-rust-emulator",
"path": "/tests/branch_ops.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>verflow_is_set(mem_branch(Cpu::BVS_RELATIVE, -0x7F, true, true, 0xFC7C), Cpu::FLAG_OVERFLOW)]
#[should_panic(expected = "Trying to branch beyond memory limits")]
#[case::bvs_dont_wrap_beyond_mem_limit(mem_branch(Cpu::BVS_RELATIVE, 0x7F, true, true, 0xFFE2), Cpu::FLAG_OVERFLOW)]
#[should_panic(expected = "... | code_fim | hard | {
"lang": "rust",
"repo": "jonasdresch/6502-rust-emulator",
"path": "/tests/branch_ops.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> use CacheDirective::*;
let h = |s: String| unsafe { HeaderValue::from_bytes_unchecked(s.into_bytes()) };
match directive {
Immutable => h("immutable".to_string()),
MaxAge(dur) => h(format!("max-age={}", dur.as_secs())),
MaxStale(dur) => match du... | code_fim | hard | {
"lang": "rust",
"repo": "mfelsche/http-types",
"path": "/src/cache/cache_control/cache_directive.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mfelsche/http-types path: /src/cache/cache_control/cache_directive.rs
use crate::headers::HeaderValue;
use crate::Status;
use std::time::Duration;
/// An HTTP `Cache-Control` directive.
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum CacheDirective {
/// The response body... | code_fim | hard | {
"lang": "rust",
"repo": "mfelsche/http-types",
"path": "/src/cache/cache_control/cache_directive.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl From<CacheDirective> for HeaderValue {
fn from(directive: CacheDirective) -> Self {
use CacheDirective::*;
let h = |s: String| unsafe { HeaderValue::from_bytes_unchecked(s.into_bytes()) };
match directive {
Immutable => h("immutable".to_string()),
... | code_fim | hard | {
"lang": "rust",
"repo": "mfelsche/http-types",
"path": "/src/cache/cache_control/cache_directive.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>criterion_group!(init_xorhift_plus_benches, bench_xorshift_plus_init_with_no_seed, bench_xorshift_plus_init_with_seed);
criterion_group!(generate_xorhift_plus_benches, bench_xorshift_plus_get_randoms);
criterion_main!(init_xorhift_plus_benches, generate_xorhift_plus_benches);<|fim_prefix|>// repo: markju... | code_fim | hard | {
"lang": "rust",
"repo": "markjunod/randomness",
"path": "/random_numbers/benches/xorshift_plus_benchmarks.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: markjunod/randomness path: /random_numbers/benches/xorshift_plus_benchmarks.rs
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use random_numbers::prelude::*;
fn bench_xorshift_plus_init_with_no_seed(c: &mut Criterion) {
c.bench_function("xorshift_plus_init_with_no_... | code_fim | hard | {
"lang": "rust",
"repo": "markjunod/randomness",
"path": "/random_numbers/benches/xorshift_plus_benchmarks.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> c.bench_function("xorshift_plus_get_random_bools", |b| b.iter(|| rnd.next_bool()));
c.bench_function("xorshift_plus_get_random_u8s", |b| b.iter(|| rnd.next_u8()));
c.bench_function("xorshift_plus_get_random_i8s", |b| b.iter(|| rnd.next_i8()));
c.bench_function("xorshift_plus_get_random_u16... | code_fim | hard | {
"lang": "rust",
"repo": "markjunod/randomness",
"path": "/random_numbers/benches/xorshift_plus_benchmarks.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: HewlettPackard/woodchipper path: /src/renderer/interactive/search_bar.rs
// (C) Copyright 2019 Hewlett Packard Enterprise Development LP
use std::error::Error;
use std::rc::Rc;
use crossterm::{Terminal, TerminalCursor, KeyEvent, ClearType};
use crate::filter::{Filter, FilterMode};
use crate::... | code_fim | hard | {
"lang": "rust",
"repo": "HewlettPackard/woodchipper",
"path": "/src/renderer/interactive/search_bar.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> selection.rel_index + offset
} else {
// otherwise, start from the beginning
0
};
let mut index = None;
{
let filtered_entries = state.filtered_entries.borrow();
// iter methods aren't quite sufficient here
#[allow(clippy::needless_range_loop)]
... | code_fim | hard | {
"lang": "rust",
"repo": "HewlettPackard/woodchipper",
"path": "/src/renderer/interactive/search_bar.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let input_action = match action {
TextInputAction::Action(a) => a,
TextInputAction::Exit(a) => {
state = actions::update_filter(state);
state = actions::update_highlight(state);
state = actions::update_style(state);
state = bar::actions::set_active(state, BarType::Status)... | code_fim | hard | {
"lang": "rust",
"repo": "HewlettPackard/woodchipper",
"path": "/src/renderer/interactive/search_bar.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let output_files = StagedFiles::default();
let runtime = Box::new(RawIoRuntime::new(input_files, output_files));
let summary = RsaSign::new().run(arguments, runtime).unwrap();
let mut expected_string = fs::read_to_string(expected_output).unwrap();
expected_string =... | code_fim | hard | {
"lang": "rust",
"repo": "apache/incubator-teaclave",
"path": "/function/src/rsa_sign.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: apache/incubator-teaclave path: /function/src/rsa_sign.rs
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses thi... | code_fim | hard | {
"lang": "rust",
"repo": "apache/incubator-teaclave",
"path": "/function/src/rsa_sign.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>rse().unwrap())
.collect();
if v==[0,0]{break}
for (a, b) in (0..2)
.cycle()
.map(|a|(a, a+v[1]))
.take(v[0]){
println!("{}",&x[a..b]);
}
println!();
}
}<|fim_prefix|>// repo: eda3/rust_sandbox path: /01_itp1/itp1_5_c_Print_Chessboard/src/main.rs
use std::io::BufRead;
fn main() {... | code_fim | medium | {
"lang": "rust",
"repo": "eda3/rust_sandbox",
"path": "/01_itp1/itp1_5_c_Print_Chessboard/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: eda3/rust_sandbox path: /01_itp1/itp1_5_c_Print_Chessboard/src/main.rs
use std::io::BufRead;
fn main() {
let x = "#.".repeat(151);
let s=std::io::stdin();
fo<|fim_suffix|>rse().unwrap())
.collect();
if v==[0,0]{break}
for (a, b) in (0..2)
.cycle()
.map(|a|(a, a+v[1]))
.take(v[... | code_fim | medium | {
"lang": "rust",
"repo": "eda3/rust_sandbox",
"path": "/01_itp1/itp1_5_c_Print_Chessboard/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> .map(|a|(a, a+v[1]))
.take(v[0]){
println!("{}",&x[a..b]);
}
println!();
}
}<|fim_prefix|>// repo: eda3/rust_sandbox path: /01_itp1/itp1_5_c_Print_Chessboard/src/main.rs
use std::io::BufRead;
fn main() {
let x = "#.".repeat(151);
let s=std::io::stdin();
fo<|fim_middle|>r l in s.lock().lin... | code_fim | medium | {
"lang": "rust",
"repo": "eda3/rust_sandbox",
"path": "/01_itp1/itp1_5_c_Print_Chessboard/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Thomasdezeeuw/tchannel path: /tests/mpsc.rs
// Copyright 2017 Thomas de Zeeuw
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT
// or http://opensource.org/licenses/MIT>, at your option. This fil... | code_fim | hard | {
"lang": "rust",
"repo": "Thomasdezeeuw/tchannel",
"path": "/tests/mpsc.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (mut sender, receiver) = channel();
let handle = thread::spawn(move || {
thread::sleep(Duration::from_millis(100));
assert_eq!(sender.start_send(value1_c), Ok(AsyncSink::Ready));
thread::sleep(Duration::from_millis(100));
assert_eq!(sender.start_send(value2_c),... | code_fim | hard | {
"lang": "rust",
"repo": "Thomasdezeeuw/tchannel",
"path": "/tests/mpsc.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: EternalReckoning/core path: /src/net/codec/opcode.rs
use crate::net::operation::Operation;
pub type OpcodeType = u8;
pub const CL_SYNC_OP: OpcodeType = 0x00;
pub const SV_SYNC_OP: OpcodeType = 0x01;
pub const CL_CONNECT_MESSAGE_OP: OpcodeType = 0x02;
pub const SV_CONNECT_RESP<|fim_suffix|>n) -... | code_fim | hard | {
"lang": "rust",
"repo": "EternalReckoning/core",
"path": "/src/net/codec/opcode.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>) => SV_CONNECT_RESPONSE_OP,
Operation::SvUpdateWorld(_) => SV_UPDATE_WORLD_OP,
Operation::ClMoveSetPosition(_) => CL_MOVE_SET_POSITION_OP,
Operation::DisconnectMessage => DISCONNECT_MESSAGE_OP,
}
}<|fim_prefix|>// repo: EternalReckoning/core path: /src/net/codec/opcode.rs
use... | code_fim | hard | {
"lang": "rust",
"repo": "EternalReckoning/core",
"path": "/src/net/codec/opcode.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>, 18211, 18217, 18223,
18229, 18233, 18251, 18253, 18257, 18269, 18287, 18289, 18301, 18307, 18311, 18313, 18329,
18341, 18353, 18367, 18371, 18379, 18397, 18401, 18413, 18427, 18433, 18439, 18443, 18451,
18457, 18461, 18481, 18493, 18503, 18517, 18521, 18523, 18539, 18541, 18553, 18583, 18587... | code_fim | hard | {
"lang": "rust",
"repo": "motoras/rust-algos",
"path": "/timus/1055/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: motoras/rust-algos path: /timus/1055/src/main.rs
93, 16699,
16703, 16729, 16741, 16747, 16759, 16763, 16787, 16811, 16823, 16829, 16831, 16843, 16871,
16879, 16883, 16889, 16901, 16903, 16921, 16927, 16931, 16937, 16943, 16963, 16979, 16981,
16987, 16993, 17011, 17021, 17027, 17029, ... | code_fim | hard | {
"lang": "rust",
"repo": "motoras/rust-algos",
"path": "/timus/1055/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>927, 16931, 16937, 16943, 16963, 16979, 16981,
16987, 16993, 17011, 17021, 17027, 17029, 17033, 17041, 17047, 17053, 17077, 17093, 17099,
17107, 17117, 17123, 17137, 17159, 17167, 17183, 17189, 17191, 17203, 17207, 17209, 17231,
17239, 17257, 17291, 17293, 17299, 17317, 17321, 17327, 17333, 17... | code_fim | hard | {
"lang": "rust",
"repo": "motoras/rust-algos",
"path": "/timus/1055/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub struct Sphere<'a> {
pub center: Vector3,
pub radius: f64,
pub material: Box<Material + 'a>,
}
impl<'a> Sphere<'a> {
pub fn new<T: 'a + Material>(center: Vector3, radius: f64, material: T) -> Sphere<'a> {
Sphere {center, radius, material: Box::new(material)}
}
}
impl<'a> H... | code_fim | hard | {
"lang": "rust",
"repo": "smbas/simple-ray-tracer",
"path": "/src/geometry.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: smbas/simple-ray-tracer path: /src/geometry.rs
#![allow(dead_code)]
use std::ops::{Neg, Add, AddAssign, Sub, SubAssign, Mul, MulAssign, Div, DivAssign};
use crate::tracing::{Hit, HitRecord};
use crate::material::{Material};
#[derive(Debug, PartialEq, Copy, Clone)]
pub struct Vector3 {
pub... | code_fim | hard | {
"lang": "rust",
"repo": "smbas/simple-ray-tracer",
"path": "/src/geometry.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn sub(mut self, other: Matrix) -> Matrix {
for i in 0..5 {
for j in 0..5 {
self.coords[i][j] -= other.coords[i][j];
}
}
self
}
}
impl ops::Mul<Matrix> for Matrix {
type Output = Matrix;
fn mul(self, other: Matrix) -> Matrix... | code_fim | hard | {
"lang": "rust",
"repo": "Terkwood/4d-labyrinth",
"path": "/graph4d/src/geometry/matrix.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn scale(x: f64, y: f64, z: f64, w: f64) -> Matrix {
Matrix {
coords: [
[x, 0.0, 0.0, 0.0, 0.0],
[0.0, y, 0.0, 0.0, 0.0],
[0.0, 0.0, z, 0.0, 0.0],
[0.0, 0.0, 0.0, w, 0.0],
[0.0, 0.0, 0.0, 0.0, 1.0],... | code_fim | hard | {
"lang": "rust",
"repo": "Terkwood/4d-labyrinth",
"path": "/graph4d/src/geometry/matrix.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Terkwood/4d-labyrinth path: /graph4d/src/geometry/matrix.rs
use super::vector::Vector;
use std::ops;
#[derive(Clone, Copy)]
pub struct Matrix {
coords: [[f64; 5]; 5],
}
impl Matrix {
pub fn identity() -> Matrix {
Matrix {
coords: [
[1.0, 0.0, 0.0, 0.... | code_fim | hard | {
"lang": "rust",
"repo": "Terkwood/4d-labyrinth",
"path": "/graph4d/src/geometry/matrix.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: budde25/osblog path: /risc_v/chapters/ch4/src/trap.rs
// trap.rs
// Trap routines
// Stephen Marz
// 10 October 2019
use crate::cpu::TrapFrame;
#[no_mangle]
extern "C" fn m_trap(epc: usize,
tval: usize,
cause: usize,
hart: usize,
... | code_fim | hard | {
"lang": "rust",
"repo": "budde25/osblog",
"path": "/risc_v/chapters/ch4/src/trap.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>external interrupt CPU#{}", hart);
},
_ => {
panic!("Unhandled async trap CPU#{} -> {}\n", hart, cause_num);
}
}
}
else {
// Synchronous trap
match cause_num {
2 => {
// Illegal instruction
panic!("Illegal instruction CPU#{} -> 0x{:08x}: 0x{:08x}\n", hart, epc, tval);
},... | code_fim | hard | {
"lang": "rust",
"repo": "budde25/osblog",
"path": "/risc_v/chapters/ch4/src/trap.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: datalove-app/lunatic-sdk path: /examples/channel.rs
use lunatic::{channel, Process};
fn main() {
let (sender, receiver) = channel::unbounded();
let vec: Vec<i32> = (0..3).collect();
for i in vec.iter() {
let process = Process::spawn_with((*i, vec.clone(), sender.clone()), c... | code_fim | medium | {
"lang": "rust",
"repo": "datalove-app/lunatic-sdk",
"path": "/examples/channel.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for _ in vec.iter() {
let (i, sum) = receiver.receive().unwrap();
println!("Sum until {}: {}", i, sum);
}
}
// Child process calculates the sum of numbers of context.1 until context.0 index.
fn child(context: (i32, Vec<i32>, channel::Sender<(i32, i32)>)) {
let i = context.0;
... | code_fim | medium | {
"lang": "rust",
"repo": "datalove-app/lunatic-sdk",
"path": "/examples/channel.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// Child process calculates the sum of numbers of context.1 until context.0 index.
fn child(context: (i32, Vec<i32>, channel::Sender<(i32, i32)>)) {
let i = context.0;
let vec = context.1;
let channel = context.2;
let sum_until_i: i32 = vec[..=i as usize].iter().sum();
channel.send((i,... | code_fim | medium | {
"lang": "rust",
"repo": "datalove-app/lunatic-sdk",
"path": "/examples/channel.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nisarhassan12/materialize path: /src/cloud-api/src/client/cloud_provider.rs
// Copyright Materialize, Inc. and contributors. All rights reserved.
//
// Use of this software is governed by the Business Source License
// included in the LICENSE file.
//
// As of the Change Date specified in that f... | code_fim | hard | {
"lang": "rust",
"repo": "nisarhassan12/materialize",
"path": "/src/cloud-api/src/client/cloud_provider.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Client {
/// List all the available cloud providers.
///
/// E.g.: [us-east-1, eu-west-1]
pub async fn list_cloud_providers(&self) -> Result<Vec<CloudProvider>, Error> {
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
struct CloudProviderResponse {
... | code_fim | hard | {
"lang": "rust",
"repo": "nisarhassan12/materialize",
"path": "/src/cloud-api/src/client/cloud_provider.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yggie/mithril-examples path: /src/main.rs
#![feature(unsafe_destructor)]
#![allow(unstable)]
extern crate gl;
extern crate glfw;
use glfw::{Action, Context, Glfw, Key, Window, WindowEvent};
use graphics::GraphicsEngine;
use std::io;
use std::time;
use std::sync;
mod graphics;
fn main() {
... | code_fim | hard | {
"lang": "rust",
"repo": "yggie/mithril-examples",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.window.swap_buffers();
period.recv().unwrap();
}
}
fn flush_events_queue(&mut self) {
for (time, event) in glfw::flush_messages(&self.events_receiver) {
match event {
glfw::WindowEvent::Key(Key::Escape, _, Action::Press, _) ... | code_fim | hard | {
"lang": "rust",
"repo": "yggie/mithril-examples",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let display = self.conn.get_raw_dpy();
unsafe {
let rms = XResourceManagerString(display);
if !rms.is_null() {
let db = XrmGetStringDatabase(rms);
if !db.is_null() {
let mut value = XrmValue {
... | code_fim | hard | {
"lang": "rust",
"repo": "perlindgren/baseview",
"path": "/src/x11/xcb_connection.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: perlindgren/baseview path: /src/x11/xcb_connection.rs
/// A very light abstraction around the XCB connection.
///
/// Keeps track of the xcb connection itself and the xlib display ID that was used to connect.
use std::ffi::{CStr, CString};
use std::collections::HashMap;
use crate::MouseCursor;... | code_fim | hard | {
"lang": "rust",
"repo": "perlindgren/baseview",
"path": "/src/x11/xcb_connection.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cosmicexplorer/upc path: /local/directory/src/lib.rs
toriesRequest) -> Self {
let ExpandDirectoriesRequest {
num_requests,
requests,
} = req;
HighLevelExpandDirectoriesRequest {
requests: slice::from_raw_parts(requests, num_requests as usize).to_vec(),
}
}
f... | code_fim | hard | {
"lang": "rust",
"repo": "cosmicexplorer/upc",
"path": "/local/directory/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn directory_upload_expand_end_to_end() -> Result<(), DirectoryFFIError> {
let input: Vec<(PathComponents, &str)> = generate_example_input();
let mmapped_input: Vec<(PathComponents, ShmKey)> = input
.iter()
.map(|(c, s)| {
(
c.clone(),
remexec::... | code_fim | hard | {
"lang": "rust",
"repo": "cosmicexplorer/upc",
"path": "/local/directory/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> digests
.map(move |digests| HighLevelExpandDirectoriesMapping {
mapping: digests.into_iter().zip(expansions.into_iter()).collect(),
})
.to_boxed()
}
#[no_mangle]
pub unsafe extern "C" fn directories_upload(
request: *const UploadDirectoriesRequest,
result: *mut UploadDirectoriesRe... | code_fim | hard | {
"lang": "rust",
"repo": "cosmicexplorer/upc",
"path": "/local/directory/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(quote!(
impl awto::protobuf::IntoProtobufService for #ident {
fn protobuf_service() -> awto::protobuf::ProtobufService {
awto::protobuf::ProtobufService {
methods: vec![ #( #methods, )* ],
module_pat... | code_fim | hard | {
"lang": "rust",
"repo": "awto-rs/awto",
"path": "/awto-macros/src/proc_macros/protobuf_service.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: awto-rs/awto path: /awto-macros/src/proc_macros/protobuf_service.rs
use std::iter::FromIterator;
use heck::CamelCase;
use proc_macro2::TokenStream;
use quote::{format_ident, quote, quote_spanned};
use syn::spanned::Spanned;
use crate::{error::Error, util::ProcMacro};
pub struct ProtobufServic... | code_fim | hard | {
"lang": "rust",
"repo": "awto-rs/awto",
"path": "/awto-macros/src/proc_macros/protobuf_service.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Madoshakalaka/async-sqlx-session path: /src/mysql.rs
let store = MySqlSessionStore::from_client(pool)
/// .with_table_name("custom_table_name");
/// store.migrate().await;
/// # Ok(()) }) }
/// ```
pub fn from_client(client: MySqlPool) -> Self {
Self {
... | code_fim | hard | {
"lang": "rust",
"repo": "Madoshakalaka/async-sqlx-session",
"path": "/src/mysql.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (id, count): (String, i64) =
sqlx::query_as("select id, (select count(*) from async_sessions) from async_sessions")
.fetch_one(&mut store.connection().await?)
.await?;
assert_eq!(1, count);
assert_eq!(original_id, id);
Ok(()... | code_fim | hard | {
"lang": "rust",
"repo": "Madoshakalaka/async-sqlx-session",
"path": "/src/mysql.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Madoshakalaka/async-sqlx-session path: /src/mysql.rs
:Result<Self> {
let pool = MySqlPool::connect(database_url).await?;
Ok(Self::from_client(pool))
}
/// constructs a new MySqlSessionStore from a mysql:// url. the
/// default table name for this session store will b... | code_fim | hard | {
"lang": "rust",
"repo": "Madoshakalaka/async-sqlx-session",
"path": "/src/mysql.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kubos/kubos path: /services/clyde-3g-eps-service/src/models/version.rs
//
// Copyright (C) 2019 Kubos Corporation
//
// 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 | medium | {
"lang": "rust",
"repo": "kubos/kubos",
"path": "/services/clyde-3g-eps-service/src/models/version.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Self {
revision: i32::from(version.revision),
firmware_number: i32::from(version.firmware_number),
}
}
}
impl From<VersionInfo> for VersionData {
fn from(info: VersionInfo) -> Self {
Self {
motherboard: info.motherboard.into(),
... | code_fim | hard | {
"lang": "rust",
"repo": "kubos/kubos",
"path": "/services/clyde-3g-eps-service/src/models/version.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Britefury/lspace path: /src/lib/lspace/lspace_window.rs
extern crate time;
use std::rc::Rc;
use std::cell::RefCell;
use std::any::Any;
use std::time::SystemTime;
use druid_shell::kurbo::Size;
use druid_shell::piet::{Color, RenderContext};
use piet_common::Piet;
use druid_shell::{
Applic... | code_fim | hard | {
"lang": "rust",
"repo": "Britefury/lspace",
"path": "/src/lib/lspace/lspace_window.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn size(&mut self, size: Size) {
let event_time = SystemTime::now();
self.handle_realize(&event_time);
self.size = size;
self.area.on_size_allocate(size.width, size.height, &event_time);
self.handle_queued_redraw();
}
fn got_focus(&mut self) {
l... | code_fim | hard | {
"lang": "rust",
"repo": "Britefury/lspace",
"path": "/src/lib/lspace/lspace_window.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let header = JwtHeader::new(JsonWebAlgorithm::PS512);
assert_eq!(header.alg, JsonWebAlgorithm::PS512);
assert_eq!(header.typ.unwrap(), "JWT".to_string());
assert!(header.cty.is_none());
assert!(header.kid.is_none());
}
#[test]
fn create_default() {
... | code_fim | hard | {
"lang": "rust",
"repo": "Darth-Revan/jwt-rs",
"path": "/src/header.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Darth-Revan/jwt-rs path: /src/header.rs
// MIT License
//
// Copyright (c) 2019 Kevin Kirchner
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restrictio... | code_fim | hard | {
"lang": "rust",
"repo": "Darth-Revan/jwt-rs",
"path": "/src/header.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rkanati/aoc2019 path: /day11/src/main.rs
use {
std::{
collections::HashMap,
convert::TryFrom,
},
intcode_rk::{VM, VMResult, parse_programs},
};
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
enum Colour {
Black,
White
}
impl TryFrom<i64> for Colour {
typ... | code_fim | hard | {
"lang": "rust",
"repo": "rkanati/aoc2019",
"path": "/day11/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let part1_paintjob = run_robot(mem.clone(), Colour::Black);
println!("Part 1: distinct panels painted: {}", part1_paintjob.panels.len());
let reg_plate = run_robot(mem, Colour::White);
println!("Part 2:");
let (width, height) = reg_plate.dims();
let mut image: Vec<_> = std::iter... | code_fim | hard | {
"lang": "rust",
"repo": "rkanati/aoc2019",
"path": "/day11/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("waiting mutex release");
mutex.take(5000).expect("Mutex take timeout");
println!("Mutex take successfully");
println!("Deleting mutex: {}", mutex.get_name().as_ref());
mutex.delete().unwrap();
}<|fim_prefix|>// repo: tcz717/rttrust path: /example/stm32f446-rust/rust/src/... | code_fim | hard | {
"lang": "rust",
"repo": "tcz717/rttrust",
"path": "/example/stm32f446-rust/rust/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tcz717/rttrust path: /example/stm32f446-rust/rust/src/lib.rs
#![no_std]
#[macro_use]
extern crate rttrust;
use rttrust::{
ipc::{mutex::Mutex, IpcFlag},
object::Object,
thread::Thread,
Box,
};
#[no_mangle]
pub extern "C" fn rust_main() {
println!("hello rust");
kprintf!... | code_fim | hard | {
"lang": "rust",
"repo": "tcz717/rttrust",
"path": "/example/stm32f446-rust/rust/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shifteight/rust path: /learning/trait_objects/src/main.rs
trait GetSound {
fn get_sound(&self) -> String;
}
struct Cat {
sound: String,
}
impl GetSound for Cat {
fn get_sound(&self) -> String {
self.sound.clone()
}
}
struct Bell {
sound: String,
}
impl GetSound fo... | code_fim | medium | {
"lang": "rust",
"repo": "shifteight/rust",
"path": "/learning/trait_objects/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl GetSound for Bell {
fn get_sound(&self) -> String {
self.sound.clone()
}
}
fn make_sound<T: GetSound>(t: &T) {
println!("{}!", t.get_sound())
}
fn main() {
let kitty = Cat { sound: "Meow".to_string() };
let the_bell = Bell { sound: "Ding Dong".to_string() };
make_sou... | code_fim | medium | {
"lang": "rust",
"repo": "shifteight/rust",
"path": "/learning/trait_objects/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for tv in self.l.iter() {
if tv.t <= t && tv.t > t1 {
t1 = tv.t;
v1 = tv.v;
}
if tv.t >= t && tv.t < t2 {
t2 = tv.t;
v2 = tv.v;
}
}
if t1 == t2 {
v1
... | code_fim | medium | {
"lang": "rust",
"repo": "drbrain/unicornify.rs",
"path": "/src/sorter.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: drbrain/unicornify.rs path: /src/sorter.rs
use crate::TV;
pub struct Sorter {
l: Vec<TV>,
}
impl Sorter {
pub fn new(mut tvs: Vec<TV>) -> Self {
tvs.sort();
let first = tvs.first().unwrap();
let last = tvs.last().unwrap();
let mut l = Vec::with_capacity... | code_fim | hard | {
"lang": "rust",
"repo": "drbrain/unicornify.rs",
"path": "/src/sorter.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> if tv.t >= t && tv.t < t2 {
t2 = tv.t;
v2 = tv.v;
}
}
if t1 == t2 {
v1
} else {
mix_floats(v1, v2, (t - t1) / (t2 - t1))
}
}
}
fn mix_floats(f1: f64, f2: f64, f: f64) -> f64 {
f1 + f *... | code_fim | hard | {
"lang": "rust",
"repo": "drbrain/unicornify.rs",
"path": "/src/sorter.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> Box::new(Self { component })
}
}
struct FruitDecorator {
component: Box<dyn Hamburger>
}
impl FruitDecorator {
const UNIT_PRICE: f32 = 3.0;
}
impl Decorator for FruitDecorator {
fn new(component: Box<dyn Hamburger>) -> Box<dyn Hamburger> {
Box::new(Self { component })
... | code_fim | hard | {
"lang": "rust",
"repo": "MEANyehoon/rust-design-pattern",
"path": "/decorator-pattern/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn cost(&self) -> f32 {
self.component.cost() + Self::UNIT_PRICE
}
}
impl Decorator for FilletDecorator {
fn new(component: Box<dyn Hamburger>) -> Box<dyn Hamburger> {
Box::new(Self { component })
}
}
struct FruitDecorator {
component: Box<dyn Hamburger>
}
impl FruitD... | code_fim | hard | {
"lang": "rust",
"repo": "MEANyehoon/rust-design-pattern",
"path": "/decorator-pattern/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MEANyehoon/rust-design-pattern path: /decorator-pattern/src/lib.rs
trait Hamburger {
fn get_description(&self) -> String;
fn cost(&self) -> f32;
}
struct SimpleHamburger();
impl SimpleHamburger {
const UNIT_PRICE: f32 = 1.0;
}
impl Hamburger for SimpleHamburger {
fn get_descrip... | code_fim | hard | {
"lang": "rust",
"repo": "MEANyehoon/rust-design-pattern",
"path": "/decorator-pattern/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn reinhard(color: &Vector3, exposure: f64, white_point: f64) -> Vector3 {
let color = *color * exposure;
let luminance = color::color_to_luminance(&color);
let white_point = white_point * exposure;
(color * (luminance / (white_point * white_point) + 1.0) / (luminance + 1.0)).saturate()
}<... | code_fim | hard | {
"lang": "rust",
"repo": "shadercoder/hanamaru-renderer",
"path": "/src/tonemap.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shadercoder/hanamaru-renderer path: /src/tonemap.rs
use vector::Vector3;
use config;
use color;
#[allow(dead_code)]
pub enum ToneMappingMode {
None,
Reinhard,
}
pub fn execute(color: &Vector3) -> Vector3 {
match config::TONE_MAPPING_MODE {
ToneMappingMode::None => none(colo... | code_fim | medium | {
"lang": "rust",
"repo": "shadercoder/hanamaru-renderer",
"path": "/src/tonemap.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> *color
}
fn reinhard(color: &Vector3, exposure: f64, white_point: f64) -> Vector3 {
let color = *color * exposure;
let luminance = color::color_to_luminance(&color);
let white_point = white_point * exposure;
(color * (luminance / (white_point * white_point) + 1.0) / (luminance + 1.0))... | code_fim | medium | {
"lang": "rust",
"repo": "shadercoder/hanamaru-renderer",
"path": "/src/tonemap.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: thomcc/smoljson path: /tests/write.rs
use smoljson::write::{Null, Writer};
#[test]
fn test_obj() {
let mut w = Writer::new(true);
let mut o = w.object();
o.put_all(&[("foo", &3), ("a", &"12345 test 123")]);
o.put("test", &["foo", "bar"] as &[&str]);
o.put("baz", &Null);
... | code_fim | hard | {
"lang": "rust",
"repo": "thomcc/smoljson",
"path": "/tests/write.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> "foo",
"bar"
],
"baz": null,
"emptyo": {},
"emptya": [],
"ooo": {
"a b c": 40.45
},
"aaa": [
1,
4,
9
],
"aaapak": [1,2,3,4,5,6,7,8,9,10],
"recs": [
{"foo":1,"bar":1,"baz":["111"],"quux":{"frob":false}},
... | code_fim | hard | {
"lang": "rust",
"repo": "thomcc/smoljson",
"path": "/tests/write.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Relrin/quickproj path: /src/error.rs
use std::path::PathBuf;
use git2::Error as Git2Error;
use fs_extra::error::Error as FsExtraCallError;
use quick_error::quick_error;
use serde_json::error::Error as SerdeJsonError;
<|fim_suffix|>quick_error! {
#[derive(Debug)]
pub enum Error {
... | code_fim | hard | {
"lang": "rust",
"repo": "Relrin/quickproj",
"path": "/src/error.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>quick_error! {
#[derive(Debug)]
pub enum Error {
Io(err: StdIoError) {
from()
description("io error")
display("I/O error: {}", err)
cause(err)
}
IoWithContext(err: StdIoError, source: String) {
display("I/O error w... | code_fim | hard | {
"lang": "rust",
"repo": "Relrin/quickproj",
"path": "/src/error.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: francisco-mendes/anchorage path: /src/anchor.rs
use std::sync::atomic::Ordering;
use crate::{
domain::{
global::GlobalDomain,
Domain,
},
hazbox::HazBox,
hazptr::HazPtr,
Hazard,
};
pub struct Anchor<'dom, D>
where
D: Domain<'dom>,
{
ptr: &'dom HazPtr,... | code_fim | hard | {
"lang": "rust",
"repo": "francisco-mendes/anchorage",
"path": "/src/anchor.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[inline]
pub fn domain(&self) -> D {
self.domain
}
pub fn moor<'r, T>(&'r mut self, src: &'r HazBox<'dom, T, D>) -> &'r T
where
T: Hazard<'dom>,
{
assert!(self.domain == src.domain);
let mut ptr = src.ptr.load(Ordering::Relaxed);
let mut t... | code_fim | hard | {
"lang": "rust",
"repo": "francisco-mendes/anchorage",
"path": "/src/anchor.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.ptr.protect(expected.cast());
crate::asymmetric_fence::light();
let actual = src.ptr.load(Ordering::Acquire);
if expected == actual {
// Safety:
// 1. Target of actual will not be deallocated for the returned lifetime since
// ... | code_fim | hard | {
"lang": "rust",
"repo": "francisco-mendes/anchorage",
"path": "/src/anchor.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>::en_us::OUTPUT),
("es_es".to_owned(), self::es_es::OUTPUT),
]
.into_iter()
);
}<|fim_prefix|>// repo: kyranet/lyrch path: /src/i18n/mod.rs
pub mod definition;
pub mod el_gr;
pub mod en_us;
pub mod es_es;
use std::collections::HashMap;
use std::iter:<|fim_middle|>:FromIte... | code_fim | hard | {
"lang": "rust",
"repo": "kyranet/lyrch",
"path": "/src/i18n/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>ter(
vec![
("el_gr".to_owned(), self::el_gr::OUTPUT),
("en_us".to_owned(), self::en_us::OUTPUT),
("es_es".to_owned(), self::es_es::OUTPUT),
]
.into_iter()
);
}<|fim_prefix|>// repo: kyranet/lyrch path: /src/i18n/mod.rs
pub mod definition;
pu... | code_fim | medium | {
"lang": "rust",
"repo": "kyranet/lyrch",
"path": "/src/i18n/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kyranet/lyrch path: /src/i18n/mod.rs
pub mod definition;
pub mod el_gr;
pub mod en_us;
pub mod es_es;
use std::collections::HashMap;
use std::iter:<|fim_suffix|>::en_us::OUTPUT),
("es_es".to_owned(), self::es_es::OUTPUT),
]
.into_iter()
);
}<|fim_middle|>:FromIte... | code_fim | hard | {
"lang": "rust",
"repo": "kyranet/lyrch",
"path": "/src/i18n/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jqnatividad/qsv path: /tests/test_fetch.rs
n":"CA","latitude":"34.0901"}]}"#
],
svec![
"https://api.zippopotam.us/us/94105",
"200",
"0",
"0",
r#"{"post code":"94105","country":"United States","country abbreviation":"US",... | code_fim | hard | {
"lang": "rust",
"repo": "jqnatividad/qsv",
"path": "/tests/test_fetch.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // this garbled response is actually expected, as httpbin.org does not
// decompress compressed requests so it doesn't get zip-bombed.
// so it just echoed back the gzipped request body.
// https://github.com/postmanlabs/httpbin/issues/577#issuecomment-875814469
// but if this was sent... | code_fim | hard | {
"lang": "rust",
"repo": "jqnatividad/qsv",
"path": "/tests/test_fetch.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jqnatividad/qsv path: /tests/test_fetch.rs
let wrk = Workdir::new("fetch");
wrk.create(
"data.csv",
vec![svec!["URL"], svec!["http://httpbin.org/get"]],
);
let mut cmd = wrk.command("fetch");
cmd.arg("URL")
.arg("--http-header")
.arg("X-Api-Secre... | code_fim | hard | {
"lang": "rust",
"repo": "jqnatividad/qsv",
"path": "/tests/test_fetch.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if scheme_id == description.scheme {
scheme.frename(description.number, reference, uid, gid)
} else {
Err(Error::new(EXDEV))
}
}
/// File status
pub fn fstat(fd: FileHandle, stat: &mut Stat) -> Result<usize> {
let file = {
let contexts = context::contexts();
... | code_fim | hard | {
"lang": "rust",
"repo": "redox-os/kernel",
"path": "/src/syscall/fs.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: redox-os/kernel path: /src/syscall/fs.rs
//! Filesystem syscalls
use alloc::sync::Arc;
use syscall::CallerCtx;
use core::str;
use spin::RwLock;
use crate::context::file::{FileDescriptor, FileDescription};
use crate::context;
use crate::memory::PAGE_SIZE;
use crate::scheme::{self, FileHandle, Op... | code_fim | hard | {
"lang": "rust",
"repo": "redox-os/kernel",
"path": "/src/syscall/fs.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let scheme_id = crate::scheme::pipe::pipe_scheme_id().ok_or(Error::new(ENODEV))?;
let (read_id, write_id) = crate::scheme::pipe::pipe(flags);
let contexts = context::contexts();
let context_lock = contexts.current().ok_or(Error::new(ESRCH))?;
let context = context_lock.read();
le... | code_fim | hard | {
"lang": "rust",
"repo": "redox-os/kernel",
"path": "/src/syscall/fs.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jonysy/parenchyma path: /src/tensor/tensor_type.rs
use ocl::traits::OclPrm as PrimitiveType;
<|fim_suffix|>impl<T: PrimitiveType> TensorType for T {
// ..
}<|fim_middle|>/// A marker trait implemented by primitive types that usable within kernels.
pub trait TensorType: PrimitiveType {
/... | code_fim | medium | {
"lang": "rust",
"repo": "jonysy/parenchyma",
"path": "/src/tensor/tensor_type.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T: PrimitiveType> TensorType for T {
// ..
}<|fim_prefix|>// repo: jonysy/parenchyma path: /src/tensor/tensor_type.rs
use ocl::traits::OclPrm as PrimitiveType;
<|fim_middle|>/// A marker trait implemented by primitive types that usable within kernels.
pub trait TensorType: PrimitiveType {
/... | code_fim | medium | {
"lang": "rust",
"repo": "jonysy/parenchyma",
"path": "/src/tensor/tensor_type.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: petrusbatalha/saga-realworld path: /realworld-balance/src/application/transference_service.rs
use crate::application::error_msgs;
use crate::application::ports::port_out::transference_store::TransferenceStore;
use flume::{Receiver, Sender};
use realworld_shared::structs::{Status, Transfer, Trans... | code_fim | hard | {
"lang": "rust",
"repo": "petrusbatalha/saga-realworld",
"path": "/realworld-balance/src/application/transference_service.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.