text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> // Print the following three customers
println!("{:?}", customers2);
// List all customers within a given time range
let mut params = ListCustomers::new();
params.created = Some(RangeQuery::Bounds(RangeBounds {
gt: None,
gte: customers.data[0].created.map(|x| x as i64)... | code_fim | hard | {
"lang": "rust",
"repo": "wyyerd/stripe-rs",
"path": "/examples/list_customers.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wyyerd/stripe-rs path: /examples/list_customers.rs
use stripe::{Customer, ListCustomers, RangeBounds, RangeQuery};
fn main() {
// Create a new client
let secret_key = std::env::var("STRIPE_SECRET_KEY").expect("Missing STRIPE_SECRET_KEY in env");
let client = stripe::Client::new(secr... | code_fim | hard | {
"lang": "rust",
"repo": "wyyerd/stripe-rs",
"path": "/examples/list_customers.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_example2() {
assert_eq!(
vec![0, 1, 1, 2, 1, 2],
Solution::count_bits(5),
);
}
}<|fim_prefix|>// repo: csixteen/LeetCode path: /Problems/Algorithms/src/Rust/counting-bits/src/lib.rs
// https://leetcode.com/problems/counting-bits/
struct... | code_fim | medium | {
"lang": "rust",
"repo": "csixteen/LeetCode",
"path": "/Problems/Algorithms/src/Rust/counting-bits/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: csixteen/LeetCode path: /Problems/Algorithms/src/Rust/counting-bits/src/lib.rs
// https://leetcode.com/problems/counting-bits/
struct Solution {}
impl Solution {
pub fn count_bits(num: i32) -> Vec<i32> {
let num = num as usize;
(1..=num).fold(vec![0; num + 1], |mut acc, x|... | code_fim | medium | {
"lang": "rust",
"repo": "csixteen/LeetCode",
"path": "/Problems/Algorithms/src/Rust/counting-bits/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match platform::should_show_permission_rationale(permission) {
Err(err) => {
log::error!("check_self_permission failed:{:?}", err);
false
}
Ok(ret) => ret,
}
}
#[tauri::command]
fn update_notification(content: String) {
if let Err(err) = platfor... | code_fim | hard | {
"lang": "rust",
"repo": "lazytiger/trojan-rs",
"path": "/mobile/src-tauri/src/lib.rs",
"mode": "spm",
"license": "LicenseRef-scancode-free-unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lazytiger/trojan-rs path: /mobile/src-tauri/src/lib.rs
extern crate core;
use std::{
collections::HashSet,
io::{BufRead, BufReader, Cursor},
sync::{atomic::AtomicBool, Arc, RwLock},
};
use serde::{Deserialize, Serialize};
use tauri::{Manager, State, Window, Wry};
use crate::types:... | code_fim | hard | {
"lang": "rust",
"repo": "lazytiger/trojan-rs",
"path": "/mobile/src-tauri/src/lib.rs",
"mode": "psm",
"license": "LicenseRef-scancode-free-unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[tauri::command]
fn load_data(key: String) -> String {
match platform::load_data(key) {
Err(err) => {
log::error!("load data failed:{:?}", err);
"".into()
}
Ok(ret) => ret,
}
}
#[tauri::command]
fn search_domain(key: String, state: State<VpnState>)... | code_fim | hard | {
"lang": "rust",
"repo": "lazytiger/trojan-rs",
"path": "/mobile/src-tauri/src/lib.rs",
"mode": "spm",
"license": "LicenseRef-scancode-free-unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Ryanmtate/fluvio path: /src/sc-core/src/core/spus/reducer.rs
//!
//! # SC Spu Metadata
//!
//! Spu metadata information cached locally.
//!
use log::{debug, trace};
use flv_types::log_on_err;
use crate::core::common::LSChange;
use crate::core::common::WSAction;
use crate::conn_manager::Connec... | code_fim | hard | {
"lang": "rust",
"repo": "Ryanmtate/fluvio",
"path": "/src/sc-core/src/core/spus/reducer.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(())
}
///
/// Modify SPU Action handler
///
/// # Remarks
/// Action handler performs the following operations:
/// * if spec changed
/// * update spec in local cache
/// * if status changed,
/// * update status in local cache
/// * ask T... | code_fim | hard | {
"lang": "rust",
"repo": "Ryanmtate/fluvio",
"path": "/src/sc-core/src/core/spus/reducer.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for a in 1..n / 3 {
for b in a + 1..n - 2 * a {
let c = n - a - b;
if c * c == a * a + b * b {
return Some([a, b, c]);
}
}
}
return None;
}<|fim_prefix|>// repo: patrickbucher/pcp-project path: /Rust-Arnold-Bucher/code/patter... | code_fim | hard | {
"lang": "rust",
"repo": "patrickbucher/pcp-project",
"path": "/Rust-Arnold-Bucher/code/pattern-matching/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: patrickbucher/pcp-project path: /Rust-Arnold-Bucher/code/pattern-matching/src/main.rs
fn main() {
for n in [12, 50, 1000].iter() {
match pythagorean_triplet(&n) {
Some([a, b, c]) => println!("{}²+{}²={}²", a, b, c),
None => println!("{} is not the sum of a Pyt... | code_fim | hard | {
"lang": "rust",
"repo": "patrickbucher/pcp-project",
"path": "/Rust-Arnold-Bucher/code/pattern-matching/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dobrakmato/renderer path: /bfinfo/src/main.rs
use bf::image::{Format, Image};
use bf::material::Material;
use bf::mesh::Mesh;
use bf::tree::Tree;
use bf::{load_bf_from_bytes, Container};
use image::dxt::{DXTVariant, DxtDecoder};
use image::{DynamicImage, ImageBuffer, ImageDecoder, ImageFormat};
... | code_fim | hard | {
"lang": "rust",
"repo": "dobrakmato/renderer",
"path": "/bfinfo/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let tan_x = f!();
let tan_y = f!();
let tan_z = f!();
let padding = f!();
println!(
"{} ({:.4}; {:.4}; {:.4})\t\t\t({:.4}; {:.4}; {:.4})\t\t\t({:.4}; {:.4})\t\t\t({:.4}; {:.4}; {:.4})\t\t{:.4}",
idx, pos_x, pos_y,... | code_fim | hard | {
"lang": "rust",
"repo": "dobrakmato/renderer",
"path": "/bfinfo/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl MemoryAllocationTracker {
pub fn new() -> Result<Self, Error> {
Err(Error)
}
pub fn snapshot(&self) -> Result<crate::MemoryAllocationSnapshot, Error> {
unimplemented!();
}
}<|fim_prefix|>// repo: komi1230/parity-common path: /parity-util-mem/src/memory_stats_noop.rs
// Copyright 2021 Parity... | code_fim | medium | {
"lang": "rust",
"repo": "komi1230/parity-common",
"path": "/parity-util-mem/src/memory_stats_noop.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: komi1230/parity-common path: /parity-util-mem/src/memory_stats_noop.rs
// Copyright 2021 Parity Technologies
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses... | code_fim | medium | {
"lang": "rust",
"repo": "komi1230/parity-common",
"path": "/parity-util-mem/src/memory_stats_noop.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn snapshot(&self) -> Result<crate::MemoryAllocationSnapshot, Error> {
unimplemented!();
}
}<|fim_prefix|>// repo: komi1230/parity-common path: /parity-util-mem/src/memory_stats_noop.rs
// Copyright 2021 Parity Technologies
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
/... | code_fim | hard | {
"lang": "rust",
"repo": "komi1230/parity-common",
"path": "/parity-util-mem/src/memory_stats_noop.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.show_on(&mut stderr())
}
fn show_on(self, f: &mut impl Write) -> Result<Self::Result>;
}<|fim_prefix|>// repo: kiwiyou/muroba path: /src/query/mod.rs
use std::io::{stderr, Write};
use crate::item::Prompt;
use crate::style::{DefaultStyle, Styler};
use crate::Result;
mod input;
mod ... | code_fim | medium | {
"lang": "rust",
"repo": "kiwiyou/muroba",
"path": "/src/query/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kiwiyou/muroba path: /src/query/mod.rs
use std::io::{stderr, Write};
use crate::item::Prompt;
use crate::style::{DefaultStyle, Styler};
use crate::Result;
mod input;
mod reader;
mod select;
pub use input::*;
pub use reader::*;
pub use select::*;
pub struct QueryBuilder<'a, S> {
prompt: O... | code_fim | hard | {
"lang": "rust",
"repo": "kiwiyou/muroba",
"path": "/src/query/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub trait Query: Sized {
type Result;
fn show(self) -> Result<Self::Result> {
self.show_on(&mut stderr())
}
fn show_on(self, f: &mut impl Write) -> Result<Self::Result>;
}<|fim_prefix|>// repo: kiwiyou/muroba path: /src/query/mod.rs
use std::io::{stderr, Write};
use crate::item... | code_fim | hard | {
"lang": "rust",
"repo": "kiwiyou/muroba",
"path": "/src/query/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dlinman/rgame path: /src/agents/human_player.rs
use crate::games::game_form::{Game};
use super::agent::Agent;
use std::io::{self, BufRead};
pub fn get_agent() -> impl Agent {
HumanAgent { }
}
struct HumanAgent {}
impl Agent for HumanAgent {
fn decide_turn<G : Game>(&mut self, game... | code_fim | hard | {
"lang": "rust",
"repo": "dlinman/rgame",
"path": "/src/agents/human_player.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // TODO check to ensure that we get a number and that it returns something from nth
let mut buffer = String::new();
io::stdin().lock().read_line(&mut buffer).unwrap();
let choice = buffer.trim().parse::<usize>().unwrap();
game.legal_turns(state).nth(choice).unwrap(... | code_fim | hard | {
"lang": "rust",
"repo": "dlinman/rgame",
"path": "/src/agents/human_player.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<L: Iso> Iso for Invert<L>
where L::AtInitial: Iso,
L::AtFinal: Iso
{
}<|fim_prefix|>// repo: pthariensflame/refraction path: /src/iso.rs
use super::{Compose, Identity, Invert, Lens, Prism};
/// The supertype of all isomorphism families.
pub trait Iso: Lens + Prism
where Self::AtIn... | code_fim | hard | {
"lang": "rust",
"repo": "pthariensflame/refraction",
"path": "/src/iso.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pthariensflame/refraction path: /src/iso.rs
use super::{Compose, Identity, Invert, Lens, Prism};
/// The supertype of all isomorphism families.
pub trait Iso: Lens + Prism
where Self::AtInitial: Iso,
Self::AtFinal: Iso
{
}
<|fim_suffix|>impl<LF: Iso, LS: ?Sized> Iso for Compose<L... | code_fim | medium | {
"lang": "rust",
"repo": "pthariensflame/refraction",
"path": "/src/iso.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<LF: Iso, LS: ?Sized> Iso for Compose<LF, LS>
where LS: Iso<InitialTarget = LF::InitialSource, FinalTarget = LF::FinalSource>,
LF::AtInitial: Iso,
LF::AtFinal: Iso,
LS::AtInitial: Iso,
LS::AtFinal: Iso
{
}
impl<L: Iso> Iso for Invert<L>
where L::AtIniti... | code_fim | medium | {
"lang": "rust",
"repo": "pthariensflame/refraction",
"path": "/src/iso.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mahkoh/linux-rs path: /src/syscall/raw/x86_64.rs
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
pub use crate::syscall::raw::arch::abi::{
... | code_fim | hard | {
"lang": "rust",
"repo": "mahkoh/linux-rs",
"path": "/src/syscall/raw/x86_64.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub unsafe fn pread(fd: k_uint, buf: *mut c_char, count: size_t, pos: loff_t) -> ssize_t {
common::pread64(fd, buf, count, pos)
}
pub unsafe fn pwrite(fd: k_uint, buf: *const c_char, count: size_t,
pos: loff_t) -> ssize_t {
common::pwrite64(fd, buf, count, pos)
}
pub unsafe ... | code_fim | hard | {
"lang": "rust",
"repo": "mahkoh/linux-rs",
"path": "/src/syscall/raw/x86_64.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: srijs/rust-cfn path: /src/aws/resourcegroups.rs
/ AWS CloudFormation doesn't replace the resource when you change this property.
pub resources: Option<::ValueList<String>>,
/// Property [`Tags`](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-resourcegroups-gro... | code_fim | hard | {
"lang": "rust",
"repo": "srijs/rust-cfn",
"path": "/src/aws/resourcegroups.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// The [`AWS::ResourceGroups::Group.ResourceQuery`](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-resourcegroups-group-resourcequery.html) property type.
#[derive(Debug, Default)]
pub struct ResourceQuery {
/// Property [`Query`](http://docs.aws.amazon.c... | code_fim | hard | {
"lang": "rust",
"repo": "srijs/rust-cfn",
"path": "/src/aws/resourcegroups.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(ConfigurationParameter {
name: name,
values: values,
})
}
}
d.deserialize_map(Visitor)
}
}
/// The [`AWS::ResourceGroups::Group.Query`](http://docs.aws.amazo... | code_fim | hard | {
"lang": "rust",
"repo": "srijs/rust-cfn",
"path": "/src/aws/resourcegroups.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TommyCpp/monolith path: /benches/benchmark.rs
use criterion::criterion_main;
<|fim_suffix|>criterion_main! {
// benchmarks::util::benches,
// benchmarks::indexer::intersect,
benchmarks::common::serialization
}<|fim_middle|>mod benchmarks;
| code_fim | easy | {
"lang": "rust",
"repo": "TommyCpp/monolith",
"path": "/benches/benchmark.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>criterion_main! {
// benchmarks::util::benches,
// benchmarks::indexer::intersect,
benchmarks::common::serialization
}<|fim_prefix|>// repo: TommyCpp/monolith path: /benches/benchmark.rs
use criterion::criterion_main;
<|fim_middle|>mod benchmarks;
| code_fim | easy | {
"lang": "rust",
"repo": "TommyCpp/monolith",
"path": "/benches/benchmark.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ghiculescu/rustyboy path: /src/mbc/rom.rs
use mbc::MBC;
pub struct ROM {
cart_data: Vec<u8>,
}
impl ROM {
pub fn new(_cart_path: &str, cart_data: Vec<u8>) -> Self {
Self { cart_data }
}
}
impl MBC for ROM {
fn read_byte(&self, addr: u16) -> u8 {
if addr >= 0x80... | code_fim | easy | {
"lang": "rust",
"repo": "ghiculescu/rustyboy",
"path": "/src/mbc/rom.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if addr >= 0x8000 {
panic!("Attempting to read for external ram, which doesn't exist!");
}
self.cart_data[addr as usize]
}
fn write_byte(&mut self, _addr: u16, _value: u8) {}
}<|fim_prefix|>// repo: ghiculescu/rustyboy path: /src/mbc/rom.rs
use mbc::MBC;
pub... | code_fim | medium | {
"lang": "rust",
"repo": "ghiculescu/rustyboy",
"path": "/src/mbc/rom.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn write_byte(&mut self, _addr: u16, _value: u8) {}
}<|fim_prefix|>// repo: ghiculescu/rustyboy path: /src/mbc/rom.rs
use mbc::MBC;
pub struct ROM {
cart_data: Vec<u8>,
}
impl ROM {
pub fn new(_cart_path: &str, cart_data: Vec<u8>) -> Self {
Self { cart_data }
}
}
impl MBC for R... | code_fim | easy | {
"lang": "rust",
"repo": "ghiculescu/rustyboy",
"path": "/src/mbc/rom.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iCodeIN/jsondata path: /src/json.rs
oat(&self) -> Option<f64> {
match self {
Json::Float(item) => item.float(),
Json::Integer(item) => item.float(),
_ => None,
}
}
pub fn as_str(&self) -> Option<&str> {
match self {
... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/jsondata",
"path": "/src/json.rs",
"mode": "psm",
"license": "LicenseRef-scancode-dco-1.1",
"source": "the-stack-v2"
} |
<|fim_suffix|> let path = jptr::fix_prefix(path)?;
let (json, frag) = jptr::lookup_mut(self, path)?;
match json {
Json::Array(arr) => match frag.parse::<usize>() {
Ok(n) => {
if n >= arr.len() {
err_at!(IndexOutofBound, msg:... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/jsondata",
"path": "/src/json.rs",
"mode": "spm",
"license": "LicenseRef-scancode-dco-1.1",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iCodeIN/jsondata path: /src/json.rs
{
props.remove(n);
Ok(())
}
Err(_) => err_at!(PropertyNotFound, msg: "{}", frag),
}
}
_ => err_at!(InvalidContainer, msg: "{}", json... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/jsondata",
"path": "/src/json.rs",
"mode": "psm",
"license": "LicenseRef-scancode-dco-1.1",
"source": "the-stack-v2"
} |
<|fim_suffix|> let trainer_name = TrainerName::from(&self.rom[offset..(offset + 13)]);
Ok(trainer_name)
}
/// Set trainer name by trainer ID
///
/// # Example
///
/// ```
/// use pkmnapi_db::patch::*;
/// use pkmnapi_db::string::*;
/// use pkmnapi_db::*;
/// use ... | code_fim | hard | {
"lang": "rust",
"repo": "pkmn-api/pkmnapi",
"path": "/pkmnapi-db/src/db/trainer_name.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let offset_base = PkmnapiDB::ROM_PAGE * 0x0E;
let offset_base = offset_base + 0x19FF;
let offset = self.rom[offset_base..]
.iter()
.enumerate()
.filter_map(|(i, x)| {
if i == 0 {
return Some(offset_base);
... | code_fim | hard | {
"lang": "rust",
"repo": "pkmn-api/pkmnapi",
"path": "/pkmnapi-db/src/db/trainer_name.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pkmn-api/pkmnapi path: /pkmnapi-db/src/db/trainer_name.rs
use crate::error::{self, Result};
use crate::patch::*;
use crate::string::*;
use crate::PkmnapiDB;
use std::collections::HashMap;
impl PkmnapiDB {
pub fn get_trainer_name_all(&self, trainer_ids: &Vec<u8>) -> Result<HashMap<u8, Traine... | code_fim | hard | {
"lang": "rust",
"repo": "pkmn-api/pkmnapi",
"path": "/pkmnapi-db/src/db/trainer_name.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: CodeGradox/advent_of_code_2018 path: /day01/src/main.rs
use std::fs;
use std::collections::HashSet;
fn main() {
println!("Part 1: {}", part1());
println!("Part 2: {}", part2());
}
fn part1() -> i32 {
let input = fs::read_to_string("input.txt").expect("failed to read input file day0... | code_fim | hard | {
"lang": "rust",
"repo": "CodeGradox/advent_of_code_2018",
"path": "/day01/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut cur = 0;
while let Some(frequency) = iter.next() {
if lookup.contains(&cur) {
break;
}
lookup.insert(cur);
cur += frequency;
}
cur
}
#[cfg(test)]
mod test {
use super::{ part1, part2 };
#[test]
fn test_part1() {
asse... | code_fim | hard | {
"lang": "rust",
"repo": "CodeGradox/advent_of_code_2018",
"path": "/day01/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(part1(), 484);
}
#[test]
fn test_part2() {
assert_eq!(part2(), 367);
}
}<|fim_prefix|>// repo: CodeGradox/advent_of_code_2018 path: /day01/src/main.rs
use std::fs;
use std::collections::HashSet;
fn main() {
println!("Part 1: {}", part1());
println!("Pa... | code_fim | medium | {
"lang": "rust",
"repo": "CodeGradox/advent_of_code_2018",
"path": "/day01/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: carado/enum-traits path: /pm/lib.rs
//use ::utl::*;
use {
::proc_macro::TokenStream,
::proc_macro2::{Span, TokenStream as TokenStream2},
::quote::quote,
::num_bigint::BigInt,
::syn::{Result, Error, Ident, spanned::Spanned},
};
fn reprs(item: &syn::DeriveInput) -> Result<Vec<Vec<Ident>>> {... | code_fim | hard | {
"lang": "rust",
"repo": "carado/enum-traits",
"path": "/pm/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn render_bigint(value: &BigInt) -> syn::LitInt {
syn::LitInt::new(&format!("{}", &value), Span::call_site())
}
fn quote_bigint(value: &BigInt) -> TokenStream2 {
let lit = render_bigint(value);
quote!(#lit)
}
#[proc_macro_derive(DiscriminantValues)]
pub fn derive_discriminant_discrs(input: TokenStrea... | code_fim | hard | {
"lang": "rust",
"repo": "carado/enum-traits",
"path": "/pm/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> snake.update();
if snake.is_dead() {
snake.respawn();
pellet.respawn(snake.occupied_tiles());
continue;
}
if snake.can_eat(pellet.current_location()) {
snake.grow();
pellet.respawn(snake.occupied_tiles());
... | code_fim | hard | {
"lang": "rust",
"repo": "kaypour/snake-rs",
"path": "/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kaypour/snake-rs path: /src/main.rs
extern crate sdl2;
use std::time::Duration;
use sdl2::event::Event;
use sdl2::keyboard::Keycode;
use sdl2::pixels::Color;
use pellet::Pellet;
use snake::{Direction, Snake};
mod pellet;
mod snake;
const WINDOW_WIDTH: i32 = 800;
const WINDOW_HEIGHT: i32 = 6... | code_fim | hard | {
"lang": "rust",
"repo": "kaypour/snake-rs",
"path": "/src/main.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut combatant = combatant_with_initial_hp(20);
combatant.apply_damage(10);
let dice_roller = FixedDiceRoller::shared();
dice_roller.borrow_mut().next_roll(10, 2);
dice_roller.borrow_mut().next_roll(10, 7);
let result1 = combatant.heal(dice_roller.clone());
assert_eq!(comba... | code_fim | hard | {
"lang": "rust",
"repo": "wolfgang/scrolling_hero",
"path": "/src/_tests/unit/combatant_test.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wolfgang/scrolling_hero path: /src/_tests/unit/combatant_test.rs
use std::cell::RefCell;
use std::rc::Rc;
use crate::game::combatant::{Combatant, CombatantConfig, CombatResult};
use super::fixed_dice_roller::FixedDiceRoller;
#[test]
fn with_config_takes_values_from_given_config() {
let co... | code_fim | hard | {
"lang": "rust",
"repo": "wolfgang/scrolling_hero",
"path": "/src/_tests/unit/combatant_test.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let result1 = combatant.heal(dice_roller.clone());
assert_eq!(combatant.hp, 12);
let result2 = combatant.heal(dice_roller.clone());
assert_eq!(combatant.hp, 19);
assert_eq!(result1, 2);
assert_eq!(result2, 7);
}
#[test]
fn heal_caps_at_max_hp() {
let mut combatant = combatant... | code_fim | hard | {
"lang": "rust",
"repo": "wolfgang/scrolling_hero",
"path": "/src/_tests/unit/combatant_test.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>[inline(always)]
pub fn ep5(&self) -> EP5_R {
EP5_R::new(((self.bits >> 5) & 0x01) != 0)
}
#[doc = "Bit 6 - RX Endpoint 6 Interrupt"]
#[inline(always)]
pub fn ep6(&self) -> EP6_R {
EP6_R::new(((self.bits >> 6) & 0x01) != 0)
}
#[doc = "Bit 7 - RX Endpoint 7 Inter... | code_fim | hard | {
"lang": "rust",
"repo": "m-labs/dslite2svd",
"path": "/crates/tm4c123x/src/usb0/rxis.rs",
"mode": "spm",
"license": "0BSD",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: m-labs/dslite2svd path: /crates/tm4c123x/src/usb0/rxis.rs
#[doc = "Reader of register RXIS"]
pub type R = crate::R<u16, super::RXIS>;
#[doc = "Reader of field `EP1`"]
pub type EP1_R = crate::R<bool, bool>;
#[doc = "Reader of field `EP2`"]
pub type EP2_R = crate::R<bool, bool>;
#[doc = "Reader of... | code_fim | hard | {
"lang": "rust",
"repo": "m-labs/dslite2svd",
"path": "/crates/tm4c123x/src/usb0/rxis.rs",
"mode": "psm",
"license": "0BSD",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zzl133/my_rust_road path: /learn-rust/net/use_serde1/src/main.rs
/// serder crate 是Serder生态的核心
/// serde_derive crate 提供必要的工具
/// 使用过程宏来派生 Serialize 和 Deserialize
/// 但是serde只提供序列化和反序列化的框架,具体操作还需要依赖具体的包
/// 如serde_json和serde_yaml等
use serde::{Serialize, Deserialize};
<|fim_suffix|> let ... | code_fim | hard | {
"lang": "rust",
"repo": "zzl133/my_rust_road",
"path": "/learn-rust/net/use_serde1/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
let config = ServerConf::new(100, true, String::from("123"));
{
println!("json!");
let serializer = serde_json::to_string(&config).unwrap();
println!("serialized : {:#?}", serializer);
let deserialized : ServerConf = serde_json::from_str(&serializer).... | code_fim | medium | {
"lang": "rust",
"repo": "zzl133/my_rust_road",
"path": "/learn-rust/net/use_serde1/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: c0ldch0c0l8/iced_practice path: /src/counter.rs
use iced::{Align, Button, Column, Sandbox, Text, button};
#[derive(Default)]
pub struct Counter {
value: i32,
increment_pressed: button::State,
decrement_pressed: button::State
}
#[derive(Debug, Clone, Copy)]
pub enum Message {
I... | code_fim | medium | {
"lang": "rust",
"repo": "c0ldch0c0l8/iced_practice",
"path": "/src/counter.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Describes the application itself.
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct BaseAttributes {
pub name: String,
pub target_url: String,
#[serde(default)]
pub recovery: bool,
}
impl BaseAttributes {
/// Serialises as a JSON string.
pub fn to_json_str(&self) -> R... | code_fim | hard | {
"lang": "rust",
"repo": "Satanachia/liftinstall",
"path": "/src/config.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Satanachia/liftinstall path: /src/config.rs
//! config.rs
//!
//! Contains Config structures, as well as means of serialising them.
use toml;
use toml::de::Error as TomlError;
use serde_json::{self, Error as SerdeError};
use crate::sources::get_by_name;
use crate::sources::types::Release;
//... | code_fim | hard | {
"lang": "rust",
"repo": "Satanachia/liftinstall",
"path": "/src/config.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Freaky/rust-bitrw path: /tests/bitrw.rs
extern crate bitrw;
extern crate rand;
use rand::Rng;
use std::io::Cursor;
const MASKS: [u64; 64] = [
0,
0b1,
0b11,
0b111,
0b1111,
0b11111,
0b111111,
0b1111111,
0b11111111,
0b111111111,
0b1111111111,
0b1111... | code_fim | hard | {
"lang": "rust",
"repo": "Freaky/rust-bitrw",
"path": "/tests/bitrw.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut rng = rand::thread_rng();
for len in 1..128 {
for _ in 1..128 {
let mut ios: Vec<TestBitIO> = Vec::with_capacity(len);
for _ in 0..len {
ios.push(TestBitIO {
nbits: rng.gen::<u8>() % 64,
value: rng.ge... | code_fim | hard | {
"lang": "rust",
"repo": "Freaky/rust-bitrw",
"path": "/tests/bitrw.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let camera = context.scene.graph[self.handle].as_camera_mut();
camera.set_enabled(self.old_value);
let editor_camera_handle = context.editor_scene.camera_controller.camera;
let editor_camera = context.scene.graph[editor_camera_handle].as_camera_mut();
let editor_ca... | code_fim | hard | {
"lang": "rust",
"repo": "ajmwagar/rusty-editor",
"path": "/src/scene/commands/camera.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ajmwagar/rusty-editor path: /src/scene/commands/camera.rs
use crate::{
define_node_command, get_set_swap,
scene::commands::{Command, SceneContext},
};
use rg3d::{
core::pool::Handle,
scene::{
camera::{ColorGradingLut, Exposure},
graph::Graph,
node::Node,
... | code_fim | hard | {
"lang": "rust",
"repo": "ajmwagar/rusty-editor",
"path": "/src/scene/commands/camera.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>define_node_command!(SetColorGradingLutCommand("Set Color Grading Lut", Option<ColorGradingLut>) where fn swap(self, node) {
get_set_swap!(self, node.as_camera_mut(), color_grading_lut, set_color_grading_map);
});
define_node_command!(SetColorGradingEnabledCommand("Set Color Grading Enabled", bool) w... | code_fim | hard | {
"lang": "rust",
"repo": "ajmwagar/rusty-editor",
"path": "/src/scene/commands/camera.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: turtle-bazon/icfpc-2018 path: /rust/reassembler/src/main.rs
extern crate icfpc2018_lib;
#[macro_use] extern crate clap;
//mod optimizer;
//use optimizer::Optimizer;
use clap::Arg;
use std::fs::File;
use std::io::{Read,Write};
use std::collections::VecDeque;
use std::iter::DoubleEndedIterator;
... | code_fim | hard | {
"lang": "rust",
"repo": "turtle-bazon/icfpc-2018",
"path": "/rust/reassembler/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let app = app_from_crate!()
.arg(Arg::with_name("source")
.display_order(1)
.short("s")
.long("source")
.help("Source trace (In)",)
.takes_value(true))
.arg(Arg::with_name("target")
.display_order(2)
... | code_fim | hard | {
"lang": "rust",
"repo": "turtle-bazon/icfpc-2018",
"path": "/rust/reassembler/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Kamil2601/University path: /Studia_inzynierskie/Semestr_5/Rust/Lista_3/zad2/zad2.rs
fn number(bus_stops:&[(i32,i32)]) -> i32 {
bus_stops.iter().map(|(x,y) : &(i32, i32) | {x-y}).sum()
}
fn main(){
}
mod tests {
use super::*;
#[test]
fn test1() {
assert_eq!(number(&[(10,0... | code_fim | hard | {
"lang": "rust",
"repo": "Kamil2601/University",
"path": "/Studia_inzynierskie/Semestr_5/Rust/Lista_3/zad2/zad2.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(number(&[(1,0),(1,0),(1,0)]), 3);
}
#[test]
fn test8() {
assert_eq!(number(&[(10,0),(0,5)]), 5);
}
#[test]
fn test9() {
assert_eq!(number(&[(10,0),(0,10),(10,0)]), 10);
}
#[test]
fn test10() {
assert_eq!(number(&[(2,1),(1,2)]), 0);
}
}... | code_fim | medium | {
"lang": "rust",
"repo": "Kamil2601/University",
"path": "/Studia_inzynierskie/Semestr_5/Rust/Lista_3/zad2/zad2.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Default for Player {
fn default() -> Self {
Player {
velocity_x: 0.0,
velocity_y: 0.0,
speed: 200.0,
}
}
}
impl Component for Player {
type Storage = DenseVecStorage<Player>;
}<|fim_prefix|>// repo: max-the-mage/tiles_testing path: /sr... | code_fim | medium | {
"lang": "rust",
"repo": "max-the-mage/tiles_testing",
"path": "/src/game/components/player.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: max-the-mage/tiles_testing path: /src/game/components/player.rs
use amethyst::{
ecs::prelude::*,
};
<|fim_suffix|> Player {
velocity_x: 0.0,
velocity_y: 0.0,
speed: 200.0,
}
}
}
impl Component for Player {
type Storage = DenseVecSt... | code_fim | medium | {
"lang": "rust",
"repo": "max-the-mage/tiles_testing",
"path": "/src/game/components/player.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn film_lower_left_corner(&self) -> Point3 {
Vec3::new(-self.film_width / 2.0, -self.film_height / 2.0, -self.film_distance)
}
}<|fim_prefix|>// repo: Sroka/raytracing_in_one_weekend_in_rust path: /src/camera.rs
use crate::point3::Point3;
use crate::vec3::Vec3;
use std::borrow::Borrow... | code_fim | hard | {
"lang": "rust",
"repo": "Sroka/raytracing_in_one_weekend_in_rust",
"path": "/src/camera.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Sroka/raytracing_in_one_weekend_in_rust path: /src/camera.rs
use crate::point3::Point3;
use crate::vec3::Vec3;
use std::borrow::Borrow;
<|fim_suffix|> pub fn film_lower_left_corner(&self) -> Point3 {
Vec3::new(-self.film_width / 2.0, -self.film_height / 2.0, -self.film_distance)
... | code_fim | hard | {
"lang": "rust",
"repo": "Sroka/raytracing_in_one_weekend_in_rust",
"path": "/src/camera.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let file_id_2 = file_center
.put_file_by_buffer_temporarily(image_small.clone(), "", None)
.await
.unwrap();
assert_ne!(file_id_1, file_id_2);
}
{
let file_id =
file_center.put_file_by_buffer_temporarily(image_big.clone(), "... | code_fim | hard | {
"lang": "rust",
"repo": "magiclen/mongo-file-center",
"path": "/tests/temporary.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: magiclen/mongo-file-center path: /tests/temporary.rs
mod common;
use common::*;
use mongo_file_center::FileCenter;
use tokio::fs::{self, File};
#[tokio::test]
async fn temporary() {
let uri = get_mongodb_uri("test_temporary");
let file_center = FileCenter::new(uri).await.unwrap();
... | code_fim | hard | {
"lang": "rust",
"repo": "magiclen/mongo-file-center",
"path": "/tests/temporary.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_ne!(file_id_1, file_id_2);
}
{
let file_id = file_center
.put_file_by_reader_temporarily(File::open(IMAGE_BIG_PATH).await.unwrap(), "", None)
.await
.unwrap();
assert!(file_center.get_file_item_by_id(file_id).await.unwrap().is_so... | code_fim | hard | {
"lang": "rust",
"repo": "magiclen/mongo-file-center",
"path": "/tests/temporary.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dnsl48/yamlette path: /src/orchestra/conductor.rs
LE_TOP_BORDER) && (self.styled & VOLUME_STYLE_TOP_BORDER != VOLUME_STYLE_TOP_BORDER) {
self.styled |= VOLUME_STYLE_TOP_BORDER;
self.zero_level_nodes += 1;
let mut record = Record::new (0);
record.m... | code_fim | hard | {
"lang": "rust",
"repo": "dnsl48/yamlette",
"path": "/src/orchestra/conductor.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dnsl48/yamlette path: /src/orchestra/conductor.rs
let volume_idx = self.idx;
if (self.styles & VOLUME_STYLE_DIR_YAML == VOLUME_STYLE_DIR_YAML) && (self.styled & VOLUME_STYLE_DIR_YAML != VOLUME_STYLE_DIR_YAML) {
self.styled |= VOLUME_STYLE_DIR_YAML;
self... | code_fim | hard | {
"lang": "rust",
"repo": "dnsl48/yamlette",
"path": "/src/orchestra/conductor.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if record.level != 0 { continue 'vol_loop; }
rec_cnt += 1;
rope = record.get_rope ();
rope_idx = 0;
'rope_loop: loop {
let (size, new_index, done) = rope.unrope (&mut performer_buffers[perf_idx], &self.r... | code_fim | hard | {
"lang": "rust",
"repo": "dnsl48/yamlette",
"path": "/src/orchestra/conductor.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stumash/AdventOfCode2019 path: /day02/src/main.rs
use std::io;
fn main() {
let mut line = String::new();
io::stdin().read_line(&mut line).unwrap();
let mut nums: Vec<u32> = line
.trim()
.split(",")
.map(|s| s.parse().unwrap())
.collect();
let de... | code_fim | hard | {
"lang": "rust",
"repo": "stumash/AdventOfCode2019",
"path": "/day02/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn run_program(nums_p: &Vec<u32>) -> u32 {
let mut nums = nums_p.clone();
for i in (0..nums.len()-1).step_by(4) {
match OpCode::new(nums[i]) {
OpCode::Add => {
let store_index = nums[i+3];
nums[store_index as usize] = nums[nums[i+1] as usize] + ... | code_fim | hard | {
"lang": "rust",
"repo": "stumash/AdventOfCode2019",
"path": "/day02/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("-----------------------------------------------------");
for i in (0..nums.len()).step_by(4) {
if i+1 < nums.len() {
println!("at {} do {} to {} {} {}", i, nums[i], nums[i+1], nums[i+2], nums[i+3]);
} else {
println!("at {} do {} -", i, nums[i]);
... | code_fim | hard | {
"lang": "rust",
"repo": "stumash/AdventOfCode2019",
"path": "/day02/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/rust path: /src/tools/clippy/clippy_lints/src/redundant_closure_call.rs
use crate::rustc_lint::LintContext;
use clippy_utils::diagnostics::{span_lint, span_lint_and_then};
use clippy_utils::get_parent_expr;
use clippy_utils::sugg::Sugg;
use if_chain::if_chain;
use rustc_errors::Applica... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/src/tools/clippy/clippy_lints/src/redundant_closure_call.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> cx: &LateContext<'tcx>,
block: &'tcx hir::Block<'_>,
path: &'tcx hir::Path<'tcx>,
) -> usize {
struct ClosureUsageCount<'a, 'tcx> {
cx: &'a LateContext<'tcx>,
path: &'tcx hir::Path<'tcx>,
count: usize,
... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/src/tools/clippy/clippy_lints/src/redundant_closure_call.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl From<i64> for Rational {
// TODO
fn from(src: i64) -> Rational {
Rational {
n: src,
d: 1,
}
}
}<|fim_prefix|>// repo: parkje0623/multi-languages path: /Rust/Exercises/exer8/src/rational.rs
use std::fmt;
fn gcd(a: i64, b: i64) -> i64 {
// TODO
... | code_fim | hard | {
"lang": "rust",
"repo": "parkje0623/multi-languages",
"path": "/Rust/Exercises/exer8/src/rational.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: parkje0623/multi-languages path: /Rust/Exercises/exer8/src/rational.rs
use std::fmt;
fn gcd(a: i64, b: i64) -> i64 {
// TODO
let mut max = a;
let mut min = b;
if min > max {
let temp = max;
max = min;
min = temp;
}
<|fim_suffix|>impl From<i64> for Ra... | code_fim | hard | {
"lang": "rust",
"repo": "parkje0623/multi-languages",
"path": "/Rust/Exercises/exer8/src/rational.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: benjamingroeber/bitbucket-api path: /src/teams/mod.rs
pub mod members;
use api;
use api::BitBucketQuery;
#[derive(Clone, Debug)]
pub struct TeamsBuilder {
teamname: String,
}
impl TeamsBuilder {
pub(crate) fn new(username: &str) -> TeamsBuilder {
TeamsBuilder {
tea... | code_fim | medium | {
"lang": "rust",
"repo": "benjamingroeber/bitbucket-api",
"path": "/src/teams/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> BitBucketQuery::new(format!("teams/{}", self.teamname,))
}
}
use std::collections::HashMap;
#[derive(Debug, Clone, Deserialize)]
pub struct Team {
pub username: String,
pub display_name: String,
pub uuid: String,
pub links: HashMap<String, api::Link>,
}<|fim_prefix|>// repo: b... | code_fim | hard | {
"lang": "rust",
"repo": "benjamingroeber/bitbucket-api",
"path": "/src/teams/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> factory.into_handle()
}
}
impl<T> From<ReadHandle<T>> for ReadHandleFactory<T> {
fn from(handle: ReadHandle<T>) -> Self {
handle.into_factory()
}
}
impl<T> Drop for ReadHandle<T> {
fn drop(&mut self) {
if let Some(inner) = self.inner.take() {
if Arc::str... | code_fim | hard | {
"lang": "rust",
"repo": "Skarlett/evc",
"path": "/src/read.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(inner) = self.inner.take() {
if Arc::strong_count(&inner) == 1 {
let readers_inner = inner.swap(ptr::null_mut(), Ordering::Relaxed);
mem::drop(unsafe { Box::from_raw(readers_inner) });
}
}
}
}
impl<T> Clone for ReadHan... | code_fim | hard | {
"lang": "rust",
"repo": "Skarlett/evc",
"path": "/src/read.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Skarlett/evc path: /src/read.rs
use std::cell::Cell;
use std::marker::PhantomData;
use std::mem;
use std::ops::Deref;
use std::ptr;
use std::sync::atomic;
use std::sync::atomic::{AtomicPtr, AtomicUsize, Ordering};
use std::sync::Arc;
use crate::{Epoch, Epochs, Inner, USIZE_MSB};
/// A handle u... | code_fim | hard | {
"lang": "rust",
"repo": "Skarlett/evc",
"path": "/src/read.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fredmorcos/gstats path: /attic/new/src/id.rs
#![warn(clippy::all)]
//! Data structures for `Id`s and references to transactions.
use derive_more::Display;
use std::convert::TryFrom;
use std::fmt::{self, Debug, Display};
use std::num::NonZeroUsize;
/// Errors that can happen when dealing with ... | code_fim | hard | {
"lang": "rust",
"repo": "fredmorcos/gstats",
"path": "/attic/new/src/id.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Into<usize> for Id {
fn into(self) -> usize {
match self {
Id::Root => 1,
Id::Transaction(id) => id.into(),
}
}
}
impl Debug for Id {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
Display::fmt(self, f)
}
}
#[cfg(test)]
mod id_... | code_fim | hard | {
"lang": "rust",
"repo": "fredmorcos/gstats",
"path": "/attic/new/src/id.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[display(fmt = "Tx:{}", "_0")]
Transaction(NonRootId),
}
impl From<NonRootId> for Id {
fn from(value: NonRootId) -> Self {
Id::Transaction(value)
}
}
impl TryFrom<usize> for Id {
type Error = <NonRootId as TryFrom<usize>>::Error;
fn try_from(value: usize) -> Result<Self... | code_fim | hard | {
"lang": "rust",
"repo": "fredmorcos/gstats",
"path": "/attic/new/src/id.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RustyYato/double-buffer-v2 path: /src/base.rs
use crate::traits::{RawDoubleBuffer, RawParts, Strategy};
mod raw_buffers;
mod reader;
mod writer;
use raw_buffers::RawBuffers;
use radium::Radium;
pub use reader::{Reader, ReaderGuard};
pub use writer::{Split, SplitMut, Swap, Writer};
<|fim_suff... | code_fim | hard | {
"lang": "rust",
"repo": "RustyYato/double-buffer-v2",
"path": "/src/base.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<S: Strategy, B> Inner<[B; 2], S> {
pub fn new(strategy: S, front: B, back: B) -> Self { Self::from_raw_parts(strategy, [front, back]) }
}
impl<S: Strategy, R: RawDoubleBuffer> Inner<R, S> {
pub fn from_raw_parts(strategy: S, buffers: R) -> Self {
Self {
strategy,
... | code_fim | hard | {
"lang": "rust",
"repo": "RustyYato/double-buffer-v2",
"path": "/src/base.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<S: Strategy, R: RawDoubleBuffer> Inner<R, S> {
pub fn from_raw_parts(strategy: S, buffers: R) -> Self {
Self {
strategy,
which: Radium::new(false),
raw: RawBuffers::new(buffers),
}
}
}<|fim_prefix|>// repo: RustyYato/double-buffer-v2 path: ... | code_fim | hard | {
"lang": "rust",
"repo": "RustyYato/double-buffer-v2",
"path": "/src/base.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub struct RwLockWriteGuard<'a, T: ?Sized + 'a> {
lock: RefMut<'a, T>,
}
impl<T: ?Sized> Deref for RwLockReadGuard<'_, T> {
type Target = T;
fn deref(&self) -> &T {
&self.lock.deref()
}
}
impl<T: ?Sized> Deref for RwLockWriteGuard<'_, T> {
type Target = T;
fn deref(&self) -> &T {
&self.lock.... | code_fim | hard | {
"lang": "rust",
"repo": "TheBlueMatt/rust-lightning",
"path": "/lightning/src/sync.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T: ?Sized> Deref for RwLockWriteGuard<'_, T> {
type Target = T;
fn deref(&self) -> &T {
&self.lock.deref()
}
}
impl<T: ?Sized> DerefMut for RwLockWriteGuard<'_, T> {
fn deref_mut(&mut self) -> &mut T {
self.lock.deref_mut()
}
}
impl<T> RwLock<T> {
pub fn new(inner: T) -> RwLock<T> {
Rw... | code_fim | hard | {
"lang": "rust",
"repo": "TheBlueMatt/rust-lightning",
"path": "/lightning/src/sync.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TheBlueMatt/rust-lightning path: /lightning/src/sync.rs
pub use ::alloc::sync::Arc;
use core::ops::{Deref, DerefMut};
use core::time::Duration;
use core::cell::{RefCell, Ref, RefMut};
pub type LockResult<Guard> = Result<Guard, ()>;
pub struct Condvar {}
impl Condvar {
pub fn new() -> Condvar... | code_fim | hard | {
"lang": "rust",
"repo": "TheBlueMatt/rust-lightning",
"path": "/lightning/src/sync.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: radrow/satisfaction path: /solver/src/cadical_solver.rs
use crate::solvers::InterruptibleSolver;
use crate::{SATSolution, Solver, CNF};
use cadical;
pub struct CadicalSolver;
impl Solver for CadicalSolver {
fn solve(&self, formula: &CNF) -> SATSolution {
<|fim_suffix|> match solver.... | code_fim | hard | {
"lang": "rust",
"repo": "radrow/satisfaction",
"path": "/solver/src/cadical_solver.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let num_variables = formula.num_variables;
for clause in &formula.clauses {
let mut lits = Vec::new();
lits.reserve(clause.vars.len());
for var in &clause.vars {
lits.push(var.to_i32())
}
solver.add_clause(lits.int... | code_fim | hard | {
"lang": "rust",
"repo": "radrow/satisfaction",
"path": "/solver/src/cadical_solver.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(
str::from_utf8(&result.stdout).unwrap(),
"14\n8\n4\n0\ntrue\ntrue\ntrue\ntrue\n0\n0\n0\n0\n4\n"
);
assert!(result.status.success());
}
#[test]
fn unexpected_character() {
let result = Command::new("cargo")
.args(&[
"run",
"-q",
... | code_fim | hard | {
"lang": "rust",
"repo": "glugg23/rox",
"path": "/tests/misc.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.