text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> #[inline]
fn debug_abs_tol(&self, other: &Self, tol: &Self) -> Self {
Self {
#(#abs_eps_fields,)*
}
}
#[inline]
fn debug_rmax_tol(&self, other: &Self, tol: &Self) -> Self {
Self... | code_fim | hard | {
"lang": "rust",
"repo": "jtempest/float_eq-rs",
"path": "/float_eq_derive/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jtempest/float_eq-rs path: /float_eq_derive/src/lib.rs
cro::TokenStream,
item: proc_macro::TokenStream,
) -> proc_macro::TokenStream {
let args = parse_macro_input!(args as syn::AttributeArgs);
let item = parse_macro_input!(item as syn::DeriveInput);
expand_derive_float_eq(args,... | code_fim | hard | {
"lang": "rust",
"repo": "jtempest/float_eq-rs",
"path": "/float_eq_derive/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let info = TimerInfo::new(data, &mut metadata);
assert!(info.is_past_due);
assert_eq!(
info.schedule_status.last.to_rfc3339(),
"0001-01-01T00:00:00+00:00"
);
assert_eq!(
info.schedule_status.next.to_rfc3339(),
"2018-... | code_fim | hard | {
"lang": "rust",
"repo": "rtyler/azure-functions-rs",
"path": "/azure-functions/src/bindings/timer_info.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> const JSON: &'static str = r#"{"ScheduleStatus":{"Last":"0001-01-01T00:00:00","Next":"2018-07-24T23:24:00-07:00","LastUpdated":"0001-01-01T00:00:00"},"IsPastDue":true}"#;
let mut data = protocol::TypedData::new();
data.set_json(JSON.to_string());
let mut metadata = HashMa... | code_fim | hard | {
"lang": "rust",
"repo": "rtyler/azure-functions-rs",
"path": "/azure-functions/src/bindings/timer_info.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rtyler/azure-functions-rs path: /azure-functions/src/bindings/timer_info.rs
use crate::rpc::protocol;
use crate::timer::ScheduleStatus;
use serde_derive::Deserialize;
use serde_json::from_str;
use std::collections::HashMap;
/// Represents the timer information from a timer trigger binding.
///
... | code_fim | hard | {
"lang": "rust",
"repo": "rtyler/azure-functions-rs",
"path": "/azure-functions/src/bindings/timer_info.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mulimoen/hdf5-rust path: /hdf5/src/error.rs
use std::convert::Infallible;
use std::error::Error as StdError;
use std::fmt;
use std::io;
use std::ops::Deref;
use std::panic;
use std::ptr::{self, addr_of_mut};
use ndarray::ShapeError;
#[cfg(not(feature = "1.10.0"))]
use hdf5_sys::h5::hssize_t;
u... | code_fim | hard | {
"lang": "rust",
"repo": "mulimoen/hdf5-rust",
"path": "/hdf5/src/error.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Expands the error stack to a format which is easier to handle
// known HDF5 bug: H5Eget_msg() used in this function may corrupt
// the current stack, so we use self over &self
pub fn expand(self) -> Result<ExpandedErrorStack> {
struct CallbackData {
stack: ExpandedE... | code_fim | hard | {
"lang": "rust",
"repo": "mulimoen/hdf5-rust",
"path": "/hdf5/src/error.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Clone, Debug)]
pub struct ErrorFrame {
desc: String,
func: String,
major: String,
minor: String,
description: String,
}
impl ErrorFrame {
pub(crate) fn new(desc: &str, func: &str, major: &str, minor: &str) -> Self {
Self {
desc: desc.into(),
... | code_fim | hard | {
"lang": "rust",
"repo": "mulimoen/hdf5-rust",
"path": "/hdf5/src/error.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: qiwei9743/leetcode_rs path: /src/orig/66.plus-one.rs
/*
* @lc app=leetcode id=66 lang=rust
*
* [66] Plus One
*
* https://leetcode.com/problems/plus-one/description/
*
* algorithms
* Easy (41.57%)
* Total Accepted: 467.1K
* Total Submissions: 1.1M
* Testcase Example: '[1,2,3]'
*
... | code_fim | hard | {
"lang": "rust",
"repo": "qiwei9743/leetcode_rs",
"path": "/src/orig/66.plus-one.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>he array represents the integer 123.
*
*
* Example 2:
*
*
* Input: [4,3,2,1]
* Output: [4,3,2,2]
* Explanation: The array represents the integer 4321.
*
*/
#[allow(dead_code)]
#[cfg(feature = "local")]
struct Solution;
impl Solution {
#[allow(dead_code)]
pub fn plus_one(digits: Vec... | code_fim | hard | {
"lang": "rust",
"repo": "qiwei9743/leetcode_rs",
"path": "/src/orig/66.plus-one.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: NingLin-P/sled path: /src/node.rs
use std::{cmp::Ordering, fmt, ops::Bound};
use crate::Lazy;
use super::*;
#[derive(Clone, PartialEq, Serialize, Deserialize)]
pub(crate) struct Node {
pub(crate) data: Data,
pub(crate) next: Option<PageId>,
pub(crate) lo: IVec,
pub(crate) hi: ... | code_fim | hard | {
"lang": "rust",
"repo": "NingLin-P/sled",
"path": "/src/node.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub(crate) fn should_split(&self) -> bool {
let threshold = if cfg!(any(test, feature = "lock_free_delays")) {
2
} else if self.data.is_index() {
256
} else {
16
};
let size_checks = self.data.len() > threshold;
let s... | code_fim | hard | {
"lang": "rust",
"repo": "NingLin-P/sled",
"path": "/src/node.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>ber: String,
pub telephone: String,
pub is_banned: bool,
}
#[derive(AsChangeset, Default)]
#[table_name = "users"]
pub struct UpdateUser {
pub name: Option<String>,
pub gender: Option<String>,
pub id_number: Option<String>,
pub birthday: Option<NaiveDate>,
pub telephone: Optio... | code_fim | medium | {
"lang": "rust",
"repo": "PepcyCh/se-backend",
"path": "/src/models/users.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PepcyCh/se-backend path: /src/models/users.rs
use crate::schema::users;
use chrono::NaiveDate;
#[derive(Queryable, Insertable, Identifiable)]
#[primary_key(username)]
#[table_name = "users"]
pub struct U<|fim_suffix|>e: Option<String>,
pub gender: Option<String>,
pub id_number: Option<S... | code_fim | hard | {
"lang": "rust",
"repo": "PepcyCh/se-backend",
"path": "/src/models/users.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>e: Option<String>,
pub gender: Option<String>,
pub id_number: Option<String>,
pub birthday: Option<NaiveDate>,
pub telephone: Option<String>,
}<|fim_prefix|>// repo: PepcyCh/se-backend path: /src/models/users.rs
use crate::schema::users;
use chrono::NaiveDate;
#[derive(Queryable, Inserta... | code_fim | hard | {
"lang": "rust",
"repo": "PepcyCh/se-backend",
"path": "/src/models/users.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl NomadConfigLeaseInput {
pub fn new() -> NomadConfigLeaseInput {
NomadConfigLeaseInput {
max_ttl: None,
ttl: None,
}
}
}<|fim_prefix|>// repo: pbar1/vault-rs path: /vault/src/models/nomad_config_lease_input.rs
/*
* HashiCorp Vault API
*
* HTTP API th... | code_fim | hard | {
"lang": "rust",
"repo": "pbar1/vault-rs",
"path": "/vault/src/models/nomad_config_lease_input.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pbar1/vault-rs path: /vault/src/models/nomad_config_lease_input.rs
/*
* HashiCorp Vault API
*
* HTTP API that gives you full access to Vault. All API routes are prefixed with `/v1/`.
*
* The version of the OpenAPI document: 1.6.0
*
* Generated by: https://openapi-generator.tech
*/
<... | code_fim | hard | {
"lang": "rust",
"repo": "pbar1/vault-rs",
"path": "/vault/src/models/nomad_config_lease_input.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Execution for CADDI14SPN {
fn execute(&self, p: &mut Processor) -> Result<(), Exception> {
p.state().check_extension('c')?;
if self.imm(p.state().ir()) == 0 {
return Err(Exception::IllegalInsn(*p.state().ir()));
}
let imm_2: RegT = ((self.imm(p.state().... | code_fim | hard | {
"lang": "rust",
"repo": "chyyuu/rv-arch-lab-terminus",
"path": "/src/processor/extensions/c/insns.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chyyuu/rv-arch-lab-terminus path: /src/processor/extensions/c/insns.rs
().xreg(rs1_addr), 32));
let rs2: Wrapping<RegT> = Wrapping(sext(imm, 6));
let rd = rd_addr;
let value = sext((rs1 + rs2).0, 32) & p.state().config().xlen.mask();
let pc = *p.state().pc() + 2;
... | code_fim | hard | {
"lang": "rust",
"repo": "chyyuu/rv-arch-lab-terminus",
"path": "/src/processor/extensions/c/insns.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> p.state().check_extension('c')?;
//cnop
if self.rd(p.state().ir()) == 0 && self.imm(p.state().ir()) == 0 {
self.execute_c_nop(p)?
} else {
self.execute_c_addi(p)?
}
let pc = *p.state().pc() + 2;
p.state_mut().set_pc(pc);
... | code_fim | hard | {
"lang": "rust",
"repo": "chyyuu/rv-arch-lab-terminus",
"path": "/src/processor/extensions/c/insns.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ahouts/math166-assignment2 path: /src/mat.rs
use crate::norm::Norm;
use std::fmt;
use std::ops::{Mul, Sub};
#[derive(Debug, Clone)]
// representation of a row operation
pub enum RowOperation {
Swap(usize, usize),
Cmb { src: usize, scale: f64, dest: usize },
Scale { row: usize, scale... | code_fim | hard | {
"lang": "rust",
"repo": "ahouts/math166-assignment2",
"path": "/src/mat.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(self.cols(), rhs.rows());
let mut res = Mat::new(self.rows(), rhs.cols());
for r in 0..res.rows() {
for c in 0..res.cols() {
res.set(
r,
c,
self.iter_row(r)
.z... | code_fim | hard | {
"lang": "rust",
"repo": "ahouts/math166-assignment2",
"path": "/src/mat.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // calculate k for the matrix, given its inverse
pub fn k<N: Norm>(&self, inv: &Mat) -> f64 {
N::norm(self) * N::norm(&inv)
}
// maximum magnitude term in matrix
pub fn max(&self) -> f64 {
self.data
.iter()
.map(|v| f64::abs(*v))
.fo... | code_fim | hard | {
"lang": "rust",
"repo": "ahouts/math166-assignment2",
"path": "/src/mat.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Foo for FooStruct {
//~^ ERROR overflow evaluating the requirement `<FooStruct as Foo>::A`
type A = <FooStruct as Foo>::A;
//~^ ERROR overflow evaluating the requirement `<FooStruct as Foo>::A`
}
fn main() {}<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/issues/is... | code_fim | easy | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/issues/issue-21946.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/issues/issue-21946.rs
trait Foo {
type A;
}
<|fim_suffix|>impl Foo for FooStruct {
//~^ ERROR overflow evaluating the requirement `<FooStruct as Foo>::A`
type A = <FooStruct as Foo>::A;
//~^ ERROR overflow evaluating the requirement... | code_fim | easy | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/issues/issue-21946.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hitomi4vv/aizu-online-judge path: /introduction/ITP1_3_C-Swapping Two Numbers.rs
use std::io::*;
fn main() {
let stdin = stdin();
for line in std<|fim_suffix|>space().map(|s| s.parse::<i32>().unwrap()).collect();
if l == [0, 0] { break; }
l.sort();
println!("{} {}", l[0], l[1]);
... | code_fim | medium | {
"lang": "rust",
"repo": "hitomi4vv/aizu-online-judge",
"path": "/introduction/ITP1_3_C-Swapping Two Numbers.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> 0] { break; }
l.sort();
println!("{} {}", l[0], l[1]);
}
}<|fim_prefix|>// repo: hitomi4vv/aizu-online-judge path: /introduction/ITP1_3_C-Swapping Two Numbers.rs
use std::io::*;
fn main() {
let stdin = stdin();
for line in std<|fim_middle|>in.lock().lines() {
let mut l: Vec<_> = line.u... | code_fim | medium | {
"lang": "rust",
"repo": "hitomi4vv/aizu-online-judge",
"path": "/introduction/ITP1_3_C-Swapping Two Numbers.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: colelawrence/gluon path: /tests/error.rs
extern crate env_logger;
extern crate gluon;
mod support;
use gluon::Compiler;
<|fim_suffix|> let _ = ::env_logger::init();
let vm = support::make_vm();
let text = r#"abc"#;
let result = Compiler::new()
.load_script_async(&vm, "t... | code_fim | easy | {
"lang": "rust",
"repo": "colelawrence/gluon",
"path": "/tests/error.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: colelawrence/gluon path: /tests/error.rs
extern crate env_logger;
extern crate gluon;
<|fim_suffix|>#[test]
fn dont_panic_when_error_span_is_at_eof() {
let _ = ::env_logger::init();
let vm = support::make_vm();
let text = r#"abc"#;
let result = Compiler::new()
.load_scri... | code_fim | easy | {
"lang": "rust",
"repo": "colelawrence/gluon",
"path": "/tests/error.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>use gluon::Compiler;
#[test]
fn dont_panic_when_error_span_is_at_eof() {
let _ = ::env_logger::init();
let vm = support::make_vm();
let text = r#"abc"#;
let result = Compiler::new()
.load_script_async(&vm, "test", text)
.sync_or_error();
assert!(result.is_err());
}<|fi... | code_fim | easy | {
"lang": "rust",
"repo": "colelawrence/gluon",
"path": "/tests/error.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pkornecki/rustconv path: /src/output.rs
use chrono::{Duration, NaiveDate};
use serde::Serialize;
use crate::hotel::HotelMap;
use crate::input::InputRow;
/// A struct defining a single row from in the output file.
#[derive(Debug, Serialize, PartialEq)]
pub struct OutputRow<'a> {
#[serde(ren... | code_fim | medium | {
"lang": "rust",
"repo": "pkornecki/rustconv",
"path": "/src/output.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Get the checkin date as a String.
///
/// If the argument is not a valid date, "???" is returned.
fn get_checkin(checkin: &str) -> String {
if let Ok(date) = NaiveDate::parse_from_str(checkin, "%Y%m%d") {
format!("{}", date)
} else {
eprintln!("e... | code_fim | hard | {
"lang": "rust",
"repo": "pkornecki/rustconv",
"path": "/src/output.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: betrusted-io/xous-core path: /services/llio/src/i2c/mod.rs
#![cfg_attr(not(target_os = "none"), allow(dead_code))]
#![cfg_attr(not(target_os = "none"), allow(unused_imports))]
#![cfg_attr(not(target_os = "none"), allow(unused_variables))]
<|fim_suffix|>#[cfg(any(feature="precursor", feature="re... | code_fim | medium | {
"lang": "rust",
"repo": "betrusted-io/xous-core",
"path": "/services/llio/src/i2c/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(any(feature="precursor", feature="renode"))]
mod hardware;
#[cfg(any(feature="precursor", feature="renode"))]
pub(crate) use crate::i2c::hardware::*;<|fim_prefix|>// repo: betrusted-io/xous-core path: /services/llio/src/i2c/mod.rs
#![cfg_attr(not(target_os = "none"), allow(dead_code))]
#![cfg_attr(... | code_fim | medium | {
"lang": "rust",
"repo": "betrusted-io/xous-core",
"path": "/services/llio/src/i2c/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut body = Vec::new();
response.copy_to(&mut body).unwrap();
// Unpack the .tar.gz archive
let gz = GzDecoder::new(body.as_slice());
let mut tar = Archive::new(gz);
tar.unpack(&external_lib_dir.path())
.expect("Unpacking tar threw error.");
build_fetched_crate(&lib_so_search_path, &... | code_fim | hard | {
"lang": "rust",
"repo": "Passeriform/GodWit-Daemon",
"path": "/dyn_compile.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Passeriform/GodWit-Daemon path: /dyn_compile.rs
// This utility is not-so-light more-or-less verbatim https://github.com/auxoncorp/cargo-5730
use flate2::read::GzDecoder;
use glob::glob;
use std::error::Error;
use std::{env, fs, path, process};
use tar::Archive;
use tempfile::tempdir;
use toml:... | code_fim | hard | {
"lang": "rust",
"repo": "Passeriform/GodWit-Daemon",
"path": "/dyn_compile.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 0ncorhynchus/caridina path: /src/read.rs
use std::str::Chars;
use types::Datum;
const DELIMITERS: &'static [char]
= &[' ', '\n', '\t', '(', ')', '"', ';'];
fn is_delimiter(c: char) -> bool {
DELIMITERS.into_iter().any(|&delimiter| delimiter == c)
}
pub fn next_token(chars: &mut Chars)... | code_fim | hard | {
"lang": "rust",
"repo": "0ncorhynchus/caridina",
"path": "/src/read.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn read_string_datum(chars: &mut Chars) -> String {
let mut string = String::new();
loop {
let (token, delimiter) = next_token(chars);
string = (string + &token).to_string();
if delimiter == '"' {
break;
} else {
string.push(delimiter);
... | code_fim | hard | {
"lang": "rust",
"repo": "0ncorhynchus/caridina",
"path": "/src/read.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_read() {
assert_eq!(Some(Datum::Boolean(true)), read("#t"));
assert_eq!(Some(Datum::Boolean(false)), read("#f"));
assert_eq!(Some(Datum::Number(404f64)), read("404"));
assert_eq!(Some(Datum::Symbol("var".to_string())),
read("var")... | code_fim | hard | {
"lang": "rust",
"repo": "0ncorhynchus/caridina",
"path": "/src/read.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>silly_macro!();
pub fn main() {}<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/issues/issue-9110.rs
// build-pass (FIXME(62277): could be check-pass?)
#![allow(dead_code)]
// pretty-expanded FIXME #23616
#![allow(non_snake_case)]
<|fim_middle|>macro_rules! silly_macro {
(... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/issues/issue-9110.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/issues/issue-9110.rs
// build-pass (FIXME(62277): could be check-pass?)
#![allow(dead_code)]
// pretty-expanded FIXME #23616
#![allow(non_snake_case)]
<|fim_suffix|>silly_macro!();
pub fn main() {}<|fim_middle|>macro_rules! silly_macro {
(... | code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/issues/issue-9110.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AlyoshaVasilieva/teensy4-rs path: /teensy4-rt/src/fault.rs
use core::fmt;
/// Registers stacked (pushed into the stack) during an exception
#[derive(Clone, Copy)]
#[repr(C)]
pub struct ExceptionFrame {
/// (General purpose) Register 0
pub r0: u32,
/// (General purpose) Register 1
... | code_fim | medium | {
"lang": "rust",
"repo": "AlyoshaVasilieva/teensy4-rs",
"path": "/teensy4-rt/src/fault.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> struct Hex(u32);
impl fmt::Debug for Hex {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "0x{:08x}", self.0)
}
}
f.debug_struct("ExceptionFrame")
.field("r0", &Hex(self.r0))
.field("r1", &Hex... | code_fim | medium | {
"lang": "rust",
"repo": "AlyoshaVasilieva/teensy4-rs",
"path": "/teensy4-rt/src/fault.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: GuilloteauQ/Rusil path: /src/main.rs
pub mod errors;
pub mod functions;
pub mod tokens;
pub mod types;
use crate::errors::*;
use crate::tokens::*;
use std::env;
use std::error::Error;
use std::fs::File;
use std::io::prelude::*;
<|fim_suffix|> let e = Expr::token_tree(code.as_str());
// p... | code_fim | hard | {
"lang": "rust",
"repo": "GuilloteauQ/Rusil",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let e = Expr::token_tree(code.as_str());
// println!("Tree: {:?}", e);
let result = e.exec();
match result {
Ok(r) => println!("{}", r),
Err(e) => println!("{}", e.description()),
}
}<|fim_prefix|>// repo: GuilloteauQ/Rusil path: /src/main.rs
pub mod errors;
pub mod fu... | code_fim | hard | {
"lang": "rust",
"repo": "GuilloteauQ/Rusil",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn top(&self) -> TOP_R { TOP_R::new((self.bits & 0xffff) as u16) }
}<|fim_prefix|>// repo: pablo-mansanet-bluefruit/efm32gg11b path: /src/pcnt2/top.rs
#[doc = "Reader of register TOP"]
pub type R = crate::R<u32, super::TOP>;
<|fim_middle|>#[doc = "Reader of field `TOP`"]
pub type TOP_R = crate::R<u... | code_fim | medium | {
"lang": "rust",
"repo": "pablo-mansanet-bluefruit/efm32gg11b",
"path": "/src/pcnt2/top.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pablo-mansanet-bluefruit/efm32gg11b path: /src/pcnt2/top.rs
#[doc = "Reader of register TOP"]
pub type R = crate::R<u32, super::TOP>;
<|fim_suffix|> pub fn top(&self) -> TOP_R { TOP_R::new((self.bits & 0xffff) as u16) }
}<|fim_middle|>#[doc = "Reader of field `TOP`"]
pub type TOP_R = crate::R<u... | code_fim | medium | {
"lang": "rust",
"repo": "pablo-mansanet-bluefruit/efm32gg11b",
"path": "/src/pcnt2/top.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> insta::assert_snapshot!(
run_query!(&runner, r#"query { aggregateTestModel(where: { id: { gt: 2 }}) { _min { int bInt float decimal string } } }"#),
@r###"{"data":{"aggregateTestModel":{"_min":{"int":1,"bInt":"1","float":0.0,"decimal":"0","string":"g"}}}}"###
);
... | code_fim | hard | {
"lang": "rust",
"repo": "debragail/prisma-engines",
"path": "/query-engine/connector-test-kit-rs/query-engine-tests/tests/queries/aggregation/min.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn deser_structure_crate_model_resource<'a, I>(
tokens: &mut std::iter::Peekable<I>,
) -> Result<Option<crate::model::Resource>, smithy_json::deserialize::Error>
where
I: Iterator<
Item = Result<smithy_json::deserialize::Token<'a>, smithy_json::deserialize::Error>,
>,
{
match t... | code_fim | hard | {
"lang": "rust",
"repo": "mnts26/aws-sdk-rust",
"path": "/sdk/auditmanager/src/json_deser.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mnts26/aws-sdk-rust path: /sdk/auditmanager/src/json_deser.rs
smithy_json::deserialize::token::expect_number_or_null(
tokens.next(),
)?
.map(|v| v.to_i32())... | code_fim | hard | {
"lang": "rust",
"repo": "mnts26/aws-sdk-rust",
"path": "/sdk/auditmanager/src/json_deser.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn deser_structure_crate_model_notification<'a, I>(
tokens: &mut std::iter::Peekable<I>,
) -> Result<Option<crate::model::Notification>, smithy_json::deserialize::Error>
where
I: Iterator<
Item = Result<smithy_json::deserialize::Token<'a>, smithy_json::deserialize::Error>,
>,
{
... | code_fim | hard | {
"lang": "rust",
"repo": "mnts26/aws-sdk-rust",
"path": "/sdk/auditmanager/src/json_deser.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: spejamchr/exercism_solutions path: /rust/grade-school/src/lib.rs
use std::collections::HashMap;
pub struct School {
students: HashMap<String, u32>,
}
impl School {
pub fn new() -> Self {
Self {
students: HashMap::new(),
}
}
pub fn add(&mut self, gra... | code_fim | hard | {
"lang": "rust",
"repo": "spejamchr/exercism_solutions",
"path": "/rust/grade-school/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if vec.is_empty() {
None
} else {
vec.sort_unstable();
Some(vec)
}
}
}
impl Default for School {
fn default() -> Self {
Self::new()
}
}<|fim_prefix|>// repo: spejamchr/exercism_solutions path: /rust/grade-school/src/lib.rs
u... | code_fim | hard | {
"lang": "rust",
"repo": "spejamchr/exercism_solutions",
"path": "/rust/grade-school/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn grades(&self) -> Vec<u32> {
let mut g: Vec<u32> = self.students.values().copied().collect();
g.sort_unstable();
g.dedup();
g
}
// If grade returned an `Option<&Vec<String>>`,
// the internal implementation would be forced to keep a `Vec<String>` to l... | code_fim | medium | {
"lang": "rust",
"repo": "spejamchr/exercism_solutions",
"path": "/rust/grade-school/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: icsga/Wavetable path: /examples/wav_info.rs
use wavetable::WavHandler;
use flexi_logger::{Logger, opt_format};
/// Load a wave file into memory and show some information about the data.
fn main () {
<|fim_suffix|> let filename = std::env::args().nth(1).expect("Please give name of wave file ... | code_fim | hard | {
"lang": "rust",
"repo": "icsga/Wavetable",
"path": "/examples/wav_info.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let filename = std::env::args().nth(1).expect("Please give name of wave file to analyze as argument");
let result = WavHandler::read_file(&filename);
match result {
Ok(wav_file) => {
let info = wav_file.get_fmt();
let data = wav_file.get_samples();
p... | code_fim | hard | {
"lang": "rust",
"repo": "icsga/Wavetable",
"path": "/examples/wav_info.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nsalesky/todolist-backend path: /src/constants.rs
// All of the messages that can be returned for each API call.
pub const MESSAGE_OK: &str = "ok";
// pub const MESSAGE_CAN_NOT_INSERT_DATA: &str = "can not insert data";
// pub const MESSAGE_CAN_NOT_UPDATE_DATA: &str = "can not update data";
// p... | code_fim | hard | {
"lang": "rust",
"repo": "nsalesky/todolist-backend",
"path": "/src/constants.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// pub const MESSAGE_UPDATE_ITEM_SUCCESS: &str = "updated item successfully";
// pub const MESSAGE_UPDATE_ITEM_FAILED: &str = "error when updating item, please try again";
pub const MESSAGE_ITEM_NOT_OWNED_BY_LIST: &str = "error, item not owned by the specified list";
pub const MESSAGE_UPDATE_SUCCESS: &s... | code_fim | hard | {
"lang": "rust",
"repo": "nsalesky/todolist-backend",
"path": "/src/constants.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub const MESSAGE_GET_LIST_SUCCESS: &str = "got list successfully";
pub const MESSAGE_GET_LIST_FAILED: &str = "error when getting list, please try again";
// pub const MESSAGE_UPDATE_LIST_SUCCESS: &str = "updated list successfully";
// pub const MESSAGE_UPDATE_LIST_FAILED: &str = "error when updating lis... | code_fim | hard | {
"lang": "rust",
"repo": "nsalesky/todolist-backend",
"path": "/src/constants.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl PhysicalExpr for IsNotNullExpr {
fn as_expression(&self) -> &Expr {
&self.expr
}
fn evaluate(&self, df: &DataFrame, state: &ExecutionState) -> Result<Series> {
let series = self.physical_expr.evaluate(df, state)?;
Ok(series.is_not_null().into_series())
}
f... | code_fim | medium | {
"lang": "rust",
"repo": "FlorianWilhelm/polars",
"path": "/polars/polars-lazy/src/physical_plan/expressions/is_not_null.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let series = self.physical_expr.evaluate(df, state)?;
Ok(series.is_not_null().into_series())
}
fn to_field(&self, _input_schema: &Schema) -> Result<Field> {
Ok(Field::new("is_not_null", DataType::Boolean))
}
}<|fim_prefix|>// repo: FlorianWilhelm/polars path: /polars/p... | code_fim | medium | {
"lang": "rust",
"repo": "FlorianWilhelm/polars",
"path": "/polars/polars-lazy/src/physical_plan/expressions/is_not_null.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: FlorianWilhelm/polars path: /polars/polars-lazy/src/physical_plan/expressions/is_not_null.rs
use crate::physical_plan::state::ExecutionState;
use crate::prelude::*;
use polars_core::prelude::*;
use std::sync::Arc;
<|fim_suffix|>impl IsNotNullExpr {
pub fn new(physical_expr: Arc<dyn Physical... | code_fim | medium | {
"lang": "rust",
"repo": "FlorianWilhelm/polars",
"path": "/polars/polars-lazy/src/physical_plan/expressions/is_not_null.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn init_logging<P: AsRef<Path>>(log_file: P) {
CombinedLogger::init(vec![
TermLogger::new(
LevelFilter::Info,
Config::default(),
TerminalMode::Mixed,
ColorChoice::Auto,
),
WriteLogger::new(
LevelFilter::Info,
... | code_fim | hard | {
"lang": "rust",
"repo": "agersant/tiger",
"path": "/src-tauri/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> features::app_updates::init(tauri_app.handle());
features::clipboard_analysis::init(tauri_app.handle());
features::missing_textures::init(tauri_app.handle());
features::onboarding::init(tauri_app.handle());
features::recent_do... | code_fim | hard | {
"lang": "rust",
"repo": "agersant/tiger",
"path": "/src-tauri/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: agersant/tiger path: /src-tauri/src/main.rs
#![cfg_attr(
all(not(debug_assertions), target_os = "windows"),
windows_subsystem = "windows"
)]
use log::{error, LevelFilter};
use simplelog::{ColorChoice, CombinedLogger, Config, TermLogger, TerminalMode, WriteLogger};
use std::path::Path;
u... | code_fim | hard | {
"lang": "rust",
"repo": "agersant/tiger",
"path": "/src-tauri/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Self {
r#type: #model_name_str.to_string(),
id: String::new(),
attributes: #model_name_attr::default()
}
}
}
impl #model_n... | code_fim | hard | {
"lang": "rust",
"repo": "rconan/bokeh-bindings",
"path": "/import/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rconan/bokeh-bindings path: /import/src/lib.rs
use proc_macro;
use proc_macro2::{Ident, Span};
use quote::quote;
use serde::{Deserialize, Serialize};
use serde_json::Value;
use std::collections::HashMap;
#[derive(Serialize, Deserialize, Debug, Clone)]
struct Property {
name: String,
r#t... | code_fim | hard | {
"lang": "rust",
"repo": "rconan/bokeh-bindings",
"path": "/import/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> warp::any().map(move || cfg.clone())
}
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
}
}<|fim_prefix|>// repo: BruceBrown/rust-server-project path: /config/merged-config/src/main.rs
use std::convert::Infallible;
use warp::{Filter, Rejection, Reply};
mod ... | code_fim | hard | {
"lang": "rust",
"repo": "BruceBrown/rust-server-project",
"path": "/config/merged-config/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: BruceBrown/rust-server-project path: /config/merged-config/src/main.rs
use std::convert::Infallible;
use warp::{Filter, Rejection, Reply};
mod server_config;
pub use server_config::*;
mod server_settings;
pub use server_settings::*;
<|fim_suffix|> println!("Server started at localhost:{} a... | code_fim | hard | {
"lang": "rust",
"repo": "BruceBrown/rust-server-project",
"path": "/config/merged-config/src/main.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("Server started at localhost:{} and ENV: {}", config.server.port, config.env);
warp::serve(cfg_route).run(([0, 0, 0, 0], config.server.port)).await;
}
async fn cfg_handler(cfg: ServerSettings) -> Result<impl Reply, Rejection> {
Ok(format!("Running on port: {} with url: {}", cfg.serv... | code_fim | hard | {
"lang": "rust",
"repo": "BruceBrown/rust-server-project",
"path": "/config/merged-config/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let datafile = OpenOptions::new()
.create(true)
.append(true)
.open("two_files/data")
.unwrap();
let mut datafile = BufWriter::new(datafile);
write_test("two_files", |key, data| {
keyfile
.write(key)
.expect(&format!("write key {... | code_fim | hard | {
"lang": "rust",
"repo": "rwalker-com/rusty",
"path": "/ledger_showdown/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut options = Options::default();
options.create_if_missing(true);
let db = DB::open(&options, "rocksdb").expect("first open");
write_test("rocksdb", |key, data| {
db.put(key, data)
.expect(&format!("writing {:?} failed", key));
});
// cleanup
// l... | code_fim | hard | {
"lang": "rust",
"repo": "rwalker-com/rusty",
"path": "/ledger_showdown/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rwalker-com/rusty path: /ledger_showdown/src/main.rs
extern crate byteorder;
use byteorder::{BigEndian, ByteOrder};
use rand::prelude::*;
//use std::sync::Arc;
//use std::thread;
use std::time::{Duration, Instant};
fn per_second(x: u64, elapsed: &Duration) -> f64 {
let nanos = elapsed.as_se... | code_fim | hard | {
"lang": "rust",
"repo": "rwalker-com/rusty",
"path": "/ledger_showdown/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let _ = tokio::time::timeout(
Duration::from_millis(100),
self.core.log.commit_notify.notified(),
)
.await;
}
}
}
pub async fn run<A: RaftApp>(core: Arc<RaftCore<A>>) {
let x = Thread { core };
x.run().await
}<|fim_prefix|>// re... | code_fim | hard | {
"lang": "rust",
"repo": "simonsan/raft-consensus-system",
"path": "/lol-core/src/thread/execution.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: simonsan/raft-consensus-system path: /lol-core/src/thread/execution.rs
use crate::{RaftApp, RaftCore};
use std::sync::atomic::Ordering;
use std::sync::Arc;
use std::time::Duration;
struct Thread<A: RaftApp> {
core: Arc<RaftCore<A>>,
}
impl<A: RaftApp> Thread<A> {
async fn run(self) {
... | code_fim | hard | {
"lang": "rust",
"repo": "simonsan/raft-consensus-system",
"path": "/lol-core/src/thread/execution.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> core.log
.advance_last_applied(Arc::clone(&core))
.await
.unwrap();
}
need_work
}
})
.await
{}
let _ = tokio::tim... | code_fim | hard | {
"lang": "rust",
"repo": "simonsan/raft-consensus-system",
"path": "/lol-core/src/thread/execution.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ghcom275/duplex path: /src/duplex.rs
#![allow(clippy::module_name_repetitions)]
#[cfg(feature = "char-device")]
use char_device::CharDevice;
#[cfg(feature = "futures-io")]
use futures_io::{AsyncRead, AsyncWrite};
#[cfg(feature = "socketpair")]
use socketpair::SocketpairStream;
use std::{
io... | code_fim | hard | {
"lang": "rust",
"repo": "ghcom275/duplex",
"path": "/src/duplex.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(feature = "socketpair")]
impl Duplex for SocketpairStream {}
#[cfg(feature = "ssh2")]
impl Duplex for ssh2::Stream {}
#[cfg(feature = "ssh2")]
impl Duplex for ssh2::Channel {}
#[cfg(all(unix, feature = "serialport"))]
impl Duplex for serialport::TTYPort {}
#[cfg(feature = "readwrite")]
impl<R: R... | code_fim | hard | {
"lang": "rust",
"repo": "ghcom275/duplex",
"path": "/src/duplex.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: KamilRutkowski/vmar path: /src/basic_data_structures/matrix.rs
#![allow(dead_code)]
extern crate num;
extern crate std;
pub struct Matrix<T> {
data: Vec<Vec<T>>
}
impl<T> Matrix<T>
where T: num::Zero + std::clone::Clone + num::One
{
fn new(height: usize, width: usize) -> Option<Self> ... | code_fim | hard | {
"lang": "rust",
"repo": "KamilRutkowski/vmar",
"path": "/src/basic_data_structures/matrix.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn transpose(&self) -> Matrix<T> {
let tran_height = self.data[0].len();
let tran_width = self.data.len();
let mut transposed_matrix = match Matrix::<T>::new(tran_height, tran_width) {
Some(tm) => tm,
None => panic!("Couldn't transpose given matrix, wron... | code_fim | hard | {
"lang": "rust",
"repo": "KamilRutkowski/vmar",
"path": "/src/basic_data_structures/matrix.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nanreh/strava-rs path: /strava_rs/src/models/mod.rs
pub mod activity_stats;
pub use self::activity_stats::ActivityStats;
pub mod activity_total;
pub use self::activity_total::ActivityTotal;
pub mod activity_type;
pub use self::activity_type::ActivityType;
pub mod activity_zone;
pub use self::act... | code_fim | hard | {
"lang": "rust",
"repo": "nanreh/strava-rs",
"path": "/strava_rs/src/models/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ry_athlete_all_of;
pub use self::summary_athlete_all_of::SummaryAthleteAllOf;
pub mod summary_club;
pub use self::summary_club::SummaryClub;
pub mod summary_club_all_of;
pub use self::summary_club_all_of::SummaryClubAllOf;
pub mod summary_gear;
pub use self::summary_gear::SummaryGear;
pub mod summary_pr_s... | code_fim | hard | {
"lang": "rust",
"repo": "nanreh/strava-rs",
"path": "/strava_rs/src/models/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>use self::moving_stream::MovingStream;
pub mod moving_stream_all_of;
pub use self::moving_stream_all_of::MovingStreamAllOf;
pub mod photos_summary;
pub use self::photos_summary::PhotosSummary;
pub mod photos_summary_primary;
pub use self::photos_summary_primary::PhotosSummaryPrimary;
pub mod polyline_map;... | code_fim | hard | {
"lang": "rust",
"repo": "nanreh/strava-rs",
"path": "/strava_rs/src/models/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ckybonist/leetcode path: /solutions/0860-design-circular-queue/design-circular-queue.rs
// Design your implementation of the circular queue. The circular queue is a linear data structure in which the operations are performed based on FIFO (First In First Out) principle and the last position is c... | code_fim | hard | {
"lang": "rust",
"repo": "ckybonist/leetcode",
"path": "/solutions/0860-design-circular-queue/design-circular-queue.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.data[self.head]
}
/** Get the last item from the queue. */
fn rear(&self) -> i32 {
// Since the tail is point to next index of last element,
// so we can't sustract index directly when tail is 0
let index = (self.tail + self.cap() - 1) % self.cap();
... | code_fim | hard | {
"lang": "rust",
"repo": "ckybonist/leetcode",
"path": "/solutions/0860-design-circular-queue/design-circular-queue.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /** Get the last item from the queue. */
fn rear(&self) -> i32 {
// Since the tail is point to next index of last element,
// so we can't sustract index directly when tail is 0
let index = (self.tail + self.cap() - 1) % self.cap();
self.data[index]
}
/*... | code_fim | hard | {
"lang": "rust",
"repo": "ckybonist/leetcode",
"path": "/solutions/0860-design-circular-queue/design-circular-queue.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: monmaru/rust-playground path: /practice_rust/ch07/ex07/src/arc_rwlock.rs
use std::collections::HashSet;
use std::error::Error;
use std::sync::{Arc, RwLock};
fn main() -> Result<(), Box<dyn Error>> {
let dogs: HashSet<_> = ["柴", "トイプードル"].iter().cloned().collect();
let dogs = Arc::new(Rw... | code_fim | hard | {
"lang": "rust",
"repo": "monmaru/rust-playground",
"path": "/practice_rust/ch07/ex07/src/arc_rwlock.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert!(dogs
.read()
.map_err(stringify)?
.contains("ブル・テリア"));
assert!(dogs.read().map_err(stringify)?.contains("コーギー"));
Ok(())
}<|fim_prefix|>// repo: monmaru/rust-playground path: /practice_rust/ch07/ex07/src/arc_rwlock.rs
use std::collections::HashSet;
use std::er... | code_fim | hard | {
"lang": "rust",
"repo": "monmaru/rust-playground",
"path": "/practice_rust/ch07/ex07/src/arc_rwlock.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let dogs1 = Arc::clone(&dogs);
std::thread::spawn(move || {
dogs1
.write()
.map(|mut ds| ds.insert("コーギー"))
.map_err(stringify)
})
.join()
.expect("Thread error")?;
assert!(dogs
.read()
.map_err(stringify)?
.conta... | code_fim | medium | {
"lang": "rust",
"repo": "monmaru/rust-playground",
"path": "/practice_rust/ch07/ex07/src/arc_rwlock.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zhiburt/rstext path: /examples/po_files2.rs
use rstext::{self, Locale};
fn main() -> rstext::Result<()> {
<|fim_suffix|> println!("{:?}", greeting);
Ok(())
}<|fim_middle|> let mut locale = Locale::new("example_locales", "en")?;
let domain = locale.load("domain1")?;
let greeti... | code_fim | medium | {
"lang": "rust",
"repo": "zhiburt/rstext",
"path": "/examples/po_files2.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zhiburt/rstext path: /examples/po_files2.rs
use rstext::{self, Locale};
<|fim_suffix|> println!("{:?}", greeting);
Ok(())
}<|fim_middle|>fn main() -> rstext::Result<()> {
let mut locale = Locale::new("example_locales", "en")?;
let domain = locale.load("domain1")?;
let greeti... | code_fim | medium | {
"lang": "rust",
"repo": "zhiburt/rstext",
"path": "/examples/po_files2.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut locale = Locale::new("example_locales", "en")?;
let domain = locale.load("domain1")?;
let greeting = domain.get("greeting").unwrap();
println!("{:?}", greeting);
Ok(())
}<|fim_prefix|>// repo: zhiburt/rstext path: /examples/po_files2.rs
use rstext::{self, Locale};
<|fim_mid... | code_fim | easy | {
"lang": "rust",
"repo": "zhiburt/rstext",
"path": "/examples/po_files2.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: korczis/wims path: /src/types/path_cache.rs
use serde::ser::{Serialize, Serializer, SerializeStruct};
use std::cmp::Ordering;
use std::collections::BTreeMap;
use std::fmt::Debug;
use super::event_type::EventType;
use super::formatter::human_format;
use super::item_info::FsItemInfo;
use super::... | code_fim | hard | {
"lang": "rust",
"repo": "korczis/wims",
"path": "/src/types/path_cache.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> where S: Serializer
{
let mut s = serializer.serialize_struct("PathCache", 5)?;
s.serialize_field("path", &self.path)?;
s.serialize_field("data", &self.data)?;
s.serialize_field("dirs_size", &self.dirs_size)?;
s.serialize_field("files_size", &self.files_... | code_fim | hard | {
"lang": "rust",
"repo": "korczis/wims",
"path": "/src/types/path_cache.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn hash<'x, 'y>(&'y self) -> &'x [u8] {
&[]
}
pub fn open_hash<'x, 'y>(&'y self) -> &'x [u8] {
&[]
}
/// A `sha256` of the full rpm file content (lead, headers, cpio).
pub fn identifier(&self) -> String {
self.identifier.clone()
}
pub fn arch(... | code_fim | hard | {
"lang": "rust",
"repo": "drahnr/cantaloupe",
"path": "/repomd/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: drahnr/cantaloupe path: /repomd/src/lib.rs
mod error;
pub mod xml;
pub use xml::*;
pub mod servings;
pub use servings::*;
pub use error::{Error, Result};
use std::collections::HashMap;
use std::fmt;
use std::path::{Path, PathBuf};
use std::str::FromStr;
use url::Url;
#[derive(Debug)]
pub str... | code_fim | hard | {
"lang": "rust",
"repo": "drahnr/cantaloupe",
"path": "/repomd/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: andrewpedia/learn-rust path: /02trait_associated_generic/src/test0.rs
pub trait Converter {
type Output;
fn convert(&self) -> Self::Output;
}
struct MyInt;
impl Converter for MyInt {
type Output = i32;
<|fim_suffix|> 42
}
}
fn main() {
let my_int = MyInt;
... | code_fim | easy | {
"lang": "rust",
"repo": "andrewpedia/learn-rust",
"path": "/02trait_associated_generic/src/test0.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let output = my_int.convert();
println!("output is: {}", output);
}<|fim_prefix|>// repo: andrewpedia/learn-rust path: /02trait_associated_generic/src/test0.rs
pub trait Converter {
type Output;
<|fim_middle|> fn convert(&self) -> Self::Output;
}
struct MyInt;
impl Converter for MyInt... | code_fim | hard | {
"lang": "rust",
"repo": "andrewpedia/learn-rust",
"path": "/02trait_associated_generic/src/test0.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
struct MyInt;
impl Converter for MyInt {
type Output = i32;
fn convert(&self) -> Self::Output {
42
}
}
fn main() {
let my_int = MyInt;
let output = my_int.convert();
println!("output is: {}", output);
}<|fim_prefix|>// repo: andrewpedia/learn-rust path: /02tra... | code_fim | easy | {
"lang": "rust",
"repo": "andrewpedia/learn-rust",
"path": "/02trait_associated_generic/src/test0.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut color = Hsv::new(0.0, 0.0, 0.0);
assert_eq!(color.hue(), 0.0);
assert_eq!(color.saturation(), 0.0);
assert_eq!(color.brightness(), 0.0);
color.set_hue(1000.0);
color.set_saturation(1000.0);
color.set_brightness(1000.0);
assert_eq!(co... | code_fim | hard | {
"lang": "rust",
"repo": "FyroxEngine/Fyrox",
"path": "/fyrox-core/src/color.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.