text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> for row in self.seats.iter() {
let mut row : String =
row.iter()
.map( |s| match s {
Seat::Empty => 'L',
Seat::Floor => '.',
Seat::Occupied => '#',
})
... | code_fim | hard | {
"lang": "rust",
"repo": "MatthewHannah/adventofcode2020",
"path": "/day11.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MatthewHannah/adventofcode2020 path: /day11.rs
use std::fmt;
#[derive(Copy, Clone, Debug, PartialEq)]
enum Seat {
Empty,
Occupied,
Floor,
}
fn parse_line(line: &str) -> Vec<Seat> {
let line = line.trim();
line.chars()
.map(|c| match c {
'L' => Seat::Empt... | code_fim | hard | {
"lang": "rust",
"repo": "MatthewHannah/adventofcode2020",
"path": "/day11.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> bail!("Process didn't exit correctly")
}
fn clone_closure_ownership_test_payload() -> super::CloneCb {
// The vec should not be deallocated after this function returns. The
// ownership should correctly transfer to the closure returned, to be
// passed to the clone... | code_fim | hard | {
"lang": "rust",
"repo": "yjuba/youki",
"path": "/src/process/fork.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yjuba/youki path: /src/process/fork.rs
use anyhow::bail;
use anyhow::Context;
use anyhow::Result;
use nix::errno::Errno;
use nix::sched;
use nix::sys;
use nix::sys::mman;
use nix::unistd::Pid;
use std::ptr;
// The clone callback is used in clone call. It is a boxed closure and it needs
// to tr... | code_fim | hard | {
"lang": "rust",
"repo": "yjuba/youki",
"path": "/src/process/fork.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let flags = sched::CloneFlags::empty();
let pid = super::clone(
Box::new(|| {
let mut array_on_stack = [0u8; 4096];
array_on_stack.iter_mut().for_each(|x| *x = 0);
0
}),
flags,
)?;
let sta... | code_fim | hard | {
"lang": "rust",
"repo": "yjuba/youki",
"path": "/src/process/fork.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: enzious/rust-websocket path: /src/header/upgrade.rs
use std::fmt::{self, Display};
use std::str::FromStr;
use http::header::HeaderValue;
use unicase;
pub struct Upgrade(pub Vec<Protocol>);
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum ProtocolName {
HTTP,
TLS,
WebSocket,
H2C,
Unregiste... | code_fim | hard | {
"lang": "rust",
"repo": "enzious/rust-websocket",
"path": "/src/header/upgrade.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut parts = s.splitn(2, '/');
Ok(Protocol::new(
try!(parts.next().unwrap().parse()),
parts.next().map(|x| x.to_owned()),
))
}
}
impl Display for Protocol {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
try!(fmt::Display::fmt(&self.name, f));
if let Some(ref version) = self.... | code_fim | hard | {
"lang": "rust",
"repo": "enzious/rust-websocket",
"path": "/src/header/upgrade.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let listener = TcpListener::bind(server_address_with_port).expect("Could not bind");
for stream in listener.incoming() {
match stream {
Err(e) => eprintln!("failed: {}", e),
Ok(stream) => {
thread::spawn(move || {
handle_client(st... | code_fim | hard | {
"lang": "rust",
"repo": "RodionKovalenko/rustCrates",
"path": "/src/tcp/tcp_server.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RodionKovalenko/rustCrates path: /src/tcp/tcp_server.rs
use crate::tcp::tcp_stream_actions::{send_msg, read_tcp_stream};
use std::net::{TcpListener, TcpStream};
use std::io::{Error};
use std::{str, thread};
use rand::Rng;
#[derive(Debug)]
struct Point3D {
x: u32,
y: u32,
z: u32,
}
... | code_fim | hard | {
"lang": "rust",
"repo": "RodionKovalenko/rustCrates",
"path": "/src/tcp/tcp_server.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub mod parse;
pub mod macros;
pub mod buffer;
pub mod rt;<|fim_prefix|>// repo: lifthrasiir/read.rs path: /src/read/lib.rs
#[crate_id = "read#0.1.0"];
#[crate_type = "dylib"];
#[crate_type = "lib"];
<|fim_middle|>#[feature(managed_boxes, globs, macro_registrar, macro_rules, quote)];
extern crate colle... | code_fim | medium | {
"lang": "rust",
"repo": "lifthrasiir/read.rs",
"path": "/src/read/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lifthrasiir/read.rs path: /src/read/lib.rs
#[crate_id = "read#0.1.0"];
#[crate_type = "dylib"];
#[crate_type = "lib"];
<|fim_suffix|>extern crate collections;
extern crate syntax;
pub mod parse;
pub mod macros;
pub mod buffer;
pub mod rt;<|fim_middle|>#[feature(managed_boxes, globs, macro_regi... | code_fim | medium | {
"lang": "rust",
"repo": "lifthrasiir/read.rs",
"path": "/src/read/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// PGH004
pub(crate) fn blanket_noqa(
diagnostics: &mut Vec<Diagnostic>,
indexer: &Indexer,
locator: &Locator,
) {
for range in indexer.comment_ranges() {
let line = locator.slice(*range);
if let Ok(Some(Directive::All(all))) = Directive::try_extract(line, range.start()) {... | code_fim | medium | {
"lang": "rust",
"repo": "astral-sh/ruff",
"path": "/crates/ruff/src/rules/pygrep_hooks/rules/blanket_noqa.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: astral-sh/ruff path: /crates/ruff/src/rules/pygrep_hooks/rules/blanket_noqa.rs
use ruff_python_ast::Ranged;
use ruff_diagnostics::{Diagnostic, Violation};
use ruff_macros::{derive_message_formats, violation};
use ruff_python_index::Indexer;
use ruff_source_file::Locator;
use crate::noqa::Direc... | code_fim | hard | {
"lang": "rust",
"repo": "astral-sh/ruff",
"path": "/crates/ruff/src/rules/pygrep_hooks/rules/blanket_noqa.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>struct AlignmentPositionIterator<'a, T> {
alignment: &'a Alignment<T>,
index: usize,
size_hint: usize,
}
struct AlignmentSequenceIterator<'a, T> {
alignment: &'a Alignment<T>,
index: usize,
size_hint: usize,
}
#[derive(Display, Debug)]
pub enum Mutation {
/// *
Conserved,... | code_fim | hard | {
"lang": "rust",
"repo": "jianshu93/multi-seq-align",
"path": "/src/lib.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jianshu93/multi-seq-align path: /src/lib.rs
/*! 
A crate to manipulate multiple sequences alignments in Rust.
Instead of storing aligned sequences as multiple strings, `multi_seq_align` stores bases or res... | code_fim | hard | {
"lang": "rust",
"repo": "jianshu93/multi-seq-align",
"path": "/src/lib.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lighter/Leetcode-Rust path: /n0171. Excel Sheet Column Number/main.rs
// Author: Netcan @ https://github.com/netcan/Leetcode-Rust
// Zhihu: https://www.zhihu.com/people/netcan
impl Solution {
pub fn title_to_number<|fim_suffix|> .fold(0, |acc, d| { acc * 26 + (d - 'A' as u8 + 1) as i3... | code_fim | medium | {
"lang": "rust",
"repo": "lighter/Leetcode-Rust",
"path": "/n0171. Excel Sheet Column Number/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> .fold(0, |acc, d| { acc * 26 + (d - 'A' as u8 + 1) as i32 })
}
}<|fim_prefix|>// repo: lighter/Leetcode-Rust path: /n0171. Excel Sheet Column Number/main.rs
// Author: Netcan @ https://github.com/netcan/Leetcode-Rust
// Zhihu: https://www.zhihu.com/people/netcan
impl Solution {
pub fn tit... | code_fim | medium | {
"lang": "rust",
"repo": "lighter/Leetcode-Rust",
"path": "/n0171. Excel Sheet Column Number/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>(s: String) -> i32 {
s.into_bytes()
.into_iter()
.fold(0, |acc, d| { acc * 26 + (d - 'A' as u8 + 1) as i32 })
}
}<|fim_prefix|>// repo: lighter/Leetcode-Rust path: /n0171. Excel Sheet Column Number/main.rs
// Author: Netcan @ https://github.com/netcan/Leetcode-Rust
// ... | code_fim | medium | {
"lang": "rust",
"repo": "lighter/Leetcode-Rust",
"path": "/n0171. Excel Sheet Column Number/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jyn514/codespan path: /codespan-reporting/tests/term.rs
use codespan::Files;
use codespan_reporting::diagnostic::{Diagnostic, Label};
use codespan_reporting::term::{termcolor::Color, Config, DisplayStyle, Styles};
mod support;
use self::support::TestData;
fn test_config() -> Config {
Conf... | code_fim | hard | {
"lang": "rust",
"repo": "jyn514/codespan",
"path": "/codespan-reporting/tests/term.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn short_no_color() {
let config = Config {
display_style: DisplayStyle::Short,
..Config::default()
};
insta::assert_snapshot!("short_no_color", TEST_DATA.emit_no_color(&config));
}
}
mod fizz_buzz {
use super::*;
lazy_static::... | code_fim | hard | {
"lang": "rust",
"repo": "jyn514/codespan",
"path": "/codespan-reporting/tests/term.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub mod install;
pub mod run;
pub mod run_detached;
pub mod uninstall;
pub mod self_update;<|fim_prefix|>// repo: kunicmarko20/ghnotifier-rs path: /src/ui/cli/command/mod.rs
use super::output::Output;
<|fim_middle|>pub trait Command {
fn execute(&self, output: Box<Output>);
}
| code_fim | medium | {
"lang": "rust",
"repo": "kunicmarko20/ghnotifier-rs",
"path": "/src/ui/cli/command/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kunicmarko20/ghnotifier-rs path: /src/ui/cli/command/mod.rs
use super::output::Output;
<|fim_suffix|>pub mod install;
pub mod run;
pub mod run_detached;
pub mod uninstall;
pub mod self_update;<|fim_middle|>pub trait Command {
fn execute(&self, output: Box<Output>);
}
| code_fim | medium | {
"lang": "rust",
"repo": "kunicmarko20/ghnotifier-rs",
"path": "/src/ui/cli/command/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let r: BOOL = unsafe {
msg_send![workspace, setDesktopImageURL: path forScreen: screen options: options error: &mut error]
};
match r as BOOL {
1 => Ok(()),
_ => Err(()),
}
}<|fim_prefix|>// repo: mika-sandbox/rust-wallpaper path: /src/platform/macos.rs
use std::ptr::null_mut;
use o... | code_fim | hard | {
"lang": "rust",
"repo": "mika-sandbox/rust-wallpaper",
"path": "/src/platform/macos.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mika-sandbox/rust-wallpaper path: /src/platform/macos.rs
use std::ptr::null_mut;
use objc::runtime::{Class, Object, BOOL};
use objc::*;
#[link(name = "AppKit", kind = "framework")]
extern "system" {}
pub fn apply_change(path: &str) -> Result<(), ()> {
let cls = Class::get("NSString").unwrap... | code_fim | hard | {
"lang": "rust",
"repo": "mika-sandbox/rust-wallpaper",
"path": "/src/platform/macos.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: oniproject/oni path: /rooms/src/components.rs
use specs::prelude::*;
use crate::index::{KDBush, Shim, Around, SpatialIndex};
#[derive(Component)]
#[storage(HashMapStorage)]
pub struct Room<S: Shim> {
crate index: KDBush<S>,
}
impl<S: Shim> Room<S> {
pub fn new() -> Self {
Self:... | code_fim | hard | {
"lang": "rust",
"repo": "oniproject/oni",
"path": "/rooms/src/components.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Component)]
#[storage(DenseVecStorage)]
pub struct Spawned {
crate room: Entity,
}
impl Spawned {
pub fn new(room: Entity) -> Self {
Self { room }
}
}<|fim_prefix|>// repo: oniproject/oni path: /rooms/src/components.rs
use specs::prelude::*;
use crate::index::{KDBush, Shim, ... | code_fim | hard | {
"lang": "rust",
"repo": "oniproject/oni",
"path": "/rooms/src/components.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> queue.push_back(line.clone());
return true;
}
return false;
});
}
fn main() {
let matches = App::new("uq (lostutils)")
.arg(
Arg::with_name("capacity")
.short("n")
.help("Number of unique entries to rememb... | code_fim | hard | {
"lang": "rust",
"repo": "Enet4/uq",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let matches = App::new("uq (lostutils)")
.arg(
Arg::with_name("capacity")
.short("n")
.help("Number of unique entries to remember.")
.value_name("capacity")
.takes_value(true),
)
.arg(
Arg::... | code_fim | hard | {
"lang": "rust",
"repo": "Enet4/uq",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Enet4/uq path: /src/main.rs
extern crate clap;
use clap::{App, Arg};
use std::collections::{HashSet, VecDeque};
struct StdinReader;
impl Iterator for StdinReader {
type Item = String;
fn next(&mut self) -> Option<String> {
let mut line = String::new();
match std::io:... | code_fim | hard | {
"lang": "rust",
"repo": "Enet4/uq",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn all() -> Layered<Layered<NoopEntry, Stdin>, Stdout> {
layer(stdin()).layer(stdout())
}<|fim_prefix|>// repo: defvar/toy path: /plugins/toy-plugin-commons/toy-plugin-stdio/src/plugin.rs
use super::service::*;
use toy_core::prelude::{layer, Layered, NoopEntry};
<|fim_middle|>const NAME_SPACE: &... | code_fim | hard | {
"lang": "rust",
"repo": "defvar/toy",
"path": "/plugins/toy-plugin-commons/toy-plugin-stdio/src/plugin.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: defvar/toy path: /plugins/toy-plugin-commons/toy-plugin-stdio/src/plugin.rs
use super::service::*;
use toy_core::prelude::{layer, Layered, NoopEntry};
<|fim_suffix|>pub fn stdout() -> (&'static str, &'static str, Stdout) {
(NAME_SPACE, "stdout", Stdout)
}
pub fn all() -> Layered<Layered<No... | code_fim | medium | {
"lang": "rust",
"repo": "defvar/toy",
"path": "/plugins/toy-plugin-commons/toy-plugin-stdio/src/plugin.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: andrewhickman/small-lang path: /src/optimize/tests.rs
use std::rc::Rc;
use codespan::FileId;
use proptest::proptest;
use crate::check::{check, ir};
use crate::generate::generate;
use crate::optimize::{optimize, Opts};
use crate::pipeline::{Pipeline, ProcessOutput, ProcessResult, Source};
use c... | code_fim | hard | {
"lang": "rust",
"repo": "andrewhickman/small-lang",
"path": "/src/optimize/tests.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn structural_eq(lhs: &Option<rt::Value>, rhs: &Option<rt::Value>) -> bool {
match (lhs, rhs) {
(Some(lhs), Some(rhs)) => structural_eq_value(lhs, rhs),
(Some(_), None) | (None, Some(_)) => true,
(None, None) => true,
}
}
fn structural_eq_value(lhs: &rt::Value, rhs: &rt::V... | code_fim | hard | {
"lang": "rust",
"repo": "andrewhickman/small-lang",
"path": "/src/optimize/tests.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>trait TypeParametric<T> = Iterator<Item=Cow<'static, [T]>>;<|fim_prefix|>// repo: intellij-rust/intellij-rust path: /src/test/resources/org/rust/lang/core/parser/fixtures/complete/trait_aliases.rs
trait DebugDefault = Debug + Default;
trait DebugDefaultWhere = Debug where Self: Default;
<|fim_middle|>t... | code_fim | medium | {
"lang": "rust",
"repo": "intellij-rust/intellij-rust",
"path": "/src/test/resources/org/rust/lang/core/parser/fixtures/complete/trait_aliases.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>trait IntoIntIterator = IntoIterator<Item=i32>;
trait LifetimeParametric<'a> = Iterator<Item=Cow<'a, [i32]>>;`
trait TypeParametric<T> = Iterator<Item=Cow<'static, [T]>>;<|fim_prefix|>// repo: intellij-rust/intellij-rust path: /src/test/resources/org/rust/lang/core/parser/fixtures/complete/trait_aliase... | code_fim | easy | {
"lang": "rust",
"repo": "intellij-rust/intellij-rust",
"path": "/src/test/resources/org/rust/lang/core/parser/fixtures/complete/trait_aliases.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn register(&self, dest: Sender<Arc<T>>) {
self.tx.send(MulticastMsgDest(dest))
}
}
impl<T:Send> Clone for Multicast<T> {
fn clone(&self) -> Multicast<T> {
Multicast { tx: self.tx.clone() }
}
}<|fim_prefix|>// repo: alon/d3cap path: /src/multicast/src/lib.rs
use std::... | code_fim | hard | {
"lang": "rust",
"repo": "alon/d3cap",
"path": "/src/multicast/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alon/d3cap path: /src/multicast/src/lib.rs
use std::comm::{channel, Sender, Receiver};
use std::task::{TaskBuilder};
use std::sync::Arc;
pub enum MulticastMsg<T> {
MulticastMsg(Arc<T>),
MulticastMsgDest(Sender<Arc<T>>)
}
<|fim_suffix|>impl<T:Send+Sync> Multicast<T> {
pub fn spawn()... | code_fim | hard | {
"lang": "rust",
"repo": "alon/d3cap",
"path": "/src/multicast/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if first_six == 0 {
println!("first six: {}", i);
break;
}
}
}<|fim_prefix|>// repo: FreeCX/advent-of-code path: /2015/day04/src/main.rs
extern crate md5;
use md5::compute;
fn main() {
let mut first_five_not_found = true;
let key = "yzbqklnj";
<|fim_m... | code_fim | hard | {
"lang": "rust",
"repo": "FreeCX/advent-of-code",
"path": "/2015/day04/src/main.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: FreeCX/advent-of-code path: /2015/day04/src/main.rs
extern crate md5;
use md5::compute;
fn main() {
let mut first_five_not_found = true;
let key = "yzbqklnj";
for i in 0..std::u64::MAX {
let output = compute(format!("{}{}", key, i).as_bytes());
let first_five = outp... | code_fim | medium | {
"lang": "rust",
"repo": "FreeCX/advent-of-code",
"path": "/2015/day04/src/main.rs",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if first_five_not_found && first_five == 0 {
println!("first five: {}", i);
first_five_not_found = false;
}
if first_six == 0 {
println!("first six: {}", i);
break;
}
}
}<|fim_prefix|>// repo: FreeCX/advent-of-code path:... | code_fim | hard | {
"lang": "rust",
"repo": "FreeCX/advent-of-code",
"path": "/2015/day04/src/main.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> loop {
modify_reg!(gpio, gpiob, ODR, ODR0: Low, ODR7: High, ODR14: Low);
delay(10_000_000);
modify_reg!(gpio, gpiob, ODR, ODR0: High, ODR7: Low, ODR14: High);
delay(10_000_000);
}
}<|fim_prefix|>// repo: zhp-rs/stm32 path: /src/main.rs
#![no_std]
#![no_main]
use p... | code_fim | hard | {
"lang": "rust",
"repo": "zhp-rs/stm32",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zhp-rs/stm32 path: /src/main.rs
#![no_std]
#![no_main]
use panic_semihosting as _;
use cortex_m::asm::delay;
use cortex_m_rt::entry;
use stm32ral::{gpio, modify_reg, rcc, read_reg};
#[entry]
fn main() -> ! {
let rcc1 = rcc::RCC::take().unwrap();
modify_reg!(rcc, rcc1, CR, HSEON: On);
... | code_fim | medium | {
"lang": "rust",
"repo": "zhp-rs/stm32",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let unsorted = vec![ 5, 15, 20, 13 ];
let sorted = selection_sort(unsorted);
assert_eq!(sorted, [5, 13, 15, 20]);
}
fn selection_sort<T: Ord+Clone>(numbers: Vec<T>) -> Vec<T> {
let mut numbers: Vec<T> = numbers.clone();
for i in 1..numbers.len() {
let mut min = i;
for j in i+1..num... | code_fim | hard | {
"lang": "rust",
"repo": "steveklabnik/study",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> numbers.swap(min, i);
}
return numbers;
}
fn merge_sort(mut arr: Vec<usize>) -> Vec<usize> {
if arr.len()<2 {
return arr };
if arr.len()==2 {
if arr[0] > arr[1] {
arr.swap(0,1);
}
return arr;
}
let (left, right) = arr.split_at(arr.len()/2);
return merge(
m... | code_fim | hard | {
"lang": "rust",
"repo": "steveklabnik/study",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: steveklabnik/study path: /src/main.rs
extern crate rand;
use rand::Rng;
fn main() {
let unsorted = vec![ 5, 15, 20, 13 ];
println!("{:?}", unsorted);
let sorted = merge_sort(unsorted);
println!("{:?}", sorted);
return;
}
#[test]
fn test_merge_sort() {
let mut unsorted: Vec<us... | code_fim | hard | {
"lang": "rust",
"repo": "steveklabnik/study",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jilsahm/foaas-rs path: /client/src/lib.rs
mod configuration;
mod content_type;
mod error;
mod foaas;
mod operation;
pub use error:<|fim_suffix|> use configuration::FoaasClientConfiguration;<|fim_middle|>:FoaasError;
pub use foaas::FoaasClient;
pub | code_fim | easy | {
"lang": "rust",
"repo": "jilsahm/foaas-rs",
"path": "/client/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> use configuration::FoaasClientConfiguration;<|fim_prefix|>// repo: jilsahm/foaas-rs path: /client/src/lib.rs
mod configuration;
mod content_type;
mod err<|fim_middle|>or;
mod foaas;
mod operation;
pub use error::FoaasError;
pub use foaas::FoaasClient;
pub | code_fim | medium | {
"lang": "rust",
"repo": "jilsahm/foaas-rs",
"path": "/client/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jilsahm/foaas-rs path: /client/src/lib.rs
mod configuration;
mod content_type;
mod err<|fim_suffix|>:FoaasError;
pub use foaas::FoaasClient;
pub use configuration::FoaasClientConfiguration;<|fim_middle|>or;
mod foaas;
mod operation;
pub use error: | code_fim | easy | {
"lang": "rust",
"repo": "jilsahm/foaas-rs",
"path": "/client/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: oshunter/fuchsia path: /src/connectivity/bluetooth/tools/bt-fct-hci/src/main.rs
// Copyright 2020 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#![recursion_limit = "256"]
mod hci;
mod types;
u... | code_fim | hard | {
"lang": "rust",
"repo": "oshunter/fuchsia",
"path": "/src/connectivity/bluetooth/tools/bt-fct-hci/src/main.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> print_response_loop(verbose, command_channel, out_opcode, false).await
}
/// Parse program arguments, call the main loop, and log any unrecoverable errors.
#[fasync::run_singlethreaded]
async fn main() -> Result<(), Error> {
let args: Args = argh::from_env();
if args.verbose {
printl... | code_fim | hard | {
"lang": "rust",
"repo": "oshunter/fuchsia",
"path": "/src/connectivity/bluetooth/tools/bt-fct-hci/src/main.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> for index in &mut self.indices {
let res = &mut index.delete(key);
if let IndexResult::Error(err_msg) = res {
return IndexResult::Error(err_msg.to_string());
}
}
IndexResult::Ok
}
}<|fim_prefix|>// repo: dragonquest/diskv p... | code_fim | hard | {
"lang": "rust",
"repo": "dragonquest/diskv",
"path": "/src/index/multiindex.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dragonquest/diskv path: /src/index/multiindex.rs
pub use super::Index;
pub use super::IndexResult;
/// MultiIndex is an Index that can hold more chained indices
pub struct MultiIndex<I: Index> {
indices: Vec<I>,
}
impl<I: Index> MultiIndex<I> {
pub fn new(indices: Vec<I>) -> impl Index... | code_fim | hard | {
"lang": "rust",
"repo": "dragonquest/diskv",
"path": "/src/index/multiindex.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AlterionX/crossarena path: /src/entity/forge.rs
use gdnative::{
self as godot,
GodotString,
init::{Property, PropertyHint, ClassBuilder, Signal,},
Instance,
StaticBody2D,
NativeClass,
Node,
NodePath,
user_data::MutexData,
Variant,
ToVariant,
};
use tap... | code_fim | hard | {
"lang": "rust",
"repo": "AlterionX/crossarena",
"path": "/src/entity/forge.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[export]
fn _ready(&self, owner: StaticBody2D) {
Group::Switch.add_node(unsafe { owner.to_node() });
log::info!("Hello from switch.")
}
#[export]
fn switch(&self, owner: StaticBody2D) {
log::info!("Forge was hit!");
// TODO pause game and open crafting... | code_fim | hard | {
"lang": "rust",
"repo": "AlterionX/crossarena",
"path": "/src/entity/forge.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[export]
fn damage(&self, owner: StaticBody2D, _dmg: f64) {
self.switch(owner);
}
}
impl Forge {
pub fn call_instance_init(mut switch: StaticBody2D, ui: Node) {
let instance_init_method: GodotString = "instance_init".into();
if unsafe { switch.has_method(instance_... | code_fim | hard | {
"lang": "rust",
"repo": "AlterionX/crossarena",
"path": "/src/entity/forge.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cLazyZombie/learn-glyph path: /src/main.rs
//use ab_glyph::*;
use glyph_brush_layout::{ab_glyph::*, *};
use image::*;
fn main() {
glyph_brush("hello", "world");
glyph_to_image('Q');
glyph_to_image('K');
glyph_to_image('s');
glyph_to_image('M');
}
fn glyph_to_image(ch: char)... | code_fim | hard | {
"lang": "rust",
"repo": "cLazyZombie/learn-glyph",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // create image
let mut glyphs_image: RgbaImage = ImageBuffer::new(512, 512);
for section_glyph in &glyphs {
let font = &fonts[section_glyph.font_id];
let outline_glyph = font.outline_glyph(section_glyph.glyph.clone()).unwrap();
let bounds = dbg!(outline_glyph.px_bounds... | code_fim | hard | {
"lang": "rust",
"repo": "cLazyZombie/learn-glyph",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Kanaricc/iron_tank path: /tank_core/src/judge/special.rs
use std::io::{Read, Write};
use std::{
fs,
path::Path,
process::{Command, Stdio},
};
use super::{get_path_of_tankcell, Judge};
use crate::{JudgeResult, JudgeStatus, compile::CompiledProgram, problem::LimitConfig, error::Error,... | code_fim | hard | {
"lang": "rust",
"repo": "Kanaricc/iron_tank",
"path": "/tank_core/src/judge/special.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let pid = command.id();
let probe = ProcessProbe::new(pid)?;
let cin = command.stdin.as_mut().ok_or(std::io::Error::new(
std::io::ErrorKind::BrokenPipe,
"failed to open stdin",
))?;
cin.write_all(self.input.as_bytes())?;
cin.flush()?... | code_fim | hard | {
"lang": "rust",
"repo": "Kanaricc/iron_tank",
"path": "/tank_core/src/judge/special.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ue fill-level below flow-control deactivate threshold 0x2: Rx Queue fill-level above flow-control activate threshold 0x3: Rx Queue full."]
#[inline(always)]
pub fn rxqsts(&self) -> RXQSTS_R {
RXQSTS_R::new(((self.bits() >> 4) & 0x03) as u8)
}
#[doc = "Bits 16:29 - Number of Packets... | code_fim | hard | {
"lang": "rust",
"repo": "pklazy/lpc54628-rust",
"path": "/src/enet/mtl_queue/mtl_rxqx_dbg.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pklazy/lpc54628-rust path: /src/enet/mtl_queue/mtl_rxqx_dbg.rs
#[doc = r"Value read from the register"]
pub struct R {
bits: u32,
}
#[doc = r"Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::MTL_RXQX_DBG {
#[doc = r"Modifies the contents of the register"]
... | code_fim | hard | {
"lang": "rust",
"repo": "pklazy/lpc54628-rust",
"path": "/src/enet/mtl_queue/mtl_rxqx_dbg.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SEbbaDK/playform path: /server/lib/terrain/biome/caves.rs
//! Cave biome. This is very experimental and really needs occlusion culling to support any render distance at all.
use cgmath::{Point3, Vector3, InnerSpace};
use noise::{Seed, perlin3};
use common::voxel;
#[allow(missing_docs)]
pub st... | code_fim | medium | {
"lang": "rust",
"repo": "SEbbaDK/playform",
"path": "/server/lib/terrain/biome/caves.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn normal(&mut self, p: &Point3<f32>) -> Vector3<f32> {
// Use density differential in each dimension as an approximation of the normal.
let delta = 0.01;
macro_rules! differential(($d:ident) => {{
let high: f32 = {
let mut p = *p;
p.$d += delta;
voxel::field:... | code_fim | hard | {
"lang": "rust",
"repo": "SEbbaDK/playform",
"path": "/server/lib/terrain/biome/caves.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Use density differential in each dimension as an approximation of the normal.
let delta = 0.01;
macro_rules! differential(($d:ident) => {{
let high: f32 = {
let mut p = *p;
p.$d += delta;
voxel::field::T::density(self, &p)
};
let low: f32 = {
... | code_fim | medium | {
"lang": "rust",
"repo": "SEbbaDK/playform",
"path": "/server/lib/terrain/biome/caves.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// if a tweet/toot is unable to send
pub fn not_sent(service: Destination) {
let string = language(Language::new(service, 4));
match Notification::new()
.appname("ShareXin")
.summary(string)
.timeout(5000)
.show()
{
Ok(ok) => ok,
Err(_) => {
... | code_fim | hard | {
"lang": "rust",
"repo": "calvcoll/ShareXin",
"path": "/src/notification.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: calvcoll/ShareXin path: /src/notification.rs
#[cfg(target_family = "unix")]
use notify_rust::Notification;
use Destination;
use error;
use language::{language, Language};
// when the tweet/toot with an image is sent
pub fn image_sent(service: Destination, text: &str, img: &str) {
let strin... | code_fim | hard | {
"lang": "rust",
"repo": "calvcoll/ShareXin",
"path": "/src/notification.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: frxstrem/utuntap path: /src/lib.rs
#[cfg(target_os = "linux")]
#[macro_use]
extern crate nix;
#[cfg(target_os = "linux")]
#[path = "interface/linux.rs"]
mod interface;
#[cfg(target_os = "linux")]
use interface::Flags;
use std::fmt;
use std::fs::{self, File};
use std::io::Result;
#[cfg(target_f... | code_fim | hard | {
"lang": "rust",
"repo": "frxstrem/utuntap",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut options = OpenOptions::new();
assert_eq!(options.mode, Mode::Tun);
options.mode(Mode::Tap);
assert_eq!(options.mode, Mode::Tap);
options.mode(Mode::Tun);
assert_eq!(options.mode, Mode::Tun);
}
#[test]
fn change_number() {
let mut... | code_fim | hard | {
"lang": "rust",
"repo": "frxstrem/utuntap",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.nonblock = value;
self
}
fn mode(&mut self, value: Mode) -> &mut Self {
self.mode = value;
self
}
fn number(&mut self, value: u8) -> &mut Self {
self.number = Some(value);
self
}
#[cfg(target_os = "linux")]
fn packet_info(... | code_fim | hard | {
"lang": "rust",
"repo": "frxstrem/utuntap",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nuxeh/aocf path: /examples/day01.rs
extern crate aocf;
use aocf::Aoc;
fn main() {
<|fim_suffix|> let input = if let Ok(i) = aoc.get_input(false) {
i
} else {
"you probably need to add a valid cookie".to_string()
};
println!("{}", input);
}<|fim_middle|> let m... | code_fim | medium | {
"lang": "rust",
"repo": "nuxeh/aocf",
"path": "/examples/day01.rs",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|> let input = if let Ok(i) = aoc.get_input(false) {
i
} else {
"you probably need to add a valid cookie".to_string()
};
println!("{}", input);
}<|fim_prefix|>// repo: nuxeh/aocf path: /examples/day01.rs
extern crate aocf;
use aocf::Aoc;
fn main() {
<|fim_middle|> let m... | code_fim | medium | {
"lang": "rust",
"repo": "nuxeh/aocf",
"path": "/examples/day01.rs",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn take(&self) -> Vec<Action> {
let mut actions = self.actions.lock().unwrap();
mem::replace(&mut *actions, Vec::new())
}
}<|fim_prefix|>// repo: or17191/texlab path: /src/action.rs
use lsp_types::Uri;
use std::mem;
use std::path::PathBuf;
use std::sync::Mutex;
#[derive(Debug... | code_fim | medium | {
"lang": "rust",
"repo": "or17191/texlab",
"path": "/src/action.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: or17191/texlab path: /src/action.rs
use lsp_types::Uri;
use std::mem;
use std::path::PathBuf;
use std::sync::Mutex;
#[derive(Debug, PartialEq, Eq, Clone)]
pub enum LintReason {
Change,
Save,
}
#[derive(Debug, PartialEq, Eq, Clone)]
pub enum Action {
RegisterCapabilities,
Detect... | code_fim | hard | {
"lang": "rust",
"repo": "or17191/texlab",
"path": "/src/action.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: khoslaventures/ilp-rs path: /examples/receiver.rs
extern crate bytes;
extern crate chrono;
extern crate env_logger;
extern crate futures;
extern crate ilp;
extern crate ring;
extern crate tokio;
extern crate tokio_io;
use futures::{Future, Stream};
use ilp::plugin::btp::connect_async;
use ilp::... | code_fim | hard | {
"lang": "rust",
"repo": "khoslaventures/ilp-rs",
"path": "/examples/receiver.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // TODO fix inconsistent data receiving
let data: Vec<u8> = Vec::new();
let handle_data = read_to_end(stream.data, data)
.map_err(|err| {
... | code_fim | hard | {
"lang": "rust",
"repo": "khoslaventures/ilp-rs",
"path": "/examples/receiver.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Whether this peer believes it is the leader.
pub fn is_leader(&self) -> bool {
self.get_state().is_leader()
}
pub fn get_state(&self) -> raft::State {
// Your code here.
self.server.lock().unwrap().rf.get_state()
}
fn is_shutdown(&self) -> bool {
... | code_fim | hard | {
"lang": "rust",
"repo": "cppcoffee/pingcap_talent_plan",
"path": "/dss/raft/src/kvraft/server.rs",
"mode": "spm",
"license": "CC-BY-4.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cppcoffee/pingcap_talent_plan path: /dss/raft/src/kvraft/server.rs
use crate::proto::kvraftpb::*;
use crate::raft;
use std::collections::HashMap;
use std::sync::{Arc, Mutex};
use std::thread;
use std::time::Duration;
use futures::prelude::*;
use futures::sync::mpsc::{unbounded, UnboundedReceiv... | code_fim | hard | {
"lang": "rust",
"repo": "cppcoffee/pingcap_talent_plan",
"path": "/dss/raft/src/kvraft/server.rs",
"mode": "psm",
"license": "CC-BY-4.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> DeflateDecompressorState::Huffman(
(bfinal, HuffmanState {
litlen_tree, distance_tree, distance: 0, copy_len: 0,
})
)
},
3 => {
return Err(DeflateDecompressorError::Inval... | code_fim | hard | {
"lang": "rust",
"repo": "blindley/stdex",
"path": "/src/io/deflate/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: blindley/stdex path: /src/io/deflate/mod.rs
use std::io::Read;
use crate::huffman::{Node, Code, CodeString};
use crate::io::{BitRead, BitReaderLSB};
use crate::collections::BitString;
use crate::io::{write_u8};
mod ring_buffer;
struct Codes {
litlen: Vec<Code<u16>>,
distance: Vec<Code<... | code_fim | hard | {
"lang": "rust",
"repo": "blindley/stdex",
"path": "/src/io/deflate/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Parse for AttributeInput {
fn parse(input: ParseStream) -> syn::Result<Self> {
Ok(AttributeInput {
real_name: input.parse()?,
separator: input.parse()?,
repr_type: input.parse()?,
})
}
}
#[proc_macro_attribute]
pub fn flag_builder(attribute... | code_fim | hard | {
"lang": "rust",
"repo": "mcoffin/vulkan-device-filter",
"path": "/flag-builder/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mcoffin/vulkan-device-filter path: /flag-builder/src/lib.rs
#![recursion_limit="128"]
extern crate proc_macro;
extern crate proc_macro2;
extern crate quote;
extern crate syn;
extern crate inflector;
use proc_macro::TokenStream;
use syn::{
parse::{
Parse,
ParseStream,
},... | code_fim | hard | {
"lang": "rust",
"repo": "mcoffin/vulkan-device-filter",
"path": "/flag-builder/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> impl #builder_ident {
#(#builder_fns)*
#[inline]
pub fn set(self, flag: #enum_ident, v: bool) -> Self {
if v {
let mask = flag as #repr_type;
#builder_ident(self.0 | mask)
} else {
... | code_fim | hard | {
"lang": "rust",
"repo": "mcoffin/vulkan-device-filter",
"path": "/flag-builder/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fmt::Formatter<'_>) ->fmt::Result{
writeln!(f,"{}",self.link)
}
}<|fim_prefix|>// repo: n8wachT/Zeiver path: /asset/src/directory.rs
use std::fmt;
pub struct Directory{
pub link:String,
}
impl Directory{
<|fim_middle|> pub fn new(link: String) -> Directory{
Directory{
... | code_fim | medium | {
"lang": "rust",
"repo": "n8wachT/Zeiver",
"path": "/asset/src/directory.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: n8wachT/Zeiver path: /asset/src/directory.rs
use std::fmt;
pub struct Directory{
pub link:String,
}
impl Directory{
<|fim_suffix|>fmt::Formatter<'_>) ->fmt::Result{
writeln!(f,"{}",self.link)
}
}<|fim_middle|> pub fn new(link: String) -> Directory{
Directory{
... | code_fim | medium | {
"lang": "rust",
"repo": "n8wachT/Zeiver",
"path": "/asset/src/directory.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>k
}
}
}
impl fmt::Debug for Directory{
fn fmt(&self, f: &mut fmt::Formatter<'_>) ->fmt::Result{
writeln!(f,"{}",self.link)
}
}<|fim_prefix|>// repo: n8wachT/Zeiver path: /asset/src/directory.rs
use std::fmt;
pub struct Directory{
pub link:String,
}
impl Directory{
<|fim_... | code_fim | medium | {
"lang": "rust",
"repo": "n8wachT/Zeiver",
"path": "/asset/src/directory.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(feature = "difference")]
extern crate difference;
#[cfg(feature = "float-cmp")]
extern crate float_cmp;
#[cfg(feature = "normalize-line-endings")]
extern crate normalize_line_endings;
#[cfg(feature = "regex")]
extern crate regex;
pub mod prelude;
pub use predicates_core::*;
mod boxed;
pub use boxe... | code_fim | hard | {
"lang": "rust",
"repo": "kammitama5/predicates-rs",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kammitama5/predicates-rs path: /src/lib.rs
// Copyright (c) 2018 The predicates-rs Project Developers.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/license/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, ... | code_fim | hard | {
"lang": "rust",
"repo": "kammitama5/predicates-rs",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>nrr_apps::Error::ConfigRequireRos(..))),
"{:?} {:?}",
f,
result
);
} else {
assert!(result.is_ok(), "{:?} {:?}", f, result);
}
}
}<|fim_prefix|>// repo: chatblanc-ciel/openrr path: /openrr-apps/tests/test_robot_co... | code_fim | hard | {
"lang": "rust",
"repo": "chatblanc-ciel/openrr",
"path": "/openrr-apps/tests/test_robot_config.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>onfig_for_urdf_viz.toml",
];
for f in files {
let result = RobotConfig::try_new(f);
if cfg!(not(feature = "ros")) && f.contains("ros") {
assert!(
matches!(result, Err(openrr_apps::Error::ConfigRequireRos(..))),
"{:?} {:?}",
... | code_fim | hard | {
"lang": "rust",
"repo": "chatblanc-ciel/openrr",
"path": "/openrr-apps/tests/test_robot_config.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chatblanc-ciel/openrr path: /openrr-apps/tests/test_robot_config.rs
use openrr_apps::RobotConfig;
#[test]
fn verify_sample_configs() {
let files = vec![
"config/pr2_robot_client_config_for_ros.toml",
"config/pr2_robot_client_config_for_urdf_viz.toml",
"config/s<|fim_... | code_fim | hard | {
"lang": "rust",
"repo": "chatblanc-ciel/openrr",
"path": "/openrr-apps/tests/test_robot_config.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: KasuyaMofu/vtuber-isucon10f path: /rust/src/admin.rs
use crate::proto::services::admin::{
initialize_response::BenchmarkServer, GetClarificationResponse, InitializeRequest,
InitializeResponse, ListClarificationsResponse, RespondClarificationRequest,
RespondClarificationResponse,
};
u... | code_fim | hard | {
"lang": "rust",
"repo": "KasuyaMofu/vtuber-isucon10f",
"path": "/rust/src/admin.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let clarification = web::block(move || {
let mut conn = db.get().expect("Failed to checkout database connection");
let current_contestant =
crate::require_current_contestant(conn.deref_mut(), &contestant_id, false)?;
if !current_contestant.staff {
return... | code_fim | hard | {
"lang": "rust",
"repo": "KasuyaMofu/vtuber-isucon10f",
"path": "/rust/src/admin.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gotcake/rust-nerual-net path: /src/train/trainer.rs
use rand::{Rng, FromEntropy, SeedableRng};
use crate::func::CompletionFn;
use crate::net::{Net, NetConfig};
use crate::data::PreparedDataSet;
use crate::stats::Stats;
use crate::train::backprop::BackpropOptions;
use crate::train::executor::Exe... | code_fim | hard | {
"lang": "rust",
"repo": "gotcake/rust-nerual-net",
"path": "/src/train/trainer.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // send next task to execute
let task = self.next_task(epoch);
self.omit_event(&TrainingEvent::TaskSubmit(&task));
ctrl_master.send_task(task)?;
}
let best = best.unwrap();
Ok(TrainingResult {
net: best.net,
... | code_fim | hard | {
"lang": "rust",
"repo": "gotcake/rust-nerual-net",
"path": "/src/train/trainer.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let session = client
.log_in(config.userid, config.password, None, None)
.await?;
println!("{}", session.access_token);
Ok(())
}<|fim_prefix|>// repo: JJJollyjim/matrix-irc-monitor path: /src/login.rs
use serde::Deserialize;
use std::error::Error;
#[derive(Deserialize, Debug... | code_fim | hard | {
"lang": "rust",
"repo": "JJJollyjim/matrix-irc-monitor",
"path": "/src/login.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JJJollyjim/matrix-irc-monitor path: /src/login.rs
use serde::Deserialize;
use std::error::Error;
#[derive(Deserialize, Debug)]
struct Config {
homeserver: String,
userid: String,
password: String,
}
<|fim_suffix|> let session = client
.log_in(config.userid, config.passwo... | code_fim | hard | {
"lang": "rust",
"repo": "JJJollyjim/matrix-irc-monitor",
"path": "/src/login.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: HiraokaTakuya/atcoder_test path: /src/main.rs
use std::io::prelude::*;
use std::process::{Command, Stdio};
fn input(child: &mut std::process::Child, s: &str) {
let s = s.to_owned() + "\n";
let stdin = child.stdin.as_mut().unwrap();
match stdin.write(s.as_bytes()) {
Ok(_) => ... | code_fim | hard | {
"lang": "rust",
"repo": "HiraokaTakuya/atcoder_test",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let args = std::env::args().collect::<Vec<_>>(); // target contest problem
if args.len() != 3 {
eprintln!("arguments errror!\nexpected: {} <contest name (for example: abc121)> <problem name (for example: a)>", args[0]);
return;
}
let inouts = {
let url = format!(
... | code_fim | hard | {
"lang": "rust",
"repo": "HiraokaTakuya/atcoder_test",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: reproto/reproto path: /lib/core/src/attributes.rs
//! Provide a collection of attributes and a convenient way for querying them.
//!
//! These structures are all map-like.
use crate::errors::Result;
use crate::{Diagnostics, Flavor, RpValue, Span, Spanned, Translate, Translator};
use serde::Seri... | code_fim | hard | {
"lang": "rust",
"repo": "reproto/reproto",
"path": "/lib/core/src/attributes.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<F> Attributes<F>
where
F: Flavor,
{
pub fn new(
words: HashMap<String, Span>,
selections: HashMap<String, Spanned<Selection<F>>>,
) -> Attributes<F> {
Attributes { words, selections }
}
/// Take the given selection, removing it in the process.
pub fn t... | code_fim | hard | {
"lang": "rust",
"repo": "reproto/reproto",
"path": "/lib/core/src/attributes.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.