text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> //form lib.rs and save
create_directory_structure("src/", lib_rs).unwrap();
//rustfmt saved files
let files = ["build.rs", "src/lib.rs"].iter().map(|a| PathBuf::from(a));
let mut buf = Vec::<u8>::new();
let mut session = Session::new(Config::default(), Some(&mut buf));
for pa... | code_fim | hard | {
"lang": "rust",
"repo": "lucab/efm32hg-pac",
"path": "/tools/src/bin/gen.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for path in files {
session.format(Input::File(path)).unwrap();
}
set_current_dir("..").unwrap();
remove_dir_all("./src").unwrap_or_else(|err| println!("./src: {} [ignored]", err));
rename(".tmp/build.rs", "./build.rs").unwrap();
rename(".tmp/device.x", "./device.x").unwra... | code_fim | hard | {
"lang": "rust",
"repo": "lucab/efm32hg-pac",
"path": "/tools/src/bin/gen.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lucab/efm32hg-pac path: /tools/src/bin/gen.rs
use form::create_directory_structure;
use rustfmt_nightly::{Config, Input, Session};
use std::env::set_current_dir;
use std::fs::{create_dir_all, read_to_string, remove_dir_all, rename, File};
use std::io::Write;
use std::path::PathBuf;
use svd2rust:... | code_fim | hard | {
"lang": "rust",
"repo": "lucab/efm32hg-pac",
"path": "/tools/src/bin/gen.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: austinschwartz/rust-rosetta path: /src/walk_recursive.rs
// Implements http://rosettacode.org/wiki/Walk_a_directory/Recursively
#![feature(old_path)]
#![feature(old_io)]
#![feature(plugin)]
#![plugin(regex_macros)]
extern crate regex;
<|fim_suffix|>fn walk(path: &Path, regex: &Regex) {
let... | code_fim | medium | {
"lang": "rust",
"repo": "austinschwartz/rust-rosetta",
"path": "/src/walk_recursive.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> let result = match readdir(path) {
Ok(result) => result,
Err(_) => return
};
for subpath in &result {
match subpath.filename_str() {
Some(filename) => {
if regex.is_match(filename) {
println!("{}", subpath.display());
... | code_fim | medium | {
"lang": "rust",
"repo": "austinschwartz/rust-rosetta",
"path": "/src/walk_recursive.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> walk(subpath, regex);
}
}
fn main() {
walk(&Path::new("."), ®ex!(r".*\.rs"));
}<|fim_prefix|>// repo: austinschwartz/rust-rosetta path: /src/walk_recursive.rs
// Implements http://rosettacode.org/wiki/Walk_a_directory/Recursively
#![feature(old_path)]
#![feature(old_io)]
#![feature(p... | code_fim | hard | {
"lang": "rust",
"repo": "austinschwartz/rust-rosetta",
"path": "/src/walk_recursive.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Roba1993/rune path: /tests/src/capture_output.rs
//! Utilities related to testing
use runestick::{ContextError, Module, Panic, Stack, Value, VmError};
use std::io::Write as _;
/// Provide a bunch of `std` functions that can be used during tests to capture output.
pub fn output_redirect_module(... | code_fim | hard | {
"lang": "rust",
"repo": "Roba1993/rune",
"path": "/tests/src/capture_output.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for value in stack.drain_stack_top(args)? {
writeln!(o, "{:?}", value).map_err(VmError::panic)?;
}
stack.push(Value::Unit);
Ok(())
}<|fim_prefix|>// repo: Roba1993/rune path: /tests/src/capture_output.rs
//! Utilities related to testing
use runestick::{ContextError, Module, Pani... | code_fim | medium | {
"lang": "rust",
"repo": "Roba1993/rune",
"path": "/tests/src/capture_output.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
let n = read::<i64>();
let mut maxv = -10_i64.pow(9);
let mut minv = read::<i64>();
for _ in 0..n - 1 {
let r = read::<i64>();
maxv = max(maxv, r - minv);
minv = min(minv, r);
}
println!("{}", maxv)
}<|fim_prefix|>// repo: kazchimo/pro-con pat... | code_fim | hard | {
"lang": "rust",
"repo": "kazchimo/pro-con",
"path": "/src/bin/ALDS1_1_D.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kazchimo/pro-con path: /src/bin/ALDS1_1_D.rs
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_D&lang=ja
use std::cmp::{max, min};
fn read<T: std::str::FromStr>() -> T {
let mut s = String::new();
std::io::stdin().read_line(&mut s).ok();
s.trim().parse().ok().unwr... | code_fim | hard | {
"lang": "rust",
"repo": "kazchimo/pro-con",
"path": "/src/bin/ALDS1_1_D.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut w = self.fa_theta.weights_view_mut();
let alpha = self.alpha.value();
for _ in 0..self.n_updates {
let (_, idx) = argmaxima(self.mu.mapv(|v| v.abs()).as_slice().unwrap());
for j in idx {
unsafe {
let update = alp... | code_fim | hard | {
"lang": "rust",
"repo": "aGiant/robust_trading.icml2019",
"path": "/rsrl/src/prediction/lstd/ilstd.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aGiant/robust_trading.icml2019 path: /rsrl/src/prediction/lstd/ilstd.rs
use crate::{
core::*,
domains::Transition,
fa::{Embedding, VFunction, Parameterised},
geometry::{Space, Matrix, MatrixView, MatrixViewMut},
utils::argmaxima,
};
use ndarray::Axis;
#[allow(non_camel_case_... | code_fim | hard | {
"lang": "rust",
"repo": "aGiant/robust_trading.icml2019",
"path": "/rsrl/src/prediction/lstd/ilstd.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: saf/terminal-size path: /src/unix.rs
extern crate libc;
use std::os::raw::*;
use super::{Width, Height};
#[cfg(target_os="macos")]
const TIOCGWINSZ: c_ulong = 0x40087468;
#[cfg(all(target_env="musl", not(target_os="macos")))]
const TIOCGWINSZ: c_int = 0x00005413;
#[cfg(all(not(target_env="mus... | code_fim | hard | {
"lang": "rust",
"repo": "saf/terminal-size",
"path": "/src/unix.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> use std::process::Command;
use std::process::Stdio;
let output = if cfg!(target_os = "macos") {
Command::new("stty").arg("-f").arg("/dev/stderr").arg("size").stderr(Stdio::inherit()).output().unwrap()
} else {
Command::new("stty").arg("size").arg("-F").arg("/dev/stderr").s... | code_fim | medium | {
"lang": "rust",
"repo": "saf/terminal-size",
"path": "/src/unix.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let output = if cfg!(target_os = "macos") {
Command::new("stty").arg("-f").arg("/dev/stderr").arg("size").stderr(Stdio::inherit()).output().unwrap()
} else {
Command::new("stty").arg("size").arg("-F").arg("/dev/stderr").stderr(Stdio::inherit()).output().unwrap()
};
let stdo... | code_fim | hard | {
"lang": "rust",
"repo": "saf/terminal-size",
"path": "/src/unix.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jakubclark/aoc-2020 path: /day06/src/main.rs
use std::collections::HashSet;
fn main() {
let input = include_str!("../input.txt");
let part1 = solve_part1(input);
println!("Part 1 solution: {}", part1);
let part2 = solve_part2(input);
println!("Part 2 solution: {}", part2);
... | code_fim | hard | {
"lang": "rust",
"repo": "jakubclark/aoc-2020",
"path": "/day06/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>b";
let part1 = solve_part1(input);
assert_eq!(11, part1);
}
#[test]
fn part2_works() {
let input = "abc
a
b
c
ab
ac
a
a
a
a
b";
let part2 = solve_part2(input);
assert_eq!(6, part2);
}<|fim_prefix|>// repo: jakubclark/aoc-2020 path: /day06/src/main.rs
use std::collections::HashSe... | code_fim | hard | {
"lang": "rust",
"repo": "jakubclark/aoc-2020",
"path": "/day06/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nathanfaucett/rs-mat3 path: /src/misc.rs
use approx_eq::ApproxEq;
use num::Num;
use signed::Signed;
use set::identity;
#[inline]
pub fn inverse_mat<'a, 'b, T: Copy + Signed>(
out: &'a mut [T; 9],
m11: T, m12: T, m13: T,
m21: T, m22: T, m23: T,
m31: T, m32: T, m33: T
) -> &'a m... | code_fim | hard | {
"lang": "rust",
"repo": "nathanfaucett/rs-mat3",
"path": "/src/misc.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[inline]
pub fn determinant<'a, 'b, T: Copy + Num>(out: &'b [T; 9]) -> T {
let a = out[0];
let b = out[1];
let c = out[2];
let d = out[3];
let e = out[4];
let f = out[5];
let g = out[6];
let h = out[7];
let i = out[8];
return a * e * i - a * f * h - b * d * i + b *... | code_fim | hard | {
"lang": "rust",
"repo": "nathanfaucett/rs-mat3",
"path": "/src/misc.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/rustc-perf path: /collector/compile-benchmarks/stm32f4-0.14.0/src/stm32f407/can1/tx/tdlr.rs
#[doc = "Register `TDLR` reader"]
pub struct R(crate::R<TDLR_SPEC>);
impl core::ops::Deref for R {
type Target = crate::R<TDLR_SPEC>;
#[inline(always)]
fn deref(&self) -> &Self::Targ... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rustc-perf",
"path": "/collector/compile-benchmarks/stm32f4-0.14.0/src/stm32f407/can1/tx/tdlr.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self.0
}
}
#[doc = "Field `DATA2` writer - DATA2"]
pub struct DATA2_W<'a> {
w: &'a mut W,
}
impl<'a> DATA2_W<'a> {
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub unsafe fn bits(self, value: u8) -> &'a mut W {
self.w.bits = (self.w.bits & !(0xff << 16)) ... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rustc-perf",
"path": "/collector/compile-benchmarks/stm32f4-0.14.0/src/stm32f407/can1/tx/tdlr.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let stdin = io::stdin();
let mut line = String::new();
// Read the lines from stdin.
stdin
.lock()
.read_to_string(&mut line)
.expect("Error reading input: ");
let (board, carts) = lib::parse_board(&line).expect("Could not parse input: ");
let (carts_after, ... | code_fim | medium | {
"lang": "rust",
"repo": "nitnelave/advent_of_code_2018",
"path": "/13/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nitnelave/advent_of_code_2018 path: /13/src/main.rs
extern crate lib;
use std::io;
use std::io::Read;
use std::string::String;
<|fim_suffix|> let stdin = io::stdin();
let mut line = String::new();
// Read the lines from stdin.
stdin
.lock()
.read_to_string(&mut li... | code_fim | medium | {
"lang": "rust",
"repo": "nitnelave/advent_of_code_2018",
"path": "/13/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fujiehuang/leetcode-rust path: /17.letter-combinations-of-a-phone-number.rs
/*
* @lc app=leetcode id=17 lang=rust
*
* [17] Letter Combinations of a Phone Number
*/
// @lc code=start
use std::collections::HashMap;
impl Solution {
pub fn letter_combinations(digits: String) -> Vec<String>... | code_fim | hard | {
"lang": "rust",
"repo": "fujiehuang/leetcode-rust",
"path": "/17.letter-combinations-of-a-phone-number.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for d in digits.chars() {
let mut tmp = vec![];
if let Some(v) = map.get(&d) {
for s in &ans {
for ch in v {
tmp.push(s.clone() + &ch.to_string());
}
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "fujiehuang/leetcode-rust",
"path": "/17.letter-combinations-of-a-phone-number.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yang-dong-dong/rocket-governor path: /src/header.rs
//! The headers used when a [super::RocketGovernor] guarded path responds with TooManyRequests.
use rocket::http;
/// HTTP headers used for rate-limiting.
pub enum Header {
/// Standard header for status 429 Too Many Requests ([RFC 6585](... | code_fim | medium | {
"lang": "rust",
"repo": "yang-dong-dong/rocket-governor",
"path": "/src/header.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match header {
Header::RetryAfter(sec) => http::Header::new(RETRY_AFTER, sec.to_string()),
Header::XRateLimitError(err) => http::Header::new(X_RATELIMIT_ERROR, err),
Header::XRateLimitReset(sec) => http::Header::new(X_RATELIMIT_RESET, sec.to_string()),
}... | code_fim | hard | {
"lang": "rust",
"repo": "yang-dong-dong/rocket-governor",
"path": "/src/header.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Header provides the time in seconds when a request to the route is not rate limited
/// and the rate limiter bucket is full again.
const X_RATELIMIT_RESET: &'static str = "x-ratelimit-reset";
#[doc(hidden)]
impl From<Header> for http::Header<'_> {
fn from(header: Header) -> Self {
match h... | code_fim | hard | {
"lang": "rust",
"repo": "yang-dong-dong/rocket-governor",
"path": "/src/header.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let json = serde_json::to_string(&code).unwrap();
let hash = Sha256::digest(json.as_bytes());
file.write_fmt(format_args!("{:x}\t{}\n", hash, json))?;
return Ok(format!("{:x}", hash));
}
}
#[cfg(all(feature = "stgen"))]
fn main() {
let args: Vec<_> = env::args().co... | code_fim | hard | {
"lang": "rust",
"repo": "thomwiggers/lpn",
"path": "/examples/find_stgen_smalls.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: thomwiggers/lpn path: /examples/find_stgen_smalls.rs
//! Tries to find StGen codes with desirable properties
//!
//! Not directly related to LPN solving
extern crate lpn;
extern crate rand;
#[cfg(feature = "stgen")]
mod program {
use std::env;
use std::fs;
use std::fs::File;
use... | code_fim | hard | {
"lang": "rust",
"repo": "thomwiggers/lpn",
"path": "/examples/find_stgen_smalls.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: project-ela/elfen path: /src/tse.rs
#[repr(C)]
#[derive(Default, Copy, Clone, Debug, PartialEq, Eq)]
pub struct Tse {
pub symbol_index: u64,<|fim_suffix|>ytes());
buf.extend(&self.size.to_le_bytes());
buf.extend(&self.align.to_le_bytes());
}
}<|fim_middle|>
pub offset... | code_fim | hard | {
"lang": "rust",
"repo": "project-ela/elfen",
"path": "/src/tse.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ytes());
buf.extend(&self.size.to_le_bytes());
buf.extend(&self.align.to_le_bytes());
}
}<|fim_prefix|>// repo: project-ela/elfen path: /src/tse.rs
#[repr(C)]
#[derive(Default, Copy, Clone, Debug, PartialEq, Eq)]
pub struct Tse {
pub symbol_index: u64,<|fim_middle|>
pub offset... | code_fim | hard | {
"lang": "rust",
"repo": "project-ela/elfen",
"path": "/src/tse.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn resolve_method_descriptor(descriptor: &str) -> (Vec<String>, String) {
let t = descriptor
.chars()
.into_iter()
.map(|x| x.to_string())
.collect::<Vec<_>>();
let mut params: Vec<String> = vec![];
let mut expect_type: bool = false;
let mut expect_semic... | code_fim | hard | {
"lang": "rust",
"repo": "chundi/azeroth-vm",
"path": "/src/interpreter/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pc
}
pub fn resolve_method_descriptor(descriptor: &str) -> (Vec<String>, String) {
let t = descriptor
.chars()
.into_iter()
.map(|x| x.to_string())
.collect::<Vec<_>>();
let mut params: Vec<String> = vec![];
let mut expect_type: bool = false;
let mut ex... | code_fim | hard | {
"lang": "rust",
"repo": "chundi/azeroth-vm",
"path": "/src/interpreter/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chundi/azeroth-vm path: /src/interpreter/mod.rs
use super::bytecode::*;
use super::mem::metaspace::*;
use super::mem::stack::*;
use super::mem::*;
use bytecode::atom::*;
use std;
use std::sync::atomic::*;
use std::sync::Arc;
pub enum Return {
Word(Slot),
DWord(WideSlot),
Void,
}
pu... | code_fim | hard | {
"lang": "rust",
"repo": "chundi/azeroth-vm",
"path": "/src/interpreter/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bNobo/LearningRust path: /enums/src/main.rs
fn main() {
let home = IpAddr {
kind: IpAddrKind::V4,
address: String::from("127.0.0.1"),
};
let loopback = IpAddr {
kind: IpAddrKind::V6,
address: String::from("::1"),
};
let home = IpAddrV2::V4(12... | code_fim | hard | {
"lang": "rust",
"repo": "bNobo/LearningRust",
"path": "/enums/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> home.ping();
let some_number = Some(5);
let some_string = Some("a string");
let absent_number: Option<i32> = None;
let x = 5;
let y = Some(6);
let z = Some(7);
let sum: i32 = x + match y {
Some(t) => t,
None => 0,
};
if let y = Some(6) {
... | code_fim | medium | {
"lang": "rust",
"repo": "bNobo/LearningRust",
"path": "/enums/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let some_u8_value = 0u8;
match some_u8_value {
1 => println!("one"),
3 => println!("three"),
5 => println!("five"),
7 => println!("seven"),
_ => (),
}
}
#[derive(Debug)]
enum IpAddrKind {
V4,
V6,
}
#[derive(Debug)]
struct IpAddr {
kind: Ip... | code_fim | hard | {
"lang": "rust",
"repo": "bNobo/LearningRust",
"path": "/enums/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> vec![8.585396,41.873571],
vec![8.826011,41.873571],
vec![8.826011,41.971536],
vec![8.585396,41.968222],
vec![8.585396,41.873571]
]],
"type" => "Polygon"
},
"bbox"=> vec![
8.585396,
41.873571,
8.826011,
41.971536
],
"id"=... | code_fim | hard | {
"lang": "rust",
"repo": "Joxit/wof-cli",
"path": "/tests/test.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Joxit/wof-cli path: /tests/test.rs
#[macro_use]
extern crate json;
use json::Null;
use wof::json_to_writer_pretty;
#[test]
pub fn serialize_first_level_wof_geojson_with_null() {
let t = object! {
"type"=> Null,
"properties"=> Null,
"geometry"=> Null,
"bbox"=> Null,
"id"=>... | code_fim | hard | {
"lang": "rust",
"repo": "Joxit/wof-cli",
"path": "/tests/test.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> r#"{
"id": 101748927,
"type": "Feature",
"properties": {
"name:eng_x_preferred":[
"Ajaccio"
],
"name:fra_x_preferred":[
"Ajaccio"
],
"wof:id":101748927,
"wof:lang":[
"fre"
]
},
"bbox": [
8.585396,
41.873571,
8.826011,
41.971536
],
... | code_fim | hard | {
"lang": "rust",
"repo": "Joxit/wof-cli",
"path": "/tests/test.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[tonic::async_trait]
impl test_server::Test for Svc {
async fn unary_call(&self, _: Request<Input>) -> Result<Response<Output>, Status> {
Err(Status::with_details(
Code::ResourceExhausted,
"Too many requests",
Bytes::from_static(... | code_fim | medium | {
"lang": "rust",
"repo": "l4l/tonic",
"path": "/tests/integration_tests/tests/status.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> tokio::time::delay_for(Duration::from_millis(100)).await;
let mut channel = test_client::TestClient::connect("http://127.0.0.1:1337")
.await
.unwrap();
let err = channel
.unary_call(Request::new(Input {}))
.await
.unwrap_err();
assert_eq!(err.mess... | code_fim | hard | {
"lang": "rust",
"repo": "l4l/tonic",
"path": "/tests/integration_tests/tests/status.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: l4l/tonic path: /tests/integration_tests/tests/status.rs
use bytes::Bytes;
use futures_util::FutureExt;
use integration_tests::pb::{test_client, test_server, Input, Output};
use std::time::Duration;
use tokio::sync::oneshot;
use tonic::{transport::Server, Code, Request, Response, Status};
#[tok... | code_fim | hard | {
"lang": "rust",
"repo": "l4l/tonic",
"path": "/tests/integration_tests/tests/status.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let duration = start.elapsed();
eprintln!("Ray tracing took {:.3}s", duration.as_secs_f64());
Ok(pixels)
};
match output {
Sink::File => {
let pixels = trace(&mut diffuse_method).unwrap();
sinks::file::write_to_file(filename.unwrap(), &pixel... | code_fim | hard | {
"lang": "rust",
"repo": "viktorku/wort",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: viktorku/wort path: /src/main.rs
#![allow(clippy::needless_return)]
use std::{io::prelude::*, time::Instant};
use rand::random;
use rayon::prelude::*;
mod core;
use crate::core::{color::Color, material::DiffuseMethod};
mod sinks;
use sinks::Sink;
mod arg;
use arg::{parse_arguments, Args};
... | code_fim | hard | {
"lang": "rust",
"repo": "viktorku/wort",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use super::*;
use tide_testing::TideTestingExt;
#[async_std::test]
async fn test_feature_set_access_control_allow_origin() -> tide::Result<()> {
let app = app(&Config { host: "".to_string() });
assert_eq!(app.get("/_matrix/client/versions").await?... | code_fim | hard | {
"lang": "rust",
"repo": "himanoa/himatrix",
"path": "/client-server-api/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: himanoa/himatrix path: /client-server-api/src/main.rs
use client_server_api::routes::*;
use client_server_api::state::State;
use envconfig::Envconfig;
use tide_tracing::TraceMiddleware;
use tracing::Level;
use tide::{Middleware, Request, Next, Server};
#[derive(Envconfig)]
struct Config {
#... | code_fim | hard | {
"lang": "rust",
"repo": "himanoa/himatrix",
"path": "/client-server-api/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: haverzard/CFF path: /mTSP/src/main.rs
use std::collections::{ BTreeSet, HashMap, VecDeque };
struct Node {
adj: HashMap<String, u32>,
}
fn dp_tsp(nodes: &HashMap<String, Node>, start: &str, mut counter: i32) -> Option<(Vec<String>, u32)> {
let mut memo : HashMap<(BTreeSet<String>, Stri... | code_fim | hard | {
"lang": "rust",
"repo": "haverzard/CFF",
"path": "/mTSP/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut path = Vec::new();
let mut temp = start.to_owned();
let last_entry = memo.get(&(nodes_set.clone(), temp.to_owned()));
while !nodes_set.is_empty() {
match memo.get(&(nodes_set.clone(), temp.to_owned())) {
Some(t) => {
if temp == start && counter >... | code_fim | hard | {
"lang": "rust",
"repo": "haverzard/CFF",
"path": "/mTSP/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // steps in x (right) direction and y (down)-direction
// here is the difference, we don't only try one solution but a list of solutions
let slopes = [
(1, 1),
(3, 1),
(5, 1),
(7, 1),
(1, 2)
];
// the results for each attempt are colle... | code_fim | hard | {
"lang": "rust",
"repo": "Mereep/advent_of_code_2020_rust",
"path": "/src/day03/solution.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // count of hit trees
let mut n_trees = 0;
// We step until we are out of the y span of the wood
while pos_y < n_lines {
if data[pos_y].as_bytes()[pos_x] == '#' as u8 {
n_trees += 1;
}
// move one step
pos_y += dy;
// in x... | code_fim | hard | {
"lang": "rust",
"repo": "Mereep/advent_of_code_2020_rust",
"path": "/src/day03/solution.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Mereep/advent_of_code_2020_rust path: /src/day03/solution.rs
use crate::files::str_to_lines;
pub fn task1() {
let data = str_to_lines(get_input_data());
let n_lines = data.len();
let n_cols = data[0].len();
// steps in x (right) direction and y (down)-direction
le... | code_fim | hard | {
"lang": "rust",
"repo": "Mereep/advent_of_code_2020_rust",
"path": "/src/day03/solution.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>//////////////////////////////////////////////
/// Implements `InterfaceType`, requiring `std::io::Write`
#[repr(C)]
#[derive(StableAbi)]
#[sabi(impl_InterfaceType(IoWrite))]
pub struct IoWriteInterface;
//////////////////////////////////////////////
/// Implements `InterfaceType`, requiring `Send + Sy... | code_fim | hard | {
"lang": "rust",
"repo": "CyberFlameGO/abi_stable_crates",
"path": "/abi_stable/src/erased_types/interfaces.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: CyberFlameGO/abi_stable_crates path: /abi_stable/src/erased_types/interfaces.rs
use super::*;
use std::marker::PhantomData;
/// Implements `InterfaceType`, requiring `Send + Sync + Clone`
#[repr(C)]
#[derive(StableAbi)]
#[sabi(impl_InterfaceType(Send,Sync,Clone))]
pub struct CloneInterface;
//... | code_fim | hard | {
"lang": "rust",
"repo": "CyberFlameGO/abi_stable_crates",
"path": "/abi_stable/src/erased_types/interfaces.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|>
/// Implements `InterfaceType`, requiring `Send + Sync + DoubleEndedIterator<Item = T>`
#[repr(C)]
#[derive(StableAbi)]
#[sabi(impl_InterfaceType(Send,Sync,DoubleEndedIterator))]
pub struct DEIteratorInterface<T>(PhantomData<T>);
impl<T> DEIteratorInterface<T>{
pub const NEW:Self=Self(PhantomData);
... | code_fim | hard | {
"lang": "rust",
"repo": "CyberFlameGO/abi_stable_crates",
"path": "/abi_stable/src/erased_types/interfaces.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ChristopherLR/web-graphics path: /src/scene_objects/two_d/tridown.rs
use wasm_bindgen::JsCast;
use web_sys::WebGl2RenderingContext as GL;
use web_sys::*;
use js_sys::WebAssembly;
use crate::helpers::*;
use crate::input::InputState;
use crate::shaders::{ color_2d_frag, color_2d_vert };
use crate:... | code_fim | hard | {
"lang": "rust",
"repo": "ChristopherLR/web-graphics",
"path": "/src/scene_objects/two_d/tridown.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn update_self(&mut self, dt: f32, input: &InputState) {
// self.matrices.rotate_x(0.01);
self.matrices.rotate_y(0.01);
// log(&format!("{:?}", self.matrices.get_rotation()))
// self.matrices.rotate_z(0.01);
}
fn draw_self(&mut self, gl: Option<&GL>, camera: &PerspectiveCamera){
... | code_fim | hard | {
"lang": "rust",
"repo": "ChristopherLR/web-graphics",
"path": "/src/scene_objects/two_d/tridown.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Checks that converting FE to the hex form and back results
/// in the same FE.
#[test]
fn fe_hex_roundtrip() {
let mut rng = XorShiftRng::from_seed([1, 2, 3, 4]);
let fr = Fr::rand(&mut rng);
let encoded_fr = fr.to_hex();
let decoded_fr = Fr::from_hex(... | code_fim | hard | {
"lang": "rust",
"repo": "Dima0825/react-native-zksync-ios-reviewer",
"path": "/zksync/core/lib/crypto/src/convert.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use super::*;
use crate::rand::{Rand, SeedableRng, XorShiftRng};
use crate::Fr;
/// Checks that converting FE to the hex form and back results
/// in the same FE.
#[test]
fn fe_hex_roundtrip() {
let mut rng = XorShiftRng::from_seed([1, 2, 3, 4... | code_fim | hard | {
"lang": "rust",
"repo": "Dima0825/react-native-zksync-ios-reviewer",
"path": "/zksync/core/lib/crypto/src/convert.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Dima0825/react-native-zksync-ios-reviewer path: /zksync/core/lib/crypto/src/convert.rs
use crate::franklin_crypto::bellman::pairing::ff::{PrimeField, PrimeFieldRepr};
/// Extension trait denoting common conversion method for field elements.
pub trait FeConvert: PrimeField {
/// Converts the... | code_fim | hard | {
"lang": "rust",
"repo": "Dima0825/react-native-zksync-ios-reviewer",
"path": "/zksync/core/lib/crypto/src/convert.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a, T: 'a + Type, C: Color> ImageRef<'a, T, C> {
/// Create a new ImageRef with the given dimensions and data
///
/// Note: this functions does not do any bounds checking regarding the specified size and
/// length of the data
pub fn new(width: usize, height: usize, data: &'a mut ... | code_fim | medium | {
"lang": "rust",
"repo": "kabergstrom/image2-rs",
"path": "/src/image_ref.rs",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kabergstrom/image2-rs path: /src/image_ref.rs
use crate::color::Color;
use crate::image::Image;
use crate::ty::Type;
use std::marker::PhantomData;
/// Image implementation backed by a mutable array reference
#[derive(Debug, PartialEq)]
pub struct ImageRef<'a, T: 'a + Type, C: Color> {
widt... | code_fim | medium | {
"lang": "rust",
"repo": "kabergstrom/image2-rs",
"path": "/src/image_ref.rs",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|>use crate::Options;
#[cfg(test)]
mod test {
use super::*;
use crate::Options;
#[derive(Options)]
#[repr(C)]
struct TestOptions {
#[option(desc = "The first test option")]
opt1: Bool,
#[option(desc = "The second test option", default = 5)]
opt2: UInt,
... | code_fim | hard | {
"lang": "rust",
"repo": "twitter/pelikan",
"path": "/legacy/deps/ccommon/rust/ccommon-rs/src/option/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Safe because implementing the trait means that layout
// is guaranteed.
unsafe { slice::from_raw_parts_mut(self.as_mut_ptr(), Self::num_options()) }
}
/// Print a description of all options in the current object
/// given using the default value, name, and descripti... | code_fim | hard | {
"lang": "rust",
"repo": "twitter/pelikan",
"path": "/legacy/deps/ccommon/rust/ccommon-rs/src/option/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: twitter/pelikan path: /legacy/deps/ccommon/rust/ccommon-rs/src/option/mod.rs
// ccommon - a cache common library.
// Copyright (C) 2019 Twitter, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You m... | code_fim | hard | {
"lang": "rust",
"repo": "twitter/pelikan",
"path": "/legacy/deps/ccommon/rust/ccommon-rs/src/option/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: BlackbirdHQ/defmt-persist path: /src/pseudo_flash.rs
#![cfg(test)]
use embedded_storage::{ReadStorage, Storage};
use std::collections::HashSet;
#[derive(Default)]
pub struct PseudoFlashStorage<'a> {
pub buf: &'a mut [u8],
pub word_set: HashSet<usize>,
}
impl<'a> ReadStorage for Pseudo... | code_fim | hard | {
"lang": "rust",
"repo": "BlackbirdHQ/defmt-persist",
"path": "/src/pseudo_flash.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let addr = offset as usize;
// It isn't allowed by FLASH to write to the same word twice
for wi in (addr..addr + bytes.len()).step_by(8).map(|a| a / 8) {
if self.word_set.contains(&wi) {
return Err(());
} else {
self.word_set... | code_fim | medium | {
"lang": "rust",
"repo": "BlackbirdHQ/defmt-persist",
"path": "/src/pseudo_flash.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl crate::ff::SqrtField for Fr {
fn legendre(&self) -> crate::ff::LegendreSymbol {
let s = self.pow([0u64, 0u64, 9223372036854775808u64, 288230376151711752u64]);
if s == Self::zero() {
crate::ff::LegendreSymbol::Zero
} else if s == Self::one() {
crate:... | code_fim | hard | {
"lang": "rust",
"repo": "matter-labs/bellman",
"path": "/src/plonk/transparent_engine/proth.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: matter-labs/bellman path: /src/plonk/transparent_engine/proth.rs
nline(always)]
fn rand<R: ::rand::Rng>(rng: &mut R) -> Self {
FrRepr(rng.gen())
}
}
impl ::std::fmt::Display for FrRepr {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
write!(f, "0... | code_fim | hard | {
"lang": "rust",
"repo": "matter-labs/bellman",
"path": "/src/plonk/transparent_engine/proth.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: matter-labs/bellman path: /src/plonk/transparent_engine/proth.rs
last = tmp;
}
}
#[inline(always)]
fn shl(&mut self, mut n: u32) {
if n as usize >= 64 * 4usize {
*self = Self::from(0);
return;
}
while n >= 64 {
... | code_fim | hard | {
"lang": "rust",
"repo": "matter-labs/bellman",
"path": "/src/plonk/transparent_engine/proth.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>bitflags::bitflags! {
/// Anchor bitflags, describing how the layers surface should be positioned and sized
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct Anchor: u32 {
/// The top edge of the anchor rectangle
const TOP = 1;
/// The bottom edge of the anc... | code_fim | hard | {
"lang": "rust",
"repo": "Smithay/smithay",
"path": "/src/wayland/shell/wlr_layer/types.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Smithay/smithay path: /src/wayland/shell/wlr_layer/types.rs
use std::{cmp::Ordering, convert::TryFrom};
use wayland_protocols_wlr::layer_shell::v1::server::{zwlr_layer_shell_v1, zwlr_layer_surface_v1};
use wayland_server::WEnum;
/// Available layers for surfaces
///
/// These values indicate w... | code_fim | hard | {
"lang": "rust",
"repo": "Smithay/smithay",
"path": "/src/wayland/shell/wlr_layer/types.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match v.cmp(&0) {
Ordering::Greater => Self::Exclusive(v as u32),
Ordering::Equal => Self::Neutral,
Ordering::Less => Self::DontCare,
}
}
}
impl From<ExclusiveZone> for i32 {
fn from(z: ExclusiveZone) -> i32 {
match z {
Exclu... | code_fim | hard | {
"lang": "rust",
"repo": "Smithay/smithay",
"path": "/src/wayland/shell/wlr_layer/types.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
/*fn printStatusMap(processMap: BTreeMap<isize,Process>) {
let tmpString = String::new();
for (_tmp,processes) in processMap {
tmpString.push(processes.toString());
tmpString.push('\n');
}
println!("{}",tmpString);
}
*/
fn parseProc() -> Vec<String> {
let path = Path::new("/proc");
let ... | code_fim | hard | {
"lang": "rust",
"repo": "Church-/Psyop",
"path": "/src/run.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Church-/Psyop path: /src/run.rs
extern crate regex;
mod process;
use regex::Regex;
use std::path::{Path, PathBuf};
use std::collections::BTreeMap;
use std::fs::File;
use std::io::prelude::*;
use process::Process;
fn readFile(filePath: &str) -> String {
let mut tmpFile = File::open(filePath... | code_fim | hard | {
"lang": "rust",
"repo": "Church-/Psyop",
"path": "/src/run.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>s2;
pub mod hill_climbing;
pub mod orthgonal;
pub mod physical;
pub mod shrink;<|fim_prefix|>// repo: seikichi/icfpc2021 path: /solver/src/solvers/mod.rs
pub mod adjust;
pub mod annealing;
pub <|fim_middle|>mod annealing3;
pub mod dfs;
pub mod df | code_fim | easy | {
"lang": "rust",
"repo": "seikichi/icfpc2021",
"path": "/solver/src/solvers/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: seikichi/icfpc2021 path: /solver/src/solvers/mod.rs
pub mod adjust;
pub mod annealing;
pub <|fim_suffix|>s2;
pub mod hill_climbing;
pub mod orthgonal;
pub mod physical;
pub mod shrink;<|fim_middle|>mod annealing3;
pub mod dfs;
pub mod df | code_fim | easy | {
"lang": "rust",
"repo": "seikichi/icfpc2021",
"path": "/solver/src/solvers/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: seikichi/icfpc2021 path: /solver/src/solvers/mod.rs
pub mod adjust;
pub mod annealing;
pub mod annealing3;
pub mod dfs;
pub mod df<|fim_suffix|>gonal;
pub mod physical;
pub mod shrink;<|fim_middle|>s2;
pub mod hill_climbing;
pub mod orth | code_fim | easy | {
"lang": "rust",
"repo": "seikichi/icfpc2021",
"path": "/solver/src/solvers/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Source for Directory {
fn modified(&self, path: &str) -> Result<u64> {
#[cfg(feature = "profiler")]
profile_scope!("dir_modified_asset");
use std::fs::metadata;
let path = self.path(path);
Ok(metadata(&path)
.chain_err(|| format!("Failed to fe... | code_fim | hard | {
"lang": "rust",
"repo": "Binero/amethyst",
"path": "/amethyst_assets/src/source/dir.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Binero/amethyst path: /amethyst_assets/src/source/dir.rs
use std::fs::File;
use std::path::PathBuf;
use std::time::UNIX_EPOCH;
use {ErrorKind, Result, ResultExt};
use source::Source;
/// Directory source.
///
/// Please note that there is a default directory source
/// inside the `Loader`, whi... | code_fim | medium | {
"lang": "rust",
"repo": "Binero/amethyst",
"path": "/amethyst_assets/src/source/dir.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let retval = real!(open)(path_resolved, oflag);
//println!("open({}) -> retval {}", path_resolved_str, retval);
return retval;
}
}
// statx is not called by node (never?)
// node calls syscall(SYS_statx, ...)
// https://stackoverflow.com/questions/49314057/how-to-find-out-wh... | code_fim | hard | {
"lang": "rust",
"repo": "milahu/nodejs-hide-symlinks",
"path": "/src/lib.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: milahu/nodejs-hide-symlinks path: /src/lib.rs
/*
nodejs-hide-symlinks
hide symlinks from nodejs
to implement a symlinked machine-level global NPM store on nixos (and others)
license: CC0-1.0, author: milahu
based on
https://github.com/nodejs/node/blob/master/deps/uv/src/unix/linux-syscalls.c ... | code_fim | hard | {
"lang": "rust",
"repo": "milahu/nodejs-hide-symlinks",
"path": "/src/lib.rs",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>// statx is not called by node (never?)
// node calls syscall(SYS_statx, ...)
// https://stackoverflow.com/questions/49314057/how-to-find-out-what-functions-to-intercept-with-ld-preload
hook! {
unsafe fn statx(
dirfd: libc::c_int,
pathname: *const libc::c_char,
flags: libc::c_... | code_fim | hard | {
"lang": "rust",
"repo": "milahu/nodejs-hide-symlinks",
"path": "/src/lib.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>cted: String::from("a borrowed byte array"),
found: String::from("the bytes \"AAECAw==\""),
},
position: ron::error::Position { line: 1, col: 10 },
})
);
}<|fim_prefix|>// repo: ron-rs/ron path: /tests/462_bytes.rs
#[test]
fn test_deserialise_byte_slice... | code_fim | hard | {
"lang": "rust",
"repo": "ron-rs/ron",
"path": "/tests/462_bytes.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ron-rs/ron path: /tests/462_bytes.rs
#[test]
fn test_deserialise_byte_slice() {
let val: &[u8] = &[0_u8, 1_u8, 2_u8, 3_u8];
let ron = ron::to_string(val).unwrap();
assert_eq!(ron, "[0,1,2,3]");
// deserialising a byte slice fr<|fim_suffix|>ation never serialises to a string
... | code_fim | hard | {
"lang": "rust",
"repo": "ron-rs/ron",
"path": "/tests/462_bytes.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>ation never serialises to a string
assert_eq!(
ron::from_str::<&[u8]>(&ron),
Err(ron::error::SpannedError {
code: ron::error::Error::InvalidValueForType {
expected: String::from("a borrowed byte array"),
found: String::from("the bytes \"AAECA... | code_fim | hard | {
"lang": "rust",
"repo": "ron-rs/ron",
"path": "/tests/462_bytes.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: CaulyKan/leetcode path: /矩形重叠/tests/tests.rs
extern crate leetcode;
use leetcode::Solution;
<|fim_suffix|> let result = Solution::is_rectangle_overlap(vec![0, 0, 2, 2], vec![1, 1, 3, 3]);
assert_eq!(true, result);
}<|fim_middle|>#[test]
fn test1() {
| code_fim | easy | {
"lang": "rust",
"repo": "CaulyKan/leetcode",
"path": "/矩形重叠/tests/tests.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let result = Solution::is_rectangle_overlap(vec![0, 0, 2, 2], vec![1, 1, 3, 3]);
assert_eq!(true, result);
}<|fim_prefix|>// repo: CaulyKan/leetcode path: /矩形重叠/tests/tests.rs
extern crate leetcode;
use leetcode::Solution;
<|fim_middle|>#[test]
fn test1() {
| code_fim | easy | {
"lang": "rust",
"repo": "CaulyKan/leetcode",
"path": "/矩形重叠/tests/tests.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Into<Vec<u8>> for FileVector {
fn into(self) -> Vec<u8> {
let mut buf: Vec<u8> = Vec::new();
for e in self.entries.iter() {
for b in e.0.to_le_bytes().to_vec() {
buf.push(b);
}
for b in e.1.to_le_bytes().to_vec() {
... | code_fim | hard | {
"lang": "rust",
"repo": "joxer/Oggetto",
"path": "/src/volume_manager.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: joxer/Oggetto path: /src/volume_manager.rs
use crate::block::Block;
use crate::chunk::{chunk_block_serialize, Chunk};
use crate::error::VolumeError;
use crate::redundant_file::RedundantFile;
use crate::UUID;
use std::fs::{File, OpenOptions};
use std::io::{Read, Seek, SeekFrom, Write};
const fil... | code_fim | hard | {
"lang": "rust",
"repo": "joxer/Oggetto",
"path": "/src/volume_manager.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(ref mut dotfiles) = config.dotfiles {
dotfiles.push(dotfile);
}
// Save new config
let new_config = toml::to_string(&config)?;
if let Err(e) = fs::File::create(common::resolve_path(config_path, None)?)
.and_then(|mut f| f.write_all(new_config.as_bytes())... | code_fim | hard | {
"lang": "rust",
"repo": "chrisduerr/dotfiler",
"path": "/src/add_template.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chrisduerr/dotfiler path: /src/add_template.rs
use std::io::{self, Write};
use std::{fs, path};
use toml;
use filesystem;
use common;
use error;
pub fn add_template(config_path: &str,
file_path: &str,
new_name: Option<&str>,
templatin... | code_fim | hard | {
"lang": "rust",
"repo": "chrisduerr/dotfiler",
"path": "/src/add_template.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Save new config
let new_config = toml::to_string(&config)?;
if let Err(e) = fs::File::create(common::resolve_path(config_path, None)?)
.and_then(|mut f| f.write_all(new_config.as_bytes())) {
let mut msg = format!("Unable to save new config:\n{}", e);
if let Err(e... | code_fim | hard | {
"lang": "rust",
"repo": "chrisduerr/dotfiler",
"path": "/src/add_template.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mrshoe/sol path: /rust/src/main.rs
extern crate image;
extern crate regex;
use std::fs::File;
use std::io;
use std::io::Read;
use std::path::Path;
use std::env;
mod vector;
mod ray;
mod camera;
mod scene;
mod sceneobject;
mod triangle;
mod sphere;
mod light;
mod parser;
mod material;
use pars... | code_fim | hard | {
"lang": "rust",
"repo": "mrshoe/sol",
"path": "/rust/src/main.rs",
"mode": "psm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|> match parse_scene(scenedef) {
Ok(scene) => {
let imgbuf = scene.raytrace();
let ref mut fout = File::create(&Path::new("sol.png")).unwrap();
let _ = image::ImageRgb8(imgbuf).save(fout, image::PNG);
},
Err(s) => println!("{}", s),
}
}
fn... | code_fim | hard | {
"lang": "rust",
"repo": "mrshoe/sol",
"path": "/rust/src/main.rs",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self.0
}
}
#[doc = "Field `gpdac_en` writer - "]
pub struct GPDAC_EN_W<'a> {
w: &'a mut W,
}
impl<'a> GPDAC_EN_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[i... | code_fim | hard | {
"lang": "rust",
"repo": "ehntoo/bl702-pac",
"path": "/src/gpip/gpdac_config.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ehntoo/bl702-pac path: /src/gpip/gpdac_config.rs
#[doc = "Register `gpdac_config` reader"]
pub struct R(crate::R<GPDAC_CONFIG_SPEC>);
impl core::ops::Deref for R {
type Target = crate::R<GPDAC_CONFIG_SPEC>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "ehntoo/bl702-pac",
"path": "/src/gpip/gpdac_config.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: EFanZh/LeetCode path: /src/problem_0990_satisfiability_of_equality_equations/mod.rs
pub mod bfs;
pub trait Solution {
fn equations_possible(equations: Vec<String>) -> bool;
}
#[cfg(test)]
mod tests {
use super::Solution;
<|fim_suffix|> for (equations, expected) in test_cases {
... | code_fim | hard | {
"lang": "rust",
"repo": "EFanZh/LeetCode",
"path": "/src/problem_0990_satisfiability_of_equality_equations/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn run<S: Solution>() {
let test_cases = [
(&["a==b", "b!=a"] as &[_], false),
(&["b==a", "a==b"], true),
(&["a!=a"], false),
(&["c==c", "b==d", "x!=z"], true),
];
for (equations, expected) in test_cases {
assert_... | code_fim | medium | {
"lang": "rust",
"repo": "EFanZh/LeetCode",
"path": "/src/problem_0990_satisfiability_of_equality_equations/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.