text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: lazear/adventofcode2019 path: /grid/src/lib.rs
use std::collections::HashMap;
use std::convert::TryFrom;
use std::fmt::Display;
use std::ops::{Index, IndexMut};
/// A point on an XY plane where the top-left position has coordinate of (0,0)
#[derive(Copy, Clone, Default, PartialEq, PartialOrd, O... | code_fim | hard | {
"lang": "rust",
"repo": "lazear/adventofcode2019",
"path": "/grid/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Direction {
pub fn rotate(self, rotation: Rotation) -> Direction {
match rotation {
Rotation::Left => match self {
Direction::Up => Direction::Left,
Direction::Down => Direction::Right,
Direction::Left => Direction::Down,
... | code_fim | hard | {
"lang": "rust",
"repo": "lazear/adventofcode2019",
"path": "/grid/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Grid {
cols: self.cols,
rows: self.rows,
grid: self.grid.clone(),
}
}
}
impl Direction {
pub fn rotate(self, rotation: Rotation) -> Direction {
match rotation {
Rotation::Left => match self {
Direction::Up => ... | code_fim | hard | {
"lang": "rust",
"repo": "lazear/adventofcode2019",
"path": "/grid/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let line: String = iter.next().unwrap();
let mut numbers = line.split_whitespace().map(|x| x.parse::<i32>().unwrap());
// Skip n and m
let g = numbers.nth(3).unwrap();
let line: String = iter.next().unwrap();
let times: Vec<i32> = line
.split_whitespace()
.map(|x| ... | code_fim | medium | {
"lang": "rust",
"repo": "stsewd/programming-problems-rust",
"path": "/src/bin/wet_clothes.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stsewd/programming-problems-rust path: /src/bin/wet_clothes.rs
// https://www.hackerearth.com/practice/algorithms/searching/linear-search/practice-problems/algorithm/wet-clothes-625348cf/
<|fim_suffix|> let max_gap: i32 = times
.iter()
.zip(×[1..])
.fold(0, |acc,... | code_fim | medium | {
"lang": "rust",
"repo": "stsewd/programming-problems-rust",
"path": "/src/bin/wet_clothes.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
let stdin = io::stdin();
let mut iter = stdin.lock().lines().map(|x| x.unwrap());
let line: String = iter.next().unwrap();
let mut numbers = line.split_whitespace().map(|x| x.parse::<i32>().unwrap());
// Skip n and m
let g = numbers.nth(3).unwrap();
let line: Stri... | code_fim | hard | {
"lang": "rust",
"repo": "stsewd/programming-problems-rust",
"path": "/src/bin/wet_clothes.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: syedqutaiba/Q1_Assignment_2a path: /src/main.rs
use std::io;
fn main() {
question_1();
question_2();
question_3();
question_4();
question_5();
}
fn question_1() {
let x = String::from("PIAIC IoT");
let y = x;
println!("\n------------");
println!("Question # 1");
... | code_fim | hard | {
"lang": "rust",
"repo": "syedqutaiba/Q1_Assignment_2a",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("------------");
println!("Question # 4");
println!("------------\n");
println!("Enter text:");
io::stdin().read_line(&mut s1).expect("Enter a valid input");
let mut s1: String = s1.trim().parse().expect("Enter a valid string");
let (s2, len) = calculate_l... | code_fim | hard | {
"lang": "rust",
"repo": "syedqutaiba/Q1_Assignment_2a",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Gregory-Meyer/pchmod path: /src/main.rs
// Copyright (c) 2019 Gregory Meyer
//
// 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 restriction, including withou... | code_fim | hard | {
"lang": "rust",
"repo": "Gregory-Meyer/pchmod",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if other_ref && execute {
bits |= 0o0001;
}
return match operator.unwrap() {
Operator::Add => Ok(Mode::Add(bits)),
Operator::Remove => Ok(Mode::Remove(!bits & 0o7777)),
Operator::Set => {
let mut mask = 0;
... | code_fim | hard | {
"lang": "rust",
"repo": "Gregory-Meyer/pchmod",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nickray/lpc55-pac path: /src/hashcrypt/intenset.rs
#[doc = "Reader of register INTENSET"]
pub type R = crate::R<u32, super::INTENSET>;
#[doc = "Writer for register INTENSET"]
pub type W = crate::W<u32, super::INTENSET>;
#[doc = "Register INTENSET `reset()`'s with value 0"]
impl crate::ResetValue... | code_fim | hard | {
"lang": "rust",
"repo": "nickray/lpc55-pac",
"path": "/src/hashcrypt/intenset.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> variant as u8 != 0
}
}
#[doc = "Reader of field `ERROR`"]
pub type ERROR_R = crate::R<bool, ERROR_A>;
impl ERROR_R {
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> ERROR_A {
match self.bits {
false => ERROR_A::NOT_INTERRUPT,... | code_fim | hard | {
"lang": "rust",
"repo": "nickray/lpc55-pac",
"path": "/src/hashcrypt/intenset.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: HaoranYi/gitProj path: /rust_playpen/src/unsafe.rs
fn main() {
let mut a = 3;
// create raw pointer in safe code.
// The following code is not valid when using reference, two ref<|fim_suffix|> // convert raw pointer to an Option<&T>, which can then be used in safe code
let c =... | code_fim | hard | {
"lang": "rust",
"repo": "HaoranYi/gitProj",
"path": "/rust_playpen/src/unsafe.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // convert raw pointer to an Option<&T>, which can then be used in safe code
let c = unsafe {b.as_ref()};
println!("{:?}", c);
}<|fim_prefix|>// repo: HaoranYi/gitProj path: /rust_playpen/src/unsafe.rs
fn main() {
let mut a = 3;
// create raw pointer in safe code.
// The following... | code_fim | medium | {
"lang": "rust",
"repo": "HaoranYi/gitProj",
"path": "/rust_playpen/src/unsafe.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("{}", arr[2]);
println!("{}", bb);
}
fn bbQQ() -> i32 { // warning help: convert the identifier to snake case: `bb_qq`
303
}<|fim_prefix|>// repo: hisland/my-learn path: /rust-programming-2/00-common-programming-concepts/20-fn-name-snake-case.rs
fn main() {
let arr = [1, 2, 3];
... | code_fim | easy | {
"lang": "rust",
"repo": "hisland/my-learn",
"path": "/rust-programming-2/00-common-programming-concepts/20-fn-name-snake-case.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hisland/my-learn path: /rust-programming-2/00-common-programming-concepts/20-fn-name-snake-case.rs
fn main() {
let arr = [1, 2, 3];
let bb = bbQQ();
<|fim_suffix|>fn bbQQ() -> i32 { // warning help: convert the identifier to snake case: `bb_qq`
303
}<|fim_middle|> println!("{}",... | code_fim | easy | {
"lang": "rust",
"repo": "hisland/my-learn",
"path": "/rust-programming-2/00-common-programming-concepts/20-fn-name-snake-case.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iCodeIN/naia path: /shared/src/actors/state_mask.rs
use byteorder::WriteBytesExt;
use std::fmt;
use crate::PacketReader;
/// The State Mask is a variable-length byte array, where each bit represents
/// the current state of a Property owned by an Actor. The Property state
/// tracked is whethe... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/naia",
"path": "/shared/src/actors/state_mask.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn get_byte() {
let mut mask = StateMask::new(2);
mask.set_bit(10, true);
let byte = mask.get_byte(1);
assert!(byte == 4);
}
#[test]
fn nand() {
let mut mask_a = StateMask::new(2);
mask_a.set_bit(1, true);
mask_a.set_bit(... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/naia",
"path": "/shared/src/actors/state_mask.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn vel(&self) -> &Vec3 {
&self.vel
}
}<|fim_prefix|>// repo: NikVolf/ssph path: /world/src/loc.rs
use Vec3;
pub struct Loc3 {
pos: Vec3,
vel: Vec3,
}
impl Loc3 {
pub fn new(position: Vec3) -> Self {
Loc3 { pos: position, vel: Vec3::zero() }
}
<|fim_middle|> ... | code_fim | medium | {
"lang": "rust",
"repo": "NikVolf/ssph",
"path": "/world/src/loc.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: NikVolf/ssph path: /world/src/loc.rs
use Vec3;
pub struct Loc3 {
pos: Vec3,
vel: Vec3,
}
<|fim_suffix|> pub fn with_velocity(position: Vec3, velocity: Vec3) -> Self {
Loc3 { pos: position, vel: velocity }
}
pub fn pos(&self) -> &Vec3 {
&self.pos
}
p... | code_fim | medium | {
"lang": "rust",
"repo": "NikVolf/ssph",
"path": "/world/src/loc.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ChrisMacNaughton/ceph_safe_disk path: /lib/diag.rs
extern crate ansi_term;
use ansi_term::Colour;
use error::CSDError;
use osdmap::OsdMap;
use pgstate::*;
use pgmap::*;
use from::*;
use std::collections::BTreeMap;
use std::collections::BinaryHeap;
use std::fmt;
// The removability status of ... | code_fim | hard | {
"lang": "rust",
"repo": "ChrisMacNaughton/ceph_safe_disk",
"path": "/lib/diag.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(status, Status::Safe);
}
#[test]
fn exhaustive_diag_jewel_non_safe() {
let status: Status = DiagMap {
pg_map: PGMap::from_file("test/jewel/pg_dump_non_safe.json").unwrap(),
osd_map: OsdMap::from_file("test/jewel/osd_dump_non_safe.json").unwra... | code_fim | hard | {
"lang": "rust",
"repo": "ChrisMacNaughton/ceph_safe_disk",
"path": "/lib/diag.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn read_byte_iter(
alloc: &mut Allocator<'arena>,
data: &mut slice::Iter<u8>,
) -> Result<Self, Self::Error> {
let mut ex_type: u16 = 0;
ex_type += u16::from(*data.next().ok_or_else(Error::truncated)?);
ex_type <<= 8;
ex_type += u16::from(*data.next(... | code_fim | hard | {
"lang": "rust",
"repo": "infinityb/yscloud",
"path": "/parsing/tls/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: infinityb/yscloud path: /parsing/tls/src/lib.rs
256_CBC_SHA => CipherSuite::TLS_DHE_RSA_WITH_AES_256_CBC_SHA,
TLS_RSA_WITH_AES_128_CBC_SHA => CipherSuite::TLS_RSA_WITH_AES_128_CBC_SHA,
TLS_RSA_WITH_AES_256_CBC_SHA => CipherSuite::TLS_RSA_WITH_AES_256_CBC_SHA,
... | code_fim | hard | {
"lang": "rust",
"repo": "infinityb/yscloud",
"path": "/parsing/tls/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>const TLS_EXTENSION_SUPPORTED_GROUPS_ID: u16 = 0x000a;
const TLS_EXTENSION_SUPPORTED_GROUPS: ExtensionDef = ExtensionDef {
id: TLS_EXTENSION_SUPPORTED_GROUPS_ID,
name: "supported_groups",
};
const TLS_EXTENSION_EC_POINT_FORMATS_ID: u16 = 0x000b;
const TLS_EXTENSION_EC_POINT_FORMATS: ExtensionDef ... | code_fim | hard | {
"lang": "rust",
"repo": "infinityb/yscloud",
"path": "/parsing/tls/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>Writ { strongs: [ 1448, 0, 0, 0, ], b: 42, c: 18, v: 40, wc: 6, word: 0x014C, punc: 0x00, trans: 0x00, pnwc: 0x0100, pos: 0x000B0893, lemma: 0x000B },
AVXWrit { strongs: [ 1448, 0, 0, 0, ], b: 42, c: 18, v: 40, wc: 5, word: 0x0222, punc: 0x00, trans: 0x00, pnwc: 0x0100, pos: 0x00005ACE, le... | code_fim | hard | {
"lang": "rust",
"repo": "kwonus/Digital-AV",
"path": "/omega/foundations/rust/src/avx/written/written_42.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kwonus/Digital-AV path: /omega/foundations/rust/src/avx/written/written_42.rs
punc: 0x00, trans: 0x00, pnwc: 0x0C00, pos: 0x00000063, lemma: 0x0038 },
AVXWrit { strongs: [ 406, 0, 0, 0, ], b: 42, c: 6, v: 14, wc: 9, word: 0x8CB2, punc: 0x00, trans: 0x00, pnwc: 0x4032, pos: 0x00003A1C,... | code_fim | hard | {
"lang": "rust",
"repo": "kwonus/Digital-AV",
"path": "/omega/foundations/rust/src/avx/written/written_42.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> 17, wc: 12, word: 0x03BF, punc: 0x00, trans: 0x00, pnwc: 0x0100, pos: 0x00005AC4, lemma: 0x03C2 },
AVXWrit { strongs: [ 1232, 0, 0, 0, ], b: 42, c: 2, v: 17, wc: 11, word: 0x0919, punc: 0x00, trans: 0x00, pnwc: 0x0100, pos: 0x00005ACE, lemma: 0x0376 },
AVXWrit { strongs: [ 4012, 0, 0, 0,... | code_fim | hard | {
"lang": "rust",
"repo": "kwonus/Digital-AV",
"path": "/omega/foundations/rust/src/avx/written/written_42.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn getpid(&self) -> Pid;
fn getppid(&self) -> Pid;
fn getpgid(&self) -> Pid;
fn exited(&self) -> Option<i32>;
/// take ownership of `self`
fn run(self) -> Result<RunTask<Self>>
where
Self: Sized;
}<|fim_prefix|>// repo: loganwendholt/reverie path: /src/task.rs
//! task... | code_fim | hard | {
"lang": "rust",
"repo": "loganwendholt/reverie",
"path": "/src/task.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn exited(&self) -> Option<i32>;
/// take ownership of `self`
fn run(self) -> Result<RunTask<Self>>
where
Self: Sized;
}<|fim_prefix|>// repo: loganwendholt/reverie path: /src/task.rs
//! task structure and traits
use libc;
use nix::sys::wait::WaitStatus;
use nix::sys::{ptrace, si... | code_fim | hard | {
"lang": "rust",
"repo": "loganwendholt/reverie",
"path": "/src/task.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: loganwendholt/reverie path: /src/task.rs
//! task structure and traits
use libc;
use nix::sys::wait::WaitStatus;
use nix::sys::{ptrace, signal, uio, wait};
use nix::unistd;
use nix::unistd::Pid;
use std::io::{Error, ErrorKind, Result};
use std::path::PathBuf;
use std::ptr::NonNull;
use crate::c... | code_fim | hard | {
"lang": "rust",
"repo": "loganwendholt/reverie",
"path": "/src/task.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> MINT_R::new(((self.bits >> 12) & 0x07) as u8) }
#[doc = "Bits 16:19 - Hours, Units"]
#[inline(always)]
pub fn houru(&self) -> HOURU_R { HOURU_R::new(((self.bits >> 16) & 0x0f) as u8) }
#[doc = "Bits 20:21 - Hours, Tens"]
#[inline(always)]
pub fn hourt(&self) -> HOURT_R { HOURT_R::... | code_fim | hard | {
"lang": "rust",
"repo": "pablo-mansanet-bluefruit/efm32gg11b",
"path": "/src/rtcc/time.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pablo-mansanet-bluefruit/efm32gg11b path: /src/rtcc/time.rs
#[doc = "Reader of register TIME"]
pub type R = crate::R<u32, super::TIME>;
#[doc = "Writer for register TIME"]
pub type W = crate::W<u32, super::TIME>;
#[doc = "Register TIME `reset()`'s with value 0"]
impl crate::ResetValue for super:... | code_fim | hard | {
"lang": "rust",
"repo": "pablo-mansanet-bluefruit/efm32gg11b",
"path": "/src/rtcc/time.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fe fn bits(self, value: u8) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x0f << 16)) | (((value as u32) & 0x0f) << 16);
self.w
}
}
#[doc = "Reader of field `HOURT`"]
pub type HOURT_R = crate::R<u8, u8>;
#[doc = "Write proxy for field `HOURT`"]
pub struct HOURT_W<'a> {
w: &'a mut ... | code_fim | hard | {
"lang": "rust",
"repo": "pablo-mansanet-bluefruit/efm32gg11b",
"path": "/src/rtcc/time.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: linuxhenhao/leetcode path: /longest_palindromic_substring_5/src/main.rs
struct Solution;
impl Solution {
pub fn longest_palindrome(s: String) -> String {
let bs = s.as_bytes();
if bs.len() == 0 {
return "".to_string();
}
if bs.len() == 1 {
... | code_fim | hard | {
"lang": "rust",
"repo": "linuxhenhao/leetcode",
"path": "/longest_palindromic_substring_5/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // check and add new palindromic
if bs[i] == bs[i-1] {
if max_len <= 2 {
max_len = 2;
max_start = i-1;
}
ref_substrings[substr_size] = i-1;
substr_size += 1;
}
... | code_fim | hard | {
"lang": "rust",
"repo": "linuxhenhao/leetcode",
"path": "/longest_palindromic_substring_5/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mbround18/ark-manager-web path: /server/src/managed/logs.rs
use linemux::MuxedLines;
use rocket::http::Status;
use std::env;
use std::fs::read;
use std::path::Path;
const DEFAULT_LOG: &str = "/tmp/ark-manager-web/out.log";
#[derive(serde::Serialize)]
pub struct ManagedLogs {
log_files: Box... | code_fim | hard | {
"lang": "rust",
"repo": "mbround18/ark-manager-web",
"path": "/server/src/managed/logs.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut logs = vec![String::from(DEFAULT_LOG)];
add_shooter_game_log(&mut logs);
ManagedLogs {
log_files: Box::from(logs),
}
}
}
impl ManagedLogs {
pub fn new() -> ManagedLogs {
match env::var("MANAGED_LOG_FILES") {
Ok(files) => {
... | code_fim | hard | {
"lang": "rust",
"repo": "mbround18/ark-manager-web",
"path": "/server/src/managed/logs.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl ManagedLogs {
pub fn new() -> ManagedLogs {
match env::var("MANAGED_LOG_FILES") {
Ok(files) => {
let log_files: Box<[String]> = files
.split(',')
.map(String::from)
.collect::<Vec<String>>()
... | code_fim | hard | {
"lang": "rust",
"repo": "mbround18/ark-manager-web",
"path": "/server/src/managed/logs.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let mut this = self.project();
loop {
let next = futures_core::ready!(this.stream.as_mut().poll_next(cx));
match next {
Some((a, b)) => {
let res = ... | code_fim | hard | {
"lang": "rust",
"repo": "async-rs/async-std",
"path": "/src/stream/stream/unzip.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: async-rs/async-std path: /src/stream/stream/unzip.rs
use core::future::Future;
use core::pin::Pin;
use pin_project_lite::pin_project;
use crate::stream::Stream;
use crate::task::{Context, Poll};
pin_project! {
#[derive(Clone, Debug)]
#[cfg(feature = "unstable")]
#[cfg_attr(feature... | code_fim | hard | {
"lang": "rust",
"repo": "async-rs/async-std",
"path": "/src/stream/stream/unzip.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut this = self.project();
loop {
let next = futures_core::ready!(this.stream.as_mut().poll_next(cx));
match next {
Some((a, b)) => {
let res = this.res.as_mut().unwrap();
res.0.extend(Some(a));
... | code_fim | medium | {
"lang": "rust",
"repo": "async-rs/async-std",
"path": "/src/stream/stream/unzip.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Clone for Node {
fn clone(&self) -> Node {
Node {
name : self.name().to_string(),
node_type: self.node_type().clone(),
input_list : self.input_list.clone(),
initial_value : self.initial_value,
delta : self.delta,
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "Hyuntae-Lee/nn_tester",
"path": "/src/node.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Hyuntae-Lee/nn_tester path: /src/node.rs
use std::fmt;
#[derive(Clone)]
pub enum NodeType {
Input_1,
Input_2,
Hidden,
Output,
Bias,
}
pub struct Node {
name : String,
node_type : NodeType,
input_list : Vec<f64>,
initial_value : f64,
delta : f64
}
<|fim_... | code_fim | hard | {
"lang": "rust",
"repo": "Hyuntae-Lee/nn_tester",
"path": "/src/node.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Node {
name : self.name().to_string(),
node_type: self.node_type().clone(),
input_list : self.input_list.clone(),
initial_value : self.initial_value,
delta : self.delta,
}
}
}
impl fmt::Display for Node {
fn fmt(&self, f:... | code_fim | medium | {
"lang": "rust",
"repo": "Hyuntae-Lee/nn_tester",
"path": "/src/node.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JohnBSmith/moss path: /src/modules/sdl.rs
#![allow(non_camel_case_types)]
#![allow(dead_code)]
use std::os::raw::{c_int, c_uint, c_char, c_void};
pub type Uint8 = u8;
pub type Uint32 = u32;
pub type Sint32 = i32;
pub type Uint16 = i16;
pub type SDL_Keycode = Sint32;
#[repr(u32)]
#[derive(Cop... | code_fim | hard | {
"lang": "rust",
"repo": "JohnBSmith/moss",
"path": "/src/modules/sdl.rs",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[repr(C)]
#[derive(Clone,Copy)]
pub struct SDL_KeyboardEvent {
pub ty: Uint32,
pub timestamp: Uint32,
pub window_id: Uint32,
pub state: Uint8,
pub repeat: Uint8,
pub padding2: Uint8,
pub padding3: Uint8,
pub keysym: SDL_Keysym
}
#[repr(C)]
pub union SDL_Event {
pub ev... | code_fim | hard | {
"lang": "rust",
"repo": "JohnBSmith/moss",
"path": "/src/modules/sdl.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[repr(C)]
pub struct SDL_Renderer {
_mem: [u8; 0]
}
#[repr(C)]
pub struct SDL_Texture {
_mem: [u8; 0]
}
#[repr(C)]
pub struct SDL_Rect {
pub x: c_int, pub y: c_int,
pub w: c_int, pub h: c_int
}
#[link(name = "SDL2")]
extern "C" {
// SDL_video.h
pub fn SDL_CreateWindow(
... | code_fim | hard | {
"lang": "rust",
"repo": "JohnBSmith/moss",
"path": "/src/modules/sdl.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vinc/moros path: /src/usr/keyboard.rs
use crate::sys;
use crate::api::console::Style;
use crate::api::process::ExitCode;
pub fn main(args: &[&str]) -> Result<(), ExitCode> {
if args.len() == 1 {
help();
return Err(ExitCode::UsageError);
}
match args[1] {
"set... | code_fim | hard | {
"lang": "rust",
"repo": "vinc/moros",
"path": "/src/usr/keyboard.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Match {
pub fn new(start: usize, end: usize, dist: u16, subst: u16, ins: u16, del: u16) -> Match {
Match {
start: start,
end: end,
dist: dist,
subst: subst,
ins: ins,
del: del,
}
}
pub fn neg_start1(&... | code_fim | hard | {
"lang": "rust",
"repo": "markschl/seqtool",
"path": "/src/cmd/find/matcher/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: markschl/seqtool path: /src/cmd/find/matcher/mod.rs
use std::fmt::Debug;
mod approx;
mod exact;
mod regex;
pub use self::approx::*;
pub use self::exact::*;
pub use self::regex::*;
pub trait Matcher {
fn iter_matches(&mut self, text: &[u8], func: &mut FnMut(&Hit) -> bool);
}
<|fim_suffix|... | code_fim | medium | {
"lang": "rust",
"repo": "markschl/seqtool",
"path": "/src/cmd/find/matcher/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let valid_pwds = part1();
println!("Result: {}", valid_pwds);
}
#[test]
fn compute_part2() {
let valid_pwds = part2();
println!("Result: {}", valid_pwds);
}
#[test]
fn test_regex() {
let regex = Regex::new(r"^[0-9]*-[0-9]* [a-z]: [a-z]*$").... | code_fim | hard | {
"lang": "rust",
"repo": "juniorbassani/advent-of-code-2020",
"path": "/src/day02.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: juniorbassani/advent-of-code-2020 path: /src/day02.rs
use regex::Regex;
use std::io::BufRead;
use std::str::FromStr;
const INPUT_PATH: &str = "input/day02";
lazy_static! {
// valid regex example: 14-19 x: lrxxxtxxxxxxxzxxxxx
static ref RE: Regex = Regex::new(
r"(?x)
^(?... | code_fim | hard | {
"lang": "rust",
"repo": "juniorbassani/advent-of-code-2020",
"path": "/src/day02.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: steveklabnik/semver-parser path: /src/main.rs
use semver_parser::Compat;
use semver_parser::RangeSet;
use std::error::Error;
fn main() -> Result<(), Box<dyn Error>> {
<|fim_suffix|> // npm compatibility
let range_set = RangeSet::parse("1.2.3", Compat::Npm)?;
println!("Found range set... | code_fim | medium | {
"lang": "rust",
"repo": "steveklabnik/semver-parser",
"path": "/src/main.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // default operation
let range_set: RangeSet = "1.2.3".parse()?;
println!("Found range set: {:?}", range_set);
// npm compatibility
let range_set = RangeSet::parse("1.2.3", Compat::Npm)?;
println!("Found range set (node): {:?}", range_set);
Ok(())
}<|fim_prefix|>// repo: stev... | code_fim | easy | {
"lang": "rust",
"repo": "steveklabnik/semver-parser",
"path": "/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn poll_ready(&mut self) -> Poll<(), Self::Error> {
self.0.poll_ready()
}
fn call(&mut self, req: Request<B1>) -> Self::Future {
self.0.call(req).or_else(|err| {
if let Some(err) = err.downcast_ref::<error::Timedout>() {
debug!("request timed out af... | code_fim | hard | {
"lang": "rust",
"repo": "11Takanori/linkerd2-proxy",
"path": "/linkerd/proxy/http/src/timeout.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub struct MakeFuture<F> {
inner: F,
timeout: Option<Duration>,
}
#[derive(Clone, Debug)]
pub struct Service<S>(Timeout<S>);
/// A marker set in `http::Response::extensions` that *this* process triggered
/// the request timeout.
#[derive(Debug)]
pub struct ProxyTimedOut(());
impl<M> tower::laye... | code_fim | hard | {
"lang": "rust",
"repo": "11Takanori/linkerd2-proxy",
"path": "/linkerd/proxy/http/src/timeout.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 11Takanori/linkerd2-proxy path: /linkerd/proxy/http/src/timeout.rs
use futures::{future, try_ready, Future, Poll};
use http::{Request, Response, StatusCode};
use linkerd2_error::Error;
use linkerd2_timeout::{error, Timeout};
use std::time::Duration;
use tracing::{debug, error};
/// Implement on... | code_fim | hard | {
"lang": "rust",
"repo": "11Takanori/linkerd2-proxy",
"path": "/linkerd/proxy/http/src/timeout.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn typecheck_expr(scope: &mut Typescope, ix: &mut Ixpr) -> TypeResult
{
match &mut ix.src {
&mut Source::Call(ref mut func, ref mut args) => {
let tfunc = scope.typecheck_call_func(&func.src).map_err(|e| {
e.add_context(Lstr::from(format!("function: {:?}", func.... | code_fim | hard | {
"lang": "rust",
"repo": "itscomputers/leema",
"path": "/src/leema/typecheck.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: itscomputers/leema path: /src/leema/typecheck.rs
self.collect_calls(body);
}
Source::Cons(ref head, ref tail) => {
self.collect_calls(head);
self.collect_calls(tail);
}
Source::FieldAccess(ref base, _, _) ... | code_fim | hard | {
"lang": "rust",
"repo": "itscomputers/leema",
"path": "/src/leema/typecheck.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn functype(&self, modname: &str, funcname: &str) -> Type
{
if modname == self.inter.name() {
self.inter
.get_function_type(funcname)
.expect("missing typed object for module")
.clone()
} else {
let m = sel... | code_fim | hard | {
"lang": "rust",
"repo": "itscomputers/leema",
"path": "/src/leema/typecheck.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sebashack/rust_algorithms path: /src/algorithms/mod.rs
pub mod array_stack;
pub mod binary_search_tree;
pub mod connectivity_quick_find;
pub mod <|fim_suffix|>;
pub mod linked_list_queue;
pub mod linked_list_stack;
pub mod llrb_tree;
pub mod priority_queue;
pub mod separate_chainining_hash_table... | code_fim | medium | {
"lang": "rust",
"repo": "sebashack/rust_algorithms",
"path": "/src/algorithms/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>;
pub mod linked_list_queue;
pub mod linked_list_stack;
pub mod llrb_tree;
pub mod priority_queue;
pub mod separate_chainining_hash_table;
pub mod sorting;
pub mod undirected_graph;<|fim_prefix|>// repo: sebashack/rust_algorithms path: /src/algorithms/mod.rs
pub mod array_stack;
pub mod binary_search_tre... | code_fim | medium | {
"lang": "rust",
"repo": "sebashack/rust_algorithms",
"path": "/src/algorithms/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: prz23/zinc path: /zargo/src/network.rs
//!
//! The Zargo network type wrapper.
//!
use std::fmt;
///
/// The zkSync SDK network wrapper.
///
#[derive(Debug, Clone, Copy)]
pub struct Network {
/// The zkSync type.
inner: zksync::Network,
}
impl Network {
///
/// Returns the add... | code_fim | medium | {
"lang": "rust",
"repo": "prz23/zinc",
"path": "/zargo/src/network.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl From<zksync::Network> for Network {
fn from(inner: zksync::Network) -> Self {
Self { inner }
}
}
impl Into<zksync::Network> for Network {
fn into(self) -> zksync::Network {
self.inner
}
}
impl fmt::Display for Network {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -... | code_fim | hard | {
"lang": "rust",
"repo": "prz23/zinc",
"path": "/zargo/src/network.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Self { inner }
}
}
impl Into<zksync::Network> for Network {
fn into(self) -> zksync::Network {
self.inner
}
}
impl fmt::Display for Network {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.inner)
}
}<|fim_prefix|>// repo: prz23... | code_fim | hard | {
"lang": "rust",
"repo": "prz23/zinc",
"path": "/zargo/src/network.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn short() {
assert_eq!(least_significant_digits(11, 5), "11");
}
#[test]
fn exact() {
assert_eq!(
least_significant_digits(1234567890_0987654321, 20),
"12345678900987654321"
);
}
}<|fim_prefix|>// repo: AndreasChristianson/p... | code_fim | medium | {
"lang": "rust",
"repo": "AndreasChristianson/project-euler-rust",
"path": "/src/base_ten/truncated.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AndreasChristianson/project-euler-rust path: /src/base_ten/truncated.rs
use circular_queue::CircularQueue;
pub fn least_significant_digits(number: u128, count: usize) -> String {
let mut queue = CircularQueue::with_capacity(count);
let as_string = number.to_string();
let sequence = ... | code_fim | medium | {
"lang": "rust",
"repo": "AndreasChristianson/project-euler-rust",
"path": "/src/base_ten/truncated.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> amount: vec![amount],
};
store.insert(victim, dmg).expect("Unable to insert damage");
}
}
}<|fim_prefix|>// repo: voidpumpkin/rusty-rougelike path: /src/components/suffer_damage.rs
use specs::{Component, DenseVecStorage, Entity, WriteStorage};
#[derive(Comp... | code_fim | medium | {
"lang": "rust",
"repo": "voidpumpkin/rusty-rougelike",
"path": "/src/components/suffer_damage.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: voidpumpkin/rusty-rougelike path: /src/components/suffer_damage.rs
use specs::{Component, DenseVecStorage, Entity, WriteStorage};
#[derive(Component, Debug)]
pub struct SufferDamage {
pub amount: Vec<i32>,
}
impl SufferDamage {
pub fn new_damage(store: &mut WriteStorage<SufferDamage>, v... | code_fim | medium | {
"lang": "rust",
"repo": "voidpumpkin/rusty-rougelike",
"path": "/src/components/suffer_damage.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut removed_tx_keys: Vec<Signature> = Vec::new();
for (tx_key, ptx) in self.txs_by_signature.iter() {
for input in ptx.transaction.body.inputs() {
if published_block.body.inputs().contains(input) {
self.txs_by_fee_priority.remove(&ptx.fee... | code_fim | hard | {
"lang": "rust",
"repo": "fluffypony/tari",
"path": "/base_layer/core/src/mempool/pending_pool/pending_pool_storage.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fluffypony/tari path: /base_layer/core/src/mempool/pending_pool/pending_pool_storage.rs
// Copyright 2019 The Tari Project
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
// following conditions are met:
//
// 1. Redistri... | code_fim | hard | {
"lang": "rust",
"repo": "fluffypony/tari",
"path": "/base_layer/core/src/mempool/pending_pool/pending_pool_storage.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn is_automorphic(n: i128) -> bool {
let n_str = n.to_string();
let sq_str = n.pow(2).to_string();
n_str == sq_str[(sq_str.len() - n_str.len())..]
}
fn main() {
list_automorphic_numbers(1, 10000)
}
#[test]
fn simple_test() {
assert!(is_automorphic(5));
assert!(is_automorphic(6));... | code_fim | medium | {
"lang": "rust",
"repo": "ZoranPandovski/al-go-rithms",
"path": "/math/automorphic_numbers/Rust/automorphic_number.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn simple_test() {
assert!(is_automorphic(5));
assert!(is_automorphic(6));
assert!(is_automorphic(76));
assert!(is_automorphic(376));
assert!(is_automorphic(890625));
}<|fim_prefix|>// repo: ZoranPandovski/al-go-rithms path: /math/automorphic_numbers/Rust/automorphic_number.rs... | code_fim | medium | {
"lang": "rust",
"repo": "ZoranPandovski/al-go-rithms",
"path": "/math/automorphic_numbers/Rust/automorphic_number.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ZoranPandovski/al-go-rithms path: /math/automorphic_numbers/Rust/automorphic_number.rs
// In mathematics an automorphic number (sometimes referred to as a circular number)
// is a number whose square "ends" in the same digits as the number itself.
fn list_automorphic_numbers(start: i32, end: i3... | code_fim | hard | {
"lang": "rust",
"repo": "ZoranPandovski/al-go-rithms",
"path": "/math/automorphic_numbers/Rust/automorphic_number.rs",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: robinp7720/RustNotetakingApp path: /src/test_application/imp.rs
use gtk::glib;
use gtk::prelude::*;
use gtk::subclass::prelude::*;
use super::main_window;
#[derive(Debug, Default)]
pub struct TestApplication {}
#[glib::object_subclass]
impl ObjectSubclass for TestApplication {
const NAME:... | code_fim | medium | {
"lang": "rust",
"repo": "robinp7720/RustNotetakingApp",
"path": "/src/test_application/imp.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[glib::object_subclass]
impl ObjectSubclass for TestApplication {
const NAME: &'static str = "TestApplication";
type Type = super::TestApplication;
type ParentType = gtk::Application;
}
impl ObjectImpl for TestApplication {}
impl ApplicationImpl for TestApplication {
fn activate(&self, ... | code_fim | medium | {
"lang": "rust",
"repo": "robinp7720/RustNotetakingApp",
"path": "/src/test_application/imp.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MacklinEngineering/reactr path: /rwasm/testdata/rust-get/src/lib.rs
use suborbital::runnable::*;
use suborbital::cache;
struct RustGet{}
<|fim_suffix|>
// initialize the runner, do not edit below //
static RUNNABLE: &RustGet = &RustGet{};
#[no_mangle]
pub extern fn init() {
use_runnable(R... | code_fim | medium | {
"lang": "rust",
"repo": "MacklinEngineering/reactr",
"path": "/rwasm/testdata/rust-get/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[no_mangle]
pub extern fn init() {
use_runnable(RUNNABLE);
}<|fim_prefix|>// repo: MacklinEngineering/reactr path: /rwasm/testdata/rust-get/src/lib.rs
use suborbital::runnable::*;
use suborbital::cache;
struct RustGet{}
impl Runnable for RustGet {
fn run(&self, _: Vec<u8>) -> Result<Vec<u8>, R... | code_fim | medium | {
"lang": "rust",
"repo": "MacklinEngineering/reactr",
"path": "/rwasm/testdata/rust-get/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pickfire/ve path: /src/raw_vec.rs
way inspect the memory that it manages. When dropped it *will* free
/// its memory, but it *won't* try to drop its contents. It is up to the user of `RawVec` to handle
/// the actual things *stored* inside of a `RawVec`.
///
/// Note that the excess of a zero-si... | code_fim | hard | {
"lang": "rust",
"repo": "pickfire/ve",
"path": "/src/raw_vec.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Shrinks the allocation down to the specified amount. If the given amount is 0, actually
/// completely deallocates.
///
/// # Panics
///
/// Panics if the given amount is *larger* than the current capacity.
///
/// # Aborts
///
/// Aborts on OOM.
pub(crate) ... | code_fim | hard | {
"lang": "rust",
"repo": "pickfire/ve",
"path": "/src/raw_vec.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pickfire/ve path: /src/raw_vec.rs
/ * Guards against overflowing your length.
/// * Calls `handle_alloc_error` for fallible allocations.
/// * Contains a `ptr::Unique` and thus endows the user with all related benefits.
/// * Uses the excess returned from the allocator to use the largest availab... | code_fim | hard | {
"lang": "rust",
"repo": "pickfire/ve",
"path": "/src/raw_vec.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn compressed_bytes_total(direction: Direction) -> IntCounter {
metrics::counter(
super::Compress::NAME,
"compressed_bytes_total",
"Total number of compressed bytes either received or sent.",
direction,
)
}
fn decompressed_bytes_total(direction: Direction) -> IntCo... | code_fim | hard | {
"lang": "rust",
"repo": "googleforgames/quilkin",
"path": "/src/filters/compress/metrics.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: googleforgames/quilkin path: /src/filters/compress/metrics.rs
/*
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://ww... | code_fim | hard | {
"lang": "rust",
"repo": "googleforgames/quilkin",
"path": "/src/filters/compress/metrics.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn same_backward_diagonal_as(&self, position: &ChessPosition) -> bool {
let rank_diff = self.rank - position.rank;
let file_diff = self.file - position.file;
rank_diff == -file_diff
}
const MIN_RANK: i32 = 0;
const MAX_RANK: i32 = 7;
fn rank_in_range(rank:... | code_fim | hard | {
"lang": "rust",
"repo": "HarrisonMc555/exercism",
"path": "/rust/queen-attack/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: HarrisonMc555/exercism path: /rust/queen-attack/src/lib.rs
#[derive(Debug)]
pub struct ChessPosition {
rank: i32,
file: i32,
}
#[derive(Debug)]
pub struct Queen(ChessPosition);
impl ChessPosition {
#![allow(clippy::new_ret_no_self)]
pub fn new(rank: i32, file: i32) -> Option<Se... | code_fim | medium | {
"lang": "rust",
"repo": "HarrisonMc555/exercism",
"path": "/rust/queen-attack/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let src = &mut n.src;
let new = self
.resolver
.resolve_import(&self.base, &src.value)
.with_context(|| format!("failed to resolve import `{}`", src.value))
.unwrap();
src.raw = None;
src.value = new;
}
}<|fim_prefix|>//... | code_fim | hard | {
"lang": "rust",
"repo": "swc-project/swc",
"path": "/crates/swc_ecma_transforms_module/src/rewriter.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: swc-project/swc path: /crates/swc_ecma_transforms_module/src/rewriter.rs
use anyhow::Context;
use swc_common::FileName;
use swc_ecma_ast::*;
use swc_ecma_visit::{as_folder, noop_visit_mut_type, Fold, VisitMut, VisitMutWith};
use crate::path::ImportResolver;
/// Import rewriter, which rewrites ... | code_fim | hard | {
"lang": "rust",
"repo": "swc-project/swc",
"path": "/crates/swc_ecma_transforms_module/src/rewriter.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Term {
const CELL_SIZE: usize = 20;
const MARGIN: usize = 5;
fn new(width: usize, height: usize) -> Self {
preapre_term();
Self {
cells: vec![vec![]],
cursor: (0, 0),
width: width / (Self::CELL_SIZE + Self::MARGIN),
height: ... | code_fim | hard | {
"lang": "rust",
"repo": "sigmaSd/picowave",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sigmaSd/picowave path: /src/main.rs
fn main() {
let (width, height) = get_dim();
let mut term = Term::new(width, height);
let mut search_bar = Search::new();
let mut state = State::Search;
loop {
goto_start();
clear();
term.draw(matches!(state, State:... | code_fim | hard | {
"lang": "rust",
"repo": "sigmaSd/picowave",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn dalek_scalar_inv(bench: &mut Bencher, _i: &()) {
let a = Scalar::from_bytes_mod_order([
0x4e, 0x5a, 0xb4, 0x34, 0x5d, 0x47, 0x08, 0x84, 0x59, 0x13, 0xb4, 0x64, 0x1b, 0xc2, 0x7d,
0x52, 0x52, 0xa5, 0x85, 0x10, 0x1b, 0xcc, 0x42, 0x44, 0xd4, 0x49, 0xf4, 0xa8, 0x79, 0xd9,
0xf... | code_fim | hard | {
"lang": "rust",
"repo": "louiszhuang/OpenZKP",
"path": "/algebra/primefield/benchmarks/benches/dalek.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: louiszhuang/OpenZKP path: /algebra/primefield/benchmarks/benches/dalek.rs
// Criterion requires the second argument to be by reference
#![allow(clippy::trivially_copy_pass_by_ref)]
use criterion::{black_box, Bencher};
use curve25519_dalek::{
field::FieldElement,
scalar::{Scalar, Unpacke... | code_fim | hard | {
"lang": "rust",
"repo": "louiszhuang/OpenZKP",
"path": "/algebra/primefield/benchmarks/benches/dalek.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn dalek_scalar_sqr(bench: &mut Bencher, _i: &()) {
let a = Scalar::from_bytes_mod_order([
0x4e, 0x5a, 0xb4, 0x34, 0x5d, 0x47, 0x08, 0x84, 0x59, 0x13, 0xb4, 0x64, 0x1b, 0xc2, 0x7d,
0x52, 0x52, 0xa5, 0x85, 0x10, 0x1b, 0xcc, 0x42, 0x44, 0xd4, 0x49, 0xf4, 0xa8, 0x79, 0xd9,
0xf... | code_fim | hard | {
"lang": "rust",
"repo": "louiszhuang/OpenZKP",
"path": "/algebra/primefield/benchmarks/benches/dalek.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zphixon/froggi path: /client/simple-client.rs
use froggi::request::RequestKind;
fn main() {
let addr = std::env::args()
.nth(1)
.unwrap_or(String::from("127.0.0.1:11121"));
let request = std::env::args().nth(2).unwrap_or(String::from(""));
<|fim_suffix|> let result ... | code_fim | medium | {
"lang": "rust",
"repo": "zphixon/froggi",
"path": "/client/simple-client.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let result = froggi::send_request(addr, &request, RequestKind::PageOnly).unwrap();
match result.parse() {
Ok(page) => {
let document = froggi::markup::document::Document::from_page(&page);
println!("{}", document.to_string());
}
Err(errors) => {
... | code_fim | medium | {
"lang": "rust",
"repo": "zphixon/froggi",
"path": "/client/simple-client.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: terrarier2111/Leafish path: /src/entity/zombie.rs
use super::{Bounds, GameInfo, Light, Position, Rotation, Velocity};
use crate::ecs;
use crate::ecs::Entity;
use crate::entity::player_like::{compute_player_model_components, PlayerLikeModelPart};
use crate::entity::{CustomEntityRenderer, EntityTy... | code_fim | hard | {
"lang": "rust",
"repo": "terrarier2111/Leafish",
"path": "/src/entity/zombie.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> mdl.matrix[PlayerLikeModelPart::ArmRight as usize] = offset_matrix
* Matrix4::from_translation(Vector3::new(
6.0 / 16.0,
-12.0 / 16.0 - 12.0 / 16.0,
0.0,
))
* Matrix4::from(Quaternion::f... | code_fim | hard | {
"lang": "rust",
"repo": "terrarier2111/Leafish",
"path": "/src/entity/zombie.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let info = VkPipelineLayoutCreateInfo {
sType: VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,
pNext: null_mut(),
flags: 0,
setLayoutCount: 0,
pSetLayouts: null_mut(),
pushConstantRangeCount: 0,
pPushConstantRanges:... | code_fim | medium | {
"lang": "rust",
"repo": "des256/classic-e",
"path": "/src/gpu/vulkan/pipelinelayout.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Some(Rc::new(PipelineLayout {
session: Rc::clone(self),
vk_pipeline_layout: unsafe { vk_pipeline_layout.assume_init() },
}))
}
}
impl Drop for PipelineLayout {
fn drop(&mut self) {
unsafe { vkDestroyPipelineLayout(self.session.vk_device,self.vk_pip... | code_fim | hard | {
"lang": "rust",
"repo": "des256/classic-e",
"path": "/src/gpu/vulkan/pipelinelayout.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: des256/classic-e path: /src/gpu/vulkan/pipelinelayout.rs
// E - GPU (Vulkan) - PipelineLayout
// Desmond Germans, 2020
use {
crate::*,
std::{
ptr::null_mut,
mem::MaybeUninit,
rc::Rc,
},
sys_sys::*,
};
<|fim_suffix|> Some(Rc::new(PipelineLayout {
... | code_fim | hard | {
"lang": "rust",
"repo": "des256/classic-e",
"path": "/src/gpu/vulkan/pipelinelayout.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.