text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> IntervalRange {
lower_inclusive: lower,
upper_exclusive: upper,
}
}
}
impl From<(String, String)> for IntervalRange {
fn from((lower, upper): (String, String)) -> Self {
IntervalRange::from((lower.into_bytes(), upper.into_bytes()))
}
}
// FIXME... | code_fim | hard | {
"lang": "rust",
"repo": "CavHack/EinsteinDB",
"path": "/ einsteindb-gen(0).einsteindb-gen/edn-causet-sql/src/storage/range.rs",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|> _old
} = 0_u8;
}
*{
let _old = op;
op = op.offset(1_isize);
_old
} = m_len as u8;
}
... | code_fim | hard | {
"lang": "rust",
"repo": "pat2381/HEMTT",
"path": "/hemtt-paa/src/lzo/lzo1x_compress.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> op = op.offset(1_isize);
_old
} = (m_off >> 3_i32) as u8;
}
}
}
*out_len =
((op as isize).wrapping_sub(out as isize) / ::std::mem::size_of::<u8>() as isize) as usize;
((in_end as isize).wrapping_sub(ii.offset(-(ti a... | code_fim | hard | {
"lang": "rust",
"repo": "pat2381/HEMTT",
"path": "/hemtt-paa/src/lzo/lzo1x_compress.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pat2381/HEMTT path: /hemtt-paa/src/lzo/lzo1x_compress.rs
k;
}
ii = ii.offset(-(ti as isize));
ti = 0_usize;
t = ((ip as isize).wrapping_sub(ii as isize) / ::std::mem::size_of::<u8>() as isize)
as usize;
if t != 0_usize {... | code_fim | hard | {
"lang": "rust",
"repo": "pat2381/HEMTT",
"path": "/hemtt-paa/src/lzo/lzo1x_compress.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.filter_state = output * self.dampening_inverse + self.filter_state * self.dampening;
self.delay_line
.write_and_advance(input + self.filter_state * self.feedback);
output
}
}
#[cfg(test)]
mod tests {
#[test]
fn basic_ticking() {
let mut comb ... | code_fim | medium | {
"lang": "rust",
"repo": "irh/freeverb-rs",
"path": "/src/freeverb/src/comb.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: irh/freeverb-rs path: /src/freeverb/src/comb.rs
use crate::delay_line::DelayLine;
pub struct Comb {
delay_line: DelayLine,
feedback: f64,
filter_state: f64,
dampening: f64,
dampening_inverse: f64,
}
impl Comb {
pub fn new(delay_length: usize) -> Self {
Self {
... | code_fim | medium | {
"lang": "rust",
"repo": "irh/freeverb-rs",
"path": "/src/freeverb/src/comb.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>8, 0xc4, 0x3b, 0x98, 0x42, 0x23, 0x09, 0x24
],
external_ovk: [
0xed, 0xe8, 0xfb, 0x11, 0x37, 0x9b, 0x15, 0xae, 0xc4, 0xfa, 0x4e, 0xc5, 0x12, 0x4c, 0x95, 0x00, 0xad, 0xf4, 0x0e, 0xb6, 0xf7, 0xca, 0xa5, 0xe9, 0xce, 0x80, 0xf6, 0xbd, 0x9e, 0x73, 0xd0, 0xe7
... | code_fim | hard | {
"lang": "rust",
"repo": "daira/zcash-test-vectors",
"path": "/test-vectors/rust/zip_0316.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: daira/zcash-test-vectors path: /test-vectors/rust/zip_0316.rs
struct TestVector {
c: [u8; 32],
pk: [u8; 33],
external_ovk: [u8; 32],
internal_ovk: [u8; 32],
};
// From https://github.com/zcash-hackworks/zcash-test-vectors/b... | code_fim | hard | {
"lang": "rust",
"repo": "daira/zcash-test-vectors",
"path": "/test-vectors/rust/zip_0316.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let allocations = local_alloc.allocate(n * size_of::<*mut u32>()) as *mut *mut u32;
if allocations.is_null() {
abort();
}
for _ in range(0u, 100) {
for j in range(0, n) {
let ptr = allocations.offset(j as int);
*ptr =... | code_fim | hard | {
"lang": "rust",
"repo": "errordeveloper/rust-alloc",
"path": "/test.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: errordeveloper/rust-alloc path: /test.rs
extern crate allocator;
extern crate core;
use allocator::{Allocator, LocalAlloc, local_alloc};
use core::intrinsics::abort;
use core::mem::size_of;
<|fim_suffix|> for j in range(0, n) {
let ptr = allocations.offset(j as int);... | code_fim | hard | {
"lang": "rust",
"repo": "errordeveloper/rust-alloc",
"path": "/test.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for j in range(0, n) {
let ptr = allocations.offset(j as int);
if **ptr != 0xdeadbeef {
abort()
}
local_alloc.deallocate(*ptr as *mut u8, size_of::<u32>())
}
}
local_alloc.deallocate... | code_fim | hard | {
"lang": "rust",
"repo": "errordeveloper/rust-alloc",
"path": "/test.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> unsafe {
assert_eq!(sizes::size_of_libraw_colordata_t() as usize, mem::size_of::<libraw::libraw_colordata_t>());
}
}
#[cfg(have_ph1)]
#[test]
fn it_should_have_same_size_for_ph1_t() {
unsafe {
assert_eq!(sizes::size_of_ph1_t() as usize, mem::size_of::<libraw::ph1_t>());
}
... | code_fim | hard | {
"lang": "rust",
"repo": "dcuddeback/libraw-sys",
"path": "/tests/sizes.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> unsafe {
assert_eq!(sizes::size_of_libraw_data_t() as usize, mem::size_of::<libraw::libraw_data_t>());
}
}
#[test]
fn it_should_have_same_size_for_libraw_image_sizes_t() {
unsafe {
assert_eq!(sizes::size_of_libraw_image_sizes_t() as usize, mem::size_of::<libraw::libraw_image_s... | code_fim | hard | {
"lang": "rust",
"repo": "dcuddeback/libraw-sys",
"path": "/tests/sizes.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dcuddeback/libraw-sys path: /tests/sizes.rs
extern crate libraw_sys as libraw;
use std::mem;
#[link(name = "sizes")]
mod sizes {
extern crate libc;
use self::libc::size_t;
extern "C" {
pub fn size_of_libraw_data_t() -> size_t;
pub fn size_of_libraw_image_sizes_t()... | code_fim | hard | {
"lang": "rust",
"repo": "dcuddeback/libraw-sys",
"path": "/tests/sizes.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stenverbois/amethyst path: /amethyst_audio/src/formats.rs
use super::Source as Audio;
use amethyst_assets::*;
#[derive(Clone)]
pub struct AudioData(pub Vec<u8>);
/// Loads audio from wav files.
#[derive(Clone)]
pub struct WavFormat;
impl SimpleFormat<Audio> for WavFormat {
const NAME: &'s... | code_fim | hard | {
"lang": "rust",
"repo": "stenverbois/amethyst",
"path": "/amethyst_audio/src/formats.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl SimpleFormat<Audio> for Mp3Format {
const NAME: &'static str = "MP3";
type Options = ();
fn import(&self, bytes: Vec<u8>, _: ()) -> Result<AudioData> {
Ok(AudioData(bytes))
}
}<|fim_prefix|>// repo: stenverbois/amethyst path: /amethyst_audio/src/formats.rs
use super::Source... | code_fim | hard | {
"lang": "rust",
"repo": "stenverbois/amethyst",
"path": "/amethyst_audio/src/formats.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Calculate collision tiles
let layer = tiled_map
.get_layer_by_name(&String::from(LAYER_TILE_COLLISION_MAP))
.unwrap();
for (y, row) in &layer.tiles {
for (x, tile) in row {
if tile.gid != 0 {
qom_map.collisi... | code_fim | hard | {
"lang": "rust",
"repo": "MatthewFrench/Quest-of-Magic-Crossplatform",
"path": "/src/qom/qom_map.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MatthewFrench/Quest-of-Magic-Crossplatform path: /src/qom/qom_map.rs
use crate::qom::qom_map::qom_layer::QomLayer;
use crate::qom::qom_map::qom_object::qom_entrance_object::QomEntranceObject;
use crate::qom::qom_map::qom_object::qom_house_object::QomHouseObject;
use crate::qom::qom_map::qom_obje... | code_fim | hard | {
"lang": "rust",
"repo": "MatthewFrench/Quest-of-Magic-Crossplatform",
"path": "/src/qom/qom_map.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mre/slack path: /src/types.rs
extern crate serde;
extern crate serde_json;
extern crate serde_urlencoded;
use std;
use errors::*;
use self::serde::{Deserialize, Deserializer};
use std::io::Read;
use hyper::client::Response as HyperResponse;
#[derive(Debug)]
pub struct Response {
pub hyper_... | code_fim | hard | {
"lang": "rust",
"repo": "mre/slack",
"path": "/src/types.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Missing field: "latest": { ... }
let channel: Channel = serde_json::from_str(&raw_json).unwrap();
assert!(channel.created == 1360782804);
assert!(channel.is_general == false);
}
#[test]
fn decode_reaction() {
let raw_json = r#"{
"name": "sweet_potato",
"count": 5,
... | code_fim | hard | {
"lang": "rust",
"repo": "mre/slack",
"path": "/src/types.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if found_prefix_fully {
buffer.push('{');
}
}
pub(crate) fn expand_by_wrapper(
value: &str,
meta_info: &InstructionMetaInfo,
variables: &HashMap<String, String>,
) -> ExpandedValue {
let mut value_string = String::new();
let mut prefix_index = 0;
let mut found_pre... | code_fim | hard | {
"lang": "rust",
"repo": "sagiegurari/duckscript",
"path": "/duckscript/src/expansion.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sagiegurari/duckscript path: /duckscript/src/expansion.rs
//! # expansion
//!
//! The expand utility functions.
//!
#[cfg(test)]
#[path = "./expansion_test.rs"]
mod expansion_test;
use crate::parser;
use crate::types::instruction::InstructionMetaInfo;
use std::collections::HashMap;
pub(crate)... | code_fim | hard | {
"lang": "rust",
"repo": "sagiegurari/duckscript",
"path": "/duckscript/src/expansion.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if force_push {
value_string.push('\\');
} else if key.len() > 0 {
if prefix_index > 0 || found_prefix {
push_prefix(&mut value_string, single_type, found_prefix);
}
value_string.push_str(&key);
} else if prefix_index == 1 {
push_prefix(&mut ... | code_fim | hard | {
"lang": "rust",
"repo": "sagiegurari/duckscript",
"path": "/duckscript/src/expansion.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn on_enter(pstg: &mut PlayStg, ctx: &mut Context, curr: Pos) {
pstg.game.take_snapshot();
ctx.state.clear_hints();
if pstg.game.is_deck_clicked(Some(curr)) {
ctx.moved = true;
ctx.state.clear_mark();
pstg.game.deal();
}
let sel = ctx.state.marked();
if sel.... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/solkit",
"path": "/src/bin/solkit/play_stg.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> y += 2;
let markcardtext = "Marked card:";
let markcardpos = ctx.state.marked();
let markcard = if markcardpos.is_empty() { Card::new_empty() } else { self.game.card_at(markcardpos) };
scr.write_string(markcardtext, x, y);
if markcardpos.is_empty() || markca... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/solkit",
"path": "/src/bin/solkit/play_stg.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iCodeIN/solkit path: /src/bin/solkit/play_stg.rs
ring(game: &Game, col: usize) -> &'static str {
let cnt = game.pile_count();
if cnt != 0 {
let first = game.first_pile().expect("first pile must exist");
if col == first {
return DCK_STR;
}
if co... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/solkit",
"path": "/src/bin/solkit/play_stg.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: amrltqt/rpc_example_rs path: /src/client.rs
use std::net::TcpStream;
use rpc_example_rs::models::{OperationRequest, PermittedOperations, OperationResponse};
<|fim_suffix|> let ops = OperationRequest {
op: PermittedOperations::Sum,
args: vec![1.0, 2.0, 3.0]
};
let _... | code_fim | medium | {
"lang": "rust",
"repo": "amrltqt/rpc_example_rs",
"path": "/src/client.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let ops = OperationRequest {
op: PermittedOperations::Sum,
args: vec![1.0, 2.0, 3.0]
};
let _ = serde_json::to_writer(&stream, &ops);
let result = OperationResponse::try_from_stream(&stream);
match result {
Ok(response) => {
println!("{:?}", re... | code_fim | medium | {
"lang": "rust",
"repo": "amrltqt/rpc_example_rs",
"path": "/src/client.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
input! {
n: usize,
};
let mut ans = 0;
for &d_i in divisors(n).iter() {
if d_i == 1 {
continue;
}
if n % (d_i - 1) == n / (d_i - 1) {
ans += d_i - 1;
}
}
println!("{}", ans);
}<|fim_prefix|>// repo: bouzuya... | code_fim | hard | {
"lang": "rust",
"repo": "bouzuya/rust-atcoder",
"path": "/cargo-atcoder/contests/diverta2019/src/bin/d.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bouzuya/rust-atcoder path: /cargo-atcoder/contests/diverta2019/src/bin/d.rs
use proconio::input;
fn divisors(n: usize) -> Vec<usize> {
<|fim_suffix|> input! {
n: usize,
};
let mut ans = 0;
for &d_i in divisors(n).iter() {
if d_i == 1 {
continue;
... | code_fim | hard | {
"lang": "rust",
"repo": "bouzuya/rust-atcoder",
"path": "/cargo-atcoder/contests/diverta2019/src/bin/d.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_line_new() {
let l = Line::from("FOOBAR");
assert_eq!(l.low_buf, "foobar");
}
#[test]
fn test_line_length() {
let l = Line::from("foo");
assert_eq!(l.len(), 3);
}
#[test]
fn test_low_char_vec() {
let l = Line::from("... | code_fim | medium | {
"lang": "rust",
"repo": "deathlyfrantic/star",
"path": "/src/line.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let l = Line::from("FOOBAR");
assert_eq!(l.low_buf, "foobar");
}
#[test]
fn test_line_length() {
let l = Line::from("foo");
assert_eq!(l.len(), 3);
}
#[test]
fn test_low_char_vec() {
let l = Line::from("FOOBAR");
for (i, c) in l.low... | code_fim | medium | {
"lang": "rust",
"repo": "deathlyfrantic/star",
"path": "/src/line.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: deathlyfrantic/star path: /src/line.rs
#[derive(Debug, PartialEq, Eq)]
pub struct Line {
pub index: usize,
pub buf: String,
pub low_buf: String,
pub low_char_vec: Vec<(usize, char)>,
}
impl Line {
pub fn new(buf: String, index: usize) -> Self {
let low_buf = buf.to_l... | code_fim | medium | {
"lang": "rust",
"repo": "deathlyfrantic/star",
"path": "/src/line.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: arturkow2000/rust-psutil path: /src/process/collector.rs
// #[cfg(feature = "serde")]
// use serde::{Deserialize, Serialize};
use std::collections::BTreeMap;
use crate::process::{self, Process};
use crate::{Pid, Result};
// FIXME: Process cannot be serialized/deserialize, as a result,
// ... | code_fim | medium | {
"lang": "rust",
"repo": "arturkow2000/rust-psutil",
"path": "/src/process/collector.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> new.into_iter().for_each(|(pid, process)| {
// add new processes and replace processes with reused PIDs
if !self.processes.contains_key(&pid) || self.processes[&pid] != process {
self.processes.insert(pid, process);
} else {
// Update data used for oneshot.
#[cfg(target_os = "linux"... | code_fim | hard | {
"lang": "rust",
"repo": "arturkow2000/rust-psutil",
"path": "/src/process/collector.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let rv = {$($rega)*};
assert_eq!(rv.code, $error_code);
assert_eq!(rv.description, format!("Invalid parameter: {}", $error_msg));
}
};
}
test_register_empty_param!(
test_register_account_empty_name_param,
4002,
"full name cannot be empty",
... | code_fim | hard | {
"lang": "rust",
"repo": "fatkhur1960/hello-officeboy-dev",
"path": "/tests/account.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fatkhur1960/hello-officeboy-dev path: /tests/account.rs
mod common;
use crate::common::prelude::*;
#[test]
fn test_new_account_has_keypair() {
let testkit = create_testkit();
let helper = testkit.helper();
let accounts = helper.generate_accounts(2, true);
assert_eq!(accounts.le... | code_fim | hard | {
"lang": "rust",
"repo": "fatkhur1960/hello-officeboy-dev",
"path": "/tests/account.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kcking/clickhouse.rs path: /src/rowbinary/de.rs
use std::{borrow::Cow, convert::TryFrom, mem, str};
use bytes::Buf;
use serde::{
de::{DeserializeSeed, Deserializer, SeqAccess, Visitor},
Deserialize,
};
use crate::error::{Error, Result};
/// Deserializes a value from `buffer` with a me... | code_fim | hard | {
"lang": "rust",
"repo": "kcking/clickhouse.rs",
"path": "/src/rowbinary/de.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> todo!();
}
#[inline]
fn deserialize_struct<V: Visitor<'de>>(
self,
_name: &str,
fields: &'static [&'static str],
visitor: V,
) -> Result<V::Value> {
self.deserialize_tuple(fields.len(), visitor)
}
#[inline]
fn deserialize_identi... | code_fim | hard | {
"lang": "rust",
"repo": "kcking/clickhouse.rs",
"path": "/src/rowbinary/de.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: XOSplicer/abao path: /src/utils.rs
use std::cell::Cell;
pub(crate) fn cell_from_mut<T: ?Sized>(t: &mut <|fim_suffix|>pub(crate) fn cell_as_slice_of_cells<T>(cell: &Cell<[T]>) -> &[Cell<T>] {
unsafe { &*(cell as *const Cell<[T]> as *const [Cell<T>]) }
}<|fim_middle|>T) -> &Cell<T> {
unsa... | code_fim | medium | {
"lang": "rust",
"repo": "XOSplicer/abao",
"path": "/src/utils.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>>] {
unsafe { &*(cell as *const Cell<[T]> as *const [Cell<T>]) }
}<|fim_prefix|>// repo: XOSplicer/abao path: /src/utils.rs
use std::cell::Cell;
pub(crate) fn cell_from_mut<T: ?Sized>(t: &mut T) -> &Cell<T> {
unsafe { &*(t as *mut T as *const Cell<T>) }
}
<|fim_middle|>pub(crate) fn cell_as_sli... | code_fim | medium | {
"lang": "rust",
"repo": "XOSplicer/abao",
"path": "/src/utils.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut data = vec![5, 4, 3, 3, 1, 2, 3];
sort(&mut data);
assert_eq!(vec![1, 2, 3, 3, 3, 4, 5], data);
}
#[test]
fn test_sort2_output_is_ordered() {
let mut data = vec![5, 4, 3, 3, 1, 2, 3];
sort2(&mut data);
assert_eq!(vec![1, 2, 3, 3, 3, 4, 5... | code_fim | hard | {
"lang": "rust",
"repo": "onelson/clrs-rs",
"path": "/src/insertion_sort.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: onelson/clrs-rs path: /src/insertion_sort.rs
//! Insertion Sort (Chapter 2: Getting Started)
//!
//! ```text
//! for j = 2 to A.length
//! key = A[j]
//! // insert A[j] into the sorted sequence A[1 .. j - 1]
//! i = j - 1
//! while i > 0 and A[i] > key
//! a[i + 1] = A[i]... | code_fim | hard | {
"lang": "rust",
"repo": "onelson/clrs-rs",
"path": "/src/insertion_sort.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut data = vec![5, 4, 3, 3, 1, 2, 3];
sort2(&mut data);
assert_eq!(vec![1, 2, 3, 3, 3, 4, 5], data);
}
}<|fim_prefix|>// repo: onelson/clrs-rs path: /src/insertion_sort.rs
//! Insertion Sort (Chapter 2: Getting Started)
//!
//! ```text
//! for j = 2 to A.length
//! key... | code_fim | hard | {
"lang": "rust",
"repo": "onelson/clrs-rs",
"path": "/src/insertion_sort.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // ループ
loop {
println!("again");
break;
}
// while
let mut number = 3;
while number != 0 {
println!("{}!", number);
number = number - 1;
}
// for in
let array = [1, 2, 3, 4, 5];
// forループはもっとも使う
for element in array.iter() {
... | code_fim | medium | {
"lang": "rust",
"repo": "azu/rust-programming-languages-second-edition-sandbox",
"path": "/control_flow/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: azu/rust-programming-languages-second-edition-sandbox path: /control_flow/src/main.rs
fn main() {
let number = 3;
if number < 5 {
println!("success");
} else {
println!("failure");
}
// 暗黙的な変換はしない
// if number {}
// if式
<|fim_suffix|> // ループ
lo... | code_fim | medium | {
"lang": "rust",
"repo": "azu/rust-programming-languages-second-edition-sandbox",
"path": "/control_flow/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jimy-byerley/tri-mesh path: /examples/dust/src/pipelines/forward.rs
use gl;
use crate::core::rendertarget;
use crate::core::rendertarget::Rendertarget;
use crate::pipelines::Error;
pub struct ForwardPipeline {
gl: gl::Gl,
rendertarget: rendertarget::ScreenRendertarget
}
<|fim_suffix|>... | code_fim | hard | {
"lang": "rust",
"repo": "jimy-byerley/tri-mesh",
"path": "/examples/dust/src/pipelines/forward.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl ForwardPipeline
{
pub fn new(gl: &gl::Gl, screen_width: usize, screen_height: usize, clear_color: crate::types::Vec4) -> Result<ForwardPipeline, Error>
{
let rendertarget = rendertarget::ScreenRendertarget::new(gl, screen_width, screen_height, clear_color)?;
Ok(ForwardPipeline... | code_fim | medium | {
"lang": "rust",
"repo": "jimy-byerley/tri-mesh",
"path": "/examples/dust/src/pipelines/forward.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn render_pass_begin(&self)
{
self.rendertarget.bind();
self.rendertarget.clear();
}
}<|fim_prefix|>// repo: jimy-byerley/tri-mesh path: /examples/dust/src/pipelines/forward.rs
use gl;
use crate::core::rendertarget;
use crate::core::rendertarget::Rendertarget;
use crate::... | code_fim | hard | {
"lang": "rust",
"repo": "jimy-byerley/tri-mesh",
"path": "/examples/dust/src/pipelines/forward.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Alphalink/rust-netflow path: /src/flowset/template_parser.rs
use crate::error::ParseResult;
use crate::flowset::Record;
pub trait TemplateParser {
fn get_id(&self) -> u16;
fn parse_dataflow<'a>(&self, payload: &'a [u8]) -> ParseResult<'a, Record>;
<|fim_suffix|> fn parse_dataflows<'a... | code_fim | medium | {
"lang": "rust",
"repo": "Alphalink/rust-netflow",
"path": "/src/flowset/template_parser.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let record_count = length / self.get_template_len();
let mut record_vec = Vec::with_capacity(record_count as usize);
let mut rest = payload;
for _ in 0..record_count {
let (next, rec) = self.parse_dataflow(rest)?;
record_vec.push(rec);
r... | code_fim | medium | {
"lang": "rust",
"repo": "Alphalink/rust-netflow",
"path": "/src/flowset/template_parser.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: red75prime/rusty-com-port path: /src/d2d1_1_safe.rs
#[allow(non_snake_case)]
fn push_axis_aligned_clip(&self, clipRect: &D2D1_RECT_F, antialiasMode: D2D1_ANTIALIAS_MODE) -> HResult<HRESULT> {
let _hr=unsafe { (*(self.iptr() as *mut ID2D1CommandSink)).PushAxisAlignedClip(clipRect, ... | code_fim | hard | {
"lang": "rust",
"repo": "red75prime/rusty-com-port",
"path": "/src/d2d1_1_safe.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: red75prime/rusty-com-port path: /src/d2d1_1_safe.rs
elf) -> HResult<HRESULT> {
let _hr=unsafe { (*(self.iptr() as *mut ID2D1Bitmap1)).Unmap() };
hr2ret(_hr,_hr)
}
}
impl TUnknown for D2D1Bitmap1 {
fn new(ptr: *mut IUnknown) -> Self {
D2D1Bitmap1(ptr as *mut _)
}
fn ... | code_fim | hard | {
"lang": "rust",
"repo": "red75prime/rusty-com-port",
"path": "/src/d2d1_1_safe.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[allow(non_snake_case)]
fn push_layer_dc(&self, layerParameters: &D2D1_LAYER_PARAMETERS1, layer: &mut ID2D1Layer) -> () {
let _hr=unsafe { (*(self.iptr() as *mut ID2D1DeviceContext)).PushLayer(layerParameters, layer) };
()
}
// Method InvalidateEffectInputRectangle
#[allow(non... | code_fim | hard | {
"lang": "rust",
"repo": "red75prime/rusty-com-port",
"path": "/src/d2d1_1_safe.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nricciar/serverless-rs path: /src/functions.rs
extern crate v8;
extern crate reqwest;
extern crate serde;
extern crate serde_json;
use std::str;
use response::{Response};
use request::{Request};
use headers::{Header};
pub fn parse_json(info: v8::value::FunctionCallbackInfo) -> Result<v8::valu... | code_fim | hard | {
"lang": "rust",
"repo": "nricciar/serverless-rs",
"path": "/src/functions.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let response_obj = info.this.clone();
let request_obj = Response::from_js(&info.isolate, &context, &response_obj);
let list = response_obj.get(&context, &v8::value::String::from_str(&info.isolate, "headers")).into_array().unwrap();
... | code_fim | hard | {
"lang": "rust",
"repo": "nricciar/serverless-rs",
"path": "/src/functions.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> x_init += pat[0].len();
}
for (y, line) in text.iter().enumerate()
{
for (x, c) in line.chars().enumerate()
{
image.put_pixel(
(x_init + x) as u32,
(y_init + y) as u32,
... | code_fim | hard | {
"lang": "rust",
"repo": "Matthew-Maclean/path-tracer-gpu",
"path": "/src/scene.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Matthew-Maclean/path-tracer-gpu path: /src/scene.rs
self,
res: [u32; 2],
depth: u32,
condition: &dyn Fn(u32) -> bool,
debug: bool)
-> image::RgbImage
{
let start = std::time::Instant::now();
let mut image = Vec::with_capacity((res[0] * ... | code_fim | hard | {
"lang": "rust",
"repo": "Matthew-Maclean/path-tracer-gpu",
"path": "/src/scene.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Matthew-Maclean/path-tracer-gpu path: /src/scene.rs
: Camera
{
pos: pos,
front: front,
up: up,
fov: fov,
},
triangles: Vec::new(),
materials: Vec::new(),
}
}
pub fn re... | code_fim | hard | {
"lang": "rust",
"repo": "Matthew-Maclean/path-tracer-gpu",
"path": "/src/scene.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mnts26/aws-sdk-rust path: /sdk/costexplorer/src/json_ser.rs
).string(var_122);
}
}
pub fn serialize_structure_crate_input_get_reservation_utilization_input(
object: &mut smithy_json::serialize::JsonObjectWriter,
input: &crate::input::GetReservationUtilizationInput,
) {
if let So... | code_fim | hard | {
"lang": "rust",
"repo": "mnts26/aws-sdk-rust",
"path": "/sdk/costexplorer/src/json_ser.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn serialize_structure_crate_input_get_tags_input(
object: &mut smithy_json::serialize::JsonObjectWriter,
input: &crate::input::GetTagsInput,
) {
if let Some(var_184) = &input.search_string {
object.key("SearchString").string(var_184);
}
if let Some(var_185) = &input.time_p... | code_fim | hard | {
"lang": "rust",
"repo": "mnts26/aws-sdk-rust",
"path": "/sdk/costexplorer/src/json_ser.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn serialize_structure_crate_input_get_anomalies_input(
object: &mut smithy_json::serialize::JsonObjectWriter,
input: &crate::input::GetAnomaliesInput,
) {
if let Some(var_21) = &input.monitor_arn {
object.key("MonitorArn").string(var_21);
}
if let Some(var_22) = &input.dat... | code_fim | hard | {
"lang": "rust",
"repo": "mnts26/aws-sdk-rust",
"path": "/sdk/costexplorer/src/json_ser.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_nested_vec() {
let bad_foo = Foo { foo: "hi!".into() };
let bad_baz = Baz { baz: vec![bad_foo] };
let err = format!("{}", bad_baz.validate().unwrap_err());
assert_eq!(err, "baz[0].foo: Please provide a valid foo!");
}
}<|fim_prefix|>// repo: Keat... | code_fim | hard | {
"lang": "rust",
"repo": "Keats/validator",
"path": "/validator/tests/display.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Keats/validator path: /validator/tests/display.rs
#[cfg(derive)]
mod tests {
use validator::Validate;
#[derive(Validate, Clone)]
struct Foo {
#[validate(length(equal = 5, message = "Please provide a valid foo!"))]
foo: String,
}
#[test]
fn test_message()... | code_fim | hard | {
"lang": "rust",
"repo": "Keats/validator",
"path": "/validator/tests/display.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let res = client
.get(&format!("{}/gestures", address))
.send()
.await
.unwrap();
let gestures: Vec<Gesture> = res.json().await.unwrap();
let tags = vec!["tag1".to_owned(), "tag2".to_owned()];
assert_eq!(
vec![Gesture {
id: "ce27c124-e4... | code_fim | hard | {
"lang": "rust",
"repo": "Greedeuh/mon_oeil",
"path": "/mon_oeil_srv/tests/pictures.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Greedeuh/mon_oeil path: /mon_oeil_srv/tests/pictures.rs
= multipart::Form::new().part(
"picture",
multipart::Part::bytes(file)
.file_name("dummy.png")
.mime_str("image/png")
.unwrap(),
);
let res = client
.post(&format!(
... | code_fim | hard | {
"lang": "rust",
"repo": "Greedeuh/mon_oeil",
"path": "/mon_oeil_srv/tests/pictures.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let uuid = res.text().await.unwrap();
let uuid2 = uuid.replace("\"", "");
assert_ne!(uuid1, uuid2)
}
#[actix_rt::test]
#[serial]
async fn get_gestures_after_post_picture_should_return_gesture_with_posted_picture() {
setup::reset_db();
setup::insert_gesture_without_links();
let a... | code_fim | hard | {
"lang": "rust",
"repo": "Greedeuh/mon_oeil",
"path": "/mon_oeil_srv/tests/pictures.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for chan in 0..end {
to.channel_mut(chan).translate_from(from.channel(chan));
}
}<|fim_prefix|>// repo: aethertap/audio path: /audio/src/buf/utils.rs
//! Utilities for manipulating audio buffers.
use audio_core::Translate;
use audio_core::{Channels, ChannelsMut};
/// Copy from the buffe... | code_fim | hard | {
"lang": "rust",
"repo": "aethertap/audio",
"path": "/audio/src/buf/utils.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aethertap/audio path: /audio/src/buf/utils.rs
//! Utilities for manipulating audio buffers.
use audio_core::Translate;
use audio_core::{Channels, ChannelsMut};
/// Copy from the buffer specified by `from` into the buffer specified by `to`.
///
/// Only the common count of channels will be copi... | code_fim | hard | {
"lang": "rust",
"repo": "aethertap/audio",
"path": "/audio/src/buf/utils.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Returns the name of a Swift type represented by a metadata object.
#[inline]
#[doc(alias = "swift_getTypeName")]
pub unsafe fn name(this: *const Self, qualified: bool) -> &'static str {
let name = fns::swift_getTypeName(this, qualified);
let slice = slice::from_raw_part... | code_fim | hard | {
"lang": "rust",
"repo": "Dante-Broggi/swift-bindgen",
"path": "/swift-sys/src/metadata/metadata.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Dante-Broggi/swift-bindgen path: /swift-sys/src/metadata/metadata.rs
use crate::{
ctx_desc::TypeContextDescriptor,
metadata::{fns, MetadataKind, MetadataRequest, MetadataResponse, ValueWitnessTable},
};
use std::{ffi::c_void, ptr, slice, str};
/// Raw type metadata.
///
/// This type de... | code_fim | hard | {
"lang": "rust",
"repo": "Dante-Broggi/swift-bindgen",
"path": "/swift-sys/src/metadata/metadata.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Rectangle {h, w}
}
fn draw(&self) {
for i in 1..=self.h {
for j in 1..=self.w {
if i == 1 || i == self.h || j == 1 || j == self.w {
print!("#");
} else {
print!(".");
}
... | code_fim | medium | {
"lang": "rust",
"repo": "mhirai-bit/AIZU_ONLNE_JUDGE_RUST",
"path": "/Courses/Lesson-ITP1/ITP1_5_B/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mhirai-bit/AIZU_ONLNE_JUDGE_RUST path: /Courses/Lesson-ITP1/ITP1_5_B/src/main.rs
//Print a Frame
fn main() {
let mut rectangles: Vec<Rectangle> = vec![];
loop{
match read() {
(0, 0) => break,
(a, b) => {
let rectangle = Rectangle::new((a, ... | code_fim | hard | {
"lang": "rust",
"repo": "mhirai-bit/AIZU_ONLNE_JUDGE_RUST",
"path": "/Courses/Lesson-ITP1/ITP1_5_B/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>const INPUT1:&str = "68936
53526
62556
115539
119659
77887
101443
71392
130327
56769
55083
101448
63985
60433
80302
101264
134416
112047
143310
73842
124020
50346
124192
119547
59351
122161
103742
107648
132879
65047
70234
54569
72785
120259
134533
61778
89183
144270
68600
134849
120221
126887
128483
1012... | code_fim | hard | {
"lang": "rust",
"repo": "peterdk/advent_of_code",
"path": "/2019/day_1/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: peterdk/advent_of_code path: /2019/day_1/src/main.rs
struct Module{
mass:i32,
}
impl Module
{
fn fuel(&self) -> i32{
((self.mass as f64 / 3.0).floor() as i32 - 2) as i32
}
}
fn main() {
<|fim_suffix|>}
const INPUT1:&str = "68936
53526
62556
115539
119659
77887
101443
71392
130327
5676... | code_fim | hard | {
"lang": "rust",
"repo": "peterdk/advent_of_code",
"path": "/2019/day_1/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ebug, Clone)]
pub struct FieldAccess {
pub value: Pos<Box<AST>>,
pub field: Pos<Ident>,
}
impl_into_enum!(FieldAccess => AST:FieldAccess);<|fim_prefix|>// repo: NyxCode/Ketamine path: /parser/src/ast/field_access.rs
use crate::ast::{Ident, AST};
use crate::impl_into_enum;
use crate::Pos;<|fim_mid... | code_fim | medium | {
"lang": "rust",
"repo": "NyxCode/Ketamine",
"path": "/parser/src/ast/field_access.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: NyxCode/Ketamine path: /parser/src/ast/field_access.rs
use crate::ast::{Ident, AST};
use crate::impl_into_enum;
use crate::Pos;<|fim_suffix|>pub field: Pos<Ident>,
}
impl_into_enum!(FieldAccess => AST:FieldAccess);<|fim_middle|>
#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
#[der... | code_fim | medium | {
"lang": "rust",
"repo": "NyxCode/Ketamine",
"path": "/parser/src/ast/field_access.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>struct S1;
struct S2 {
s1: S1,
}
impl Call for S1 {
#[inline(never)]
fn maybe_panic(&self) { }
fn maybe_panic2(&self) {
panic!()
}
}
/// Should not panic
#[inline(never)]
pub fn maybe_panic() {
let s1 = S1{};
let s = &s1 as &Call;
s.maybe_panic2();
}
/// Should ... | code_fim | medium | {
"lang": "rust",
"repo": "Technolution/rustig",
"path": "/test_subjects_lib/src/same_vtable.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Technolution/rustig path: /test_subjects_lib/src/same_vtable.rs
// (C) COPYRIGHT 2018 TECHNOLUTION BV, GOUDA NL
// 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/license... | code_fim | medium | {
"lang": "rust",
"repo": "Technolution/rustig",
"path": "/test_subjects_lib/src/same_vtable.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wotsushi/competitive-programming path: /etc/nikkei2019-2-qual/c.rs
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]
fn main() {
let N: usize = {
let mut line: String = String::new();
std::io::stdin().read_line(&mut line).unwrap();
line.trim(... | code_fim | hard | {
"lang": "rust",
"repo": "wotsushi/competitive-programming",
"path": "/etc/nikkei2019-2-qual/c.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> resp.unstable_features
.insert("org.matrix.e2e_cross_signing".to_owned(), true);
Ok(resp.into())
}<|fim_prefix|>// repo: bbigras/conduit-1 path: /src/client_server/unversioned.rs
use crate::ConduitResult;
use ruma::api::client::unversioned::get_supported_versions;
#[cfg(feature = "condu... | code_fim | hard | {
"lang": "rust",
"repo": "bbigras/conduit-1",
"path": "/src/client_server/unversioned.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bbigras/conduit-1 path: /src/client_server/unversioned.rs
use crate::ConduitResult;
use ruma::api::client::unversioned::get_supported_versions;
#[cfg(feature = "conduit_bin")]
use rocket::get;
<|fim_suffix|> resp.unstable_features
.insert("org.matrix.e2e_cross_signing".to_owned(), t... | code_fim | hard | {
"lang": "rust",
"repo": "bbigras/conduit-1",
"path": "/src/client_server/unversioned.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alastairreid/oak path: /oak_runtime/src/node/wasm/mod.rs
rInvalidArgs
})?;
let handles: Vec<u64> = raw_handles
.chunks(8)
.map(|bytes| LittleEndian::read_u64(bytes))
.collect();
let msg = NodeMessage { bytes, handles };
se... | code_fim | hard | {
"lang": "rust",
"repo": "alastairreid/oak",
"path": "/oak_runtime/src/node/wasm/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alastairreid/oak path: /oak_runtime/src/node/wasm/mod.rs
Err(OakStatus::ErrHandleSpaceTooSmall)
}
}
}
}
/// Corresponds to the host ABI function [`wait_on_channels`](https://github.com/project-oak/oak/blob/main/docs/abi.md#wait_on_channel... | code_fim | hard | {
"lang": "rust",
"repo": "alastairreid/oak",
"path": "/oak_runtime/src/node/wasm/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(())
}
}
/// A helper function to move between our specific result type `Result<(), OakStatus>` and the
/// `wasmi` specific result type `Result<Option<wasmi::RuntimeValue>, wasmi::Trap>`, mapping:
/// - `Ok(())` to `Ok(Some(OakStatus::Ok))`
/// - `Err(x)` to `Ok(Some(x))`
fn map_host_error... | code_fim | hard | {
"lang": "rust",
"repo": "alastairreid/oak",
"path": "/oak_runtime/src/node/wasm/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>type}{type_generics_where} {{
const LIST_KIND: &'static str = {list_kind};
}}<|fim_prefix|>// repo: Arnavion/k8s-openapi path: /k8s-openapi-codegen-common/templates/impl_listable_resource.rs
impl{type_generics_impl} {local}Listabl<|fim_middle|>eResource for {type_name}{type_generics_ | code_fim | easy | {
"lang": "rust",
"repo": "Arnavion/k8s-openapi",
"path": "/k8s-openapi-codegen-common/templates/impl_listable_resource.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Arnavion/k8s-openapi path: /k8s-openapi-codegen-common/templates/impl_listable_resource.rs
impl{type_generics_impl} {local}Listabl<|fim_suffix|>type}{type_generics_where} {{
const LIST_KIND: &'static str = {list_kind};
}}<|fim_middle|>eResource for {type_name}{type_generics_ | code_fim | easy | {
"lang": "rust",
"repo": "Arnavion/k8s-openapi",
"path": "/k8s-openapi-codegen-common/templates/impl_listable_resource.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn read_long(&self) -> i64 {
if let SqliteValue::I64(int) = self {
return *int;
}
panic!("Trying to read non-long value as long");
}
pub fn read_double(&self) -> f64 {
if let SqliteValue::Double(double) = self {
return *double;
... | code_fim | hard | {
"lang": "rust",
"repo": "lunatic-solutions/lunatic",
"path": "/crates/lunatic-sqlite-api/src/wire_format/sqlite_value/guest_api.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lunatic-solutions/lunatic path: /crates/lunatic-sqlite-api/src/wire_format/sqlite_value/guest_api.rs
use super::{SqliteRow, SqliteValue};
#[cfg(target_arch = "wasm32")]
impl SqliteRow {
pub fn get_column(&self, idx: i32) -> Option<&SqliteValue> {
self.0.get(idx as usize)
}
}
<|... | code_fim | hard | {
"lang": "rust",
"repo": "lunatic-solutions/lunatic",
"path": "/crates/lunatic-sqlite-api/src/wire_format/sqlite_value/guest_api.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: HectorIGH/Competitive-Programming path: /Leetcode Challenge/06_June_2020/Rust/Week 5/2_Word Search II.rs
//Given a 2D board and a list of words from the dictionary, find all words in the board.
//
//Each word must be constructed from letters of sequentially adjacent cell, where "adjacent" cells ... | code_fim | hard | {
"lang": "rust",
"repo": "HectorIGH/Competitive-Programming",
"path": "/Leetcode Challenge/06_June_2020/Rust/Week 5/2_Word Search II.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> board : &[Vec<char>],
i : usize,
j : usize,
trie : &Trie,
visited : &mut Vec<Vec<bool>>,
ans : &mut HashSet<String>) {
if visited[i][j] {
return;
}
visited[i][j] = true;
let c = board[i][j];
... | code_fim | hard | {
"lang": "rust",
"repo": "HectorIGH/Competitive-Programming",
"path": "/Leetcode Challenge/06_June_2020/Rust/Week 5/2_Word Search II.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: delbato/alox path: /server/src/api/page.rs
use crate::{
api::{
error::{
ApiResult,
ApiResultExt
}
}
};
use actix_web::{
web::{
Json,
Path
},
get,
post,
put,
delete
};
use serde::Deserialize;
<|fim_suffix|>#... | code_fim | hard | {
"lang": "rust",
"repo": "delbato/alox",
"path": "/server/src/api/page.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[get("/{page_key}")]
pub async fn get_action(page_key: Path<String>) -> ApiResult {
ApiResult::error(503, "Not implemented")
}
#[put("/{page_key}")]
pub async fn update_action(page_key: Path<String>) -> ApiResult {
ApiResult::error(503, "Not implemented")
}
#[delete("/{page_key}")]
pub async fn... | code_fim | medium | {
"lang": "rust",
"repo": "delbato/alox",
"path": "/server/src/api/page.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Deserialize)]
struct PageCreateBody {
pub ident: String,
pub title: String,
pub site_key: String
}
#[post("")]
pub async fn create_action(page_create_body: Json<PageCreateBody>) -> ApiResult {
ApiResult::error(503, "Not implemented")
}<|fim_prefix|>// repo: delbato/alox path: /s... | code_fim | hard | {
"lang": "rust",
"repo": "delbato/alox",
"path": "/server/src/api/page.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn embed_image(image_path: &str) -> String {
let mut buffer = Vec::new();
let file = File::open(&image_path);
match file {
Ok(mut f) => {
f.read_to_end(&mut buffer).unwrap();
image_encoder::to_base64(&buffer).unwrap_or(image_path.to_string())
}
... | code_fim | easy | {
"lang": "rust",
"repo": "Eonm/markdown-packager",
"path": "/src/image_embedder/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match file {
Ok(mut f) => {
f.read_to_end(&mut buffer).unwrap();
image_encoder::to_base64(&buffer).unwrap_or(image_path.to_string())
}
Err(_) => image_path.to_string(),
}
}<|fim_prefix|>// repo: Eonm/markdown-packager path: /src/image_embedder/mod.r... | code_fim | medium | {
"lang": "rust",
"repo": "Eonm/markdown-packager",
"path": "/src/image_embedder/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Eonm/markdown-packager path: /src/image_embedder/mod.rs
use std::fs::File;
use std::io;
use std::io::prelude::*;
<|fim_suffix|>pub fn embed_image(image_path: &str) -> String {
let mut buffer = Vec::new();
let file = File::open(&image_path);
match file {
Ok(mut f) => {
... | code_fim | easy | {
"lang": "rust",
"repo": "Eonm/markdown-packager",
"path": "/src/image_embedder/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tynr426/wechat-rs path: /src/messages/location.rs
use time;
use xmlutil;
use messages::MessageParser;
#[derive(Debug, Clone)]
pub struct LocationMessage {
pub source: String,
pub target: String,
pub time: i64,
pub create_time: time::Tm,
pub id: i64,
pub location_x: f64,... | code_fim | hard | {
"lang": "rust",
"repo": "tynr426/wechat-rs",
"path": "/src/messages/location.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!("fromUser", &msg.source);
assert_eq!("toUser", &msg.target);
assert_eq!(1234567890123456, msg.id);
assert_eq!(1348831860, msg.time);
assert_eq!(23, msg.location_x as usize);
assert_eq!(113, msg.location_y as usize);
assert_eq!(20, msg.scal... | code_fim | hard | {
"lang": "rust",
"repo": "tynr426/wechat-rs",
"path": "/src/messages/location.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> input! {
s: Chars,
};
let mut p = 0;
let mut c = 'g';
for i in s {
match (i, c) {
('g', 'g') => p += 0,
('g', 'p') => p += 1,
('p', 'g') => p -= 1,
('p', 'p') => p += 0,
_ => unreachable!(),
}
c... | code_fim | easy | {
"lang": "rust",
"repo": "bouzuya/rust-atcoder",
"path": "/cargo-atcoder/contests/arc062/src/bin/d.rs",
"mode": "spm",
"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.