text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: kgv/lambda path: /macro/src/lambda.rs
use proc_macro2::{Span, TokenStream, TokenTree};
use quote::{quote, ToTokens};
use std::collections::HashSet;
use syn::{
parenthesized,
parse::{Parse, ParseStream},
parse_quote,
punctuated::Punctuated,
token, Error, Expr, Ident, Pat, Resu... | code_fim | hard | {
"lang": "rust",
"repo": "kgv/lambda",
"path": "/macro/src/lambda.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yaozijian/RustProgramming path: /chap12/src/section3_step1.rs
use std::env;
use std::fs::File;
use std::io::prelude::*;
pub fn main() {
let args: Vec<String> = env::args().collect();
println!("{:?}", args);
<|fim_suffix|> let mut file = File::open(filename).expect("file not ... | code_fim | medium | {
"lang": "rust",
"repo": "yaozijian/RustProgramming",
"path": "/chap12/src/section3_step1.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn parse_config(args: &[String]) -> (&str, &str) {
let filename = &args[1];
let query = &args[2];
(filename, query)
}<|fim_prefix|>// repo: yaozijian/RustProgramming path: /chap12/src/section3_step1.rs
use std::env;
use std::fs::File;
use std::io::prelude::*;
pub fn main() {
let... | code_fim | hard | {
"lang": "rust",
"repo": "yaozijian/RustProgramming",
"path": "/chap12/src/section3_step1.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> vec![Example {
description: "drop column a",
example: "[[a b]; [1 2] [3 4]] | pls convert | pls dtypes",
result: None,
}]
}
}
fn command(args: CommandArgs) -> Result<OutputStream, ShellError> {
let tag = args.call_info.name_tag.clone();
let ... | code_fim | hard | {
"lang": "rust",
"repo": "apatrushev/nushell",
"path": "/crates/nu-command/src/commands/dataframe/dtypes.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: apatrushev/nushell path: /crates/nu-command/src/commands/dataframe/dtypes.rs
use crate::prelude::*;
use nu_engine::WholeStreamCommand;
use nu_errors::ShellError;
use nu_protocol::{dataframe::PolarsData, Signature, TaggedDictBuilder, UntaggedValue};
pub struct DataFrame;
impl WholeStreamCommand... | code_fim | hard | {
"lang": "rust",
"repo": "apatrushev/nushell",
"path": "/crates/nu-command/src/commands/dataframe/dtypes.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn signature(&self) -> Signature {
Signature::build("pls dtypes")
}
fn run(&self, args: CommandArgs) -> Result<OutputStream, ShellError> {
command(args)
}
fn examples(&self) -> Vec<Example> {
vec![Example {
description: "drop column a",
... | code_fim | hard | {
"lang": "rust",
"repo": "apatrushev/nushell",
"path": "/crates/nu-command/src/commands/dataframe/dtypes.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // 0 と 1 は素数ではない
is_prime[0] = false;
is_prime[1] = false;
for i in 2..n+1 {
// is_prime[i]:
// それ以下の素数で割り切られていなければ True となる
if is_prime[i] {
// この if 文より i は素数なので
primes.push(i);
// 素数はそれ自身の最も小さい素因数であるから
spf[i] = S... | code_fim | hard | {
"lang": "rust",
"repo": "akimash/abc",
"path": "/142/d.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: akimash/abc path: /142/d.rs
use std::io::*;
use std::str::FromStr;
pub fn read<T: FromStr>() -> T {
let stdin = stdin();
let stdin = stdin.lock();
let token: String = stdin
.bytes()
.map(|c| c.expect("failed to read char") as char)
.skip_while(|c| c.is_whites... | code_fim | hard | {
"lang": "rust",
"repo": "akimash/abc",
"path": "/142/d.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // 最後にnが素数になっている場合はそれ自身も素因数に含めて終了
if n > 1 {
if hm_primes.contains_key(&n) {
let mut x = hm_primes.get_mut(&n).unwrap();
*x += 1;
} else {
hm_primes.insert(n, 1);
}
}
hm_primes
}
fn main() {
let a = read::<usize>();
let b... | code_fim | hard | {
"lang": "rust",
"repo": "akimash/abc",
"path": "/142/d.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rxRust/rxRust path: /src/scheduler.rs
use crate::{
prelude::*,
rc::{MutArc, RcDeref, RcDerefMut},
};
use futures::{future::CatchUnwind, ready, FutureExt};
use pin_project_lite::pin_project;
use std::time::Duration;
use std::{
any::Any,
fmt,
future::Future,
mem::swap,
panic::{self, ... | code_fim | hard | {
"lang": "rust",
"repo": "rxRust/rxRust",
"path": "/src/scheduler.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<Fut: Future + fmt::Debug> fmt::Debug for Remote<Fut> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_tuple("Remote").field(&self.future).finish()
}
}
impl<Fut: Future> Future for Remote<Fut> {
type Output = ();
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> ... | code_fim | hard | {
"lang": "rust",
"repo": "rxRust/rxRust",
"path": "/src/scheduler.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if cell.east.is_some() && cell.linked(cell.east.as_ref().unwrap()) {
top.push(' ');
} else {
top.push('|');
}
if cell.south.is_some() && cell.linked(cell.south.as_ref().unwrap()) {
bottom.push_str(" ");
... | code_fim | hard | {
"lang": "rust",
"repo": "suguni/maze-rs",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: suguni/maze-rs path: /src/main.rs
mod builder;
mod distance;
mod export_svg;
mod grid;
use svg;
fn main() {
let mut grid = grid::Grid::new(20, 20);
// builder::binary_tree(&mut grid);
builder::sidewinder(&mut grid);
let distance = distance::Distance::from(&grid, (19, 0));
... | code_fim | hard | {
"lang": "rust",
"repo": "suguni/maze-rs",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jakeprobst/psodropcheck path: /src/item.rs
//use std;
//use std::cmp::{Ordering};
//use std::fmt::Display;
//use std::fmt::Formatter;
//#[derive(Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
#[derive(Debug)]
pub struct Weapon {
pub name: String,
pub grind: u8,
pub special: String,
... | code_fim | hard | {
"lang": "rust",
"repo": "jakeprobst/psodropcheck",
"path": "/src/item.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug)]
pub struct Tech {
pub name: String,
pub level: u8,
}
/*impl std::fmt::Display for Item {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
//let x = self.data[2];
return write!(f, "itemz");
}
}*/
/*impl std::cmp::Ord for Item {
fn cmp(&... | code_fim | hard | {
"lang": "rust",
"repo": "jakeprobst/psodropcheck",
"path": "/src/item.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lnicola/axum path: /src/ws/mod.rs
// See the [module docs](crate::ws) for more details.
pub fn ws<F, B, T>(callback: F) -> WebSocketUpgrade<F, B, T>
where
F: WebSocketHandler<B, T>,
{
WebSocketUpgrade {
callback,
config: WebSocketConfig::default(),
protocols: Vec:... | code_fim | hard | {
"lang": "rust",
"repo": "lnicola/axum",
"path": "/src/ws/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Pin::new(&mut self.inner).poll_flush(cx).map_err(Into::into)
}
fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
Pin::new(&mut self.inner).poll_close(cx).map_err(Into::into)
}
}
/// A WebSocket message.
#[derive(Eq, PartialEq, Clone)... | code_fim | hard | {
"lang": "rust",
"repo": "lnicola/axum",
"path": "/src/ws/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lnicola/axum path: /src/ws/mod.rs
mRequest<B> for RequireAuth
//! where
//! B: Send,
//! {
//! type Rejection = StatusCode;
//!
//! async fn from_request(req: &mut RequestParts<B>) -> Result<Self, Self::Rejection> {
//! # unimplemented!()
//! // Put your auth logic he... | code_fim | hard | {
"lang": "rust",
"repo": "lnicola/axum",
"path": "/src/ws/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Shnatsel/rustsec path: /cvss/src/v3/base.rs
//! CVSS v3.1 Base Metric Group
mod a;
mod ac;
mod av;
mod c;
mod i;
mod pr;
mod s;
mod ui;
pub use self::{
a::Availability, ac::AttackComplexity, av::AttackVector, c::Confidentiality, i::Integrity,
pr::PrivilegesRequired, s::Scope, ui::UserI... | code_fim | hard | {
"lang": "rust",
"repo": "Shnatsel/rustsec",
"path": "/cvss/src/v3/base.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok((id, value))
})
.collect::<Result<Vec<_>>>()?;
let mut components = component_vec.iter();
let &(id, version_string) = components.next().ok_or(Error::InvalidPrefix {
prefix: s.to_owned(),
})?;
if id != PREFIX {
... | code_fim | hard | {
"lang": "rust",
"repo": "Shnatsel/rustsec",
"path": "/cvss/src/v3/base.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>'a> {
Position {
id,
currency,
amount,
market_value,
acquisition_cost,
}
}
}<|fim_prefix|>// repo: yuk1ty/spinoza path: /server/spinoza-server/src/models/position.rs
use models::currency::*;
use models::market_value::*;
#[de... | code_fim | hard | {
"lang": "rust",
"repo": "yuk1ty/spinoza",
"path": "/server/spinoza-server/src/models/position.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yuk1ty/spinoza path: /server/spinoza-server/src/models/position.rs
use models::currency::*;
use models::market_value::*;
#[derive(PartialEq, Clone)]
pub struct Position<'a> {
id: u32,
currency: &'a Currency<'a>, /<|fim_suffix|>'a> {
Position {
id,
currenc... | code_fim | hard | {
"lang": "rust",
"repo": "yuk1ty/spinoza",
"path": "/server/spinoza-server/src/models/position.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub trait Foo: Sized {
const WIDTH: usize;
fn arrayify(self) -> [Self; Self::WIDTH];
}
impl<T: Sized> Foo for T {
const WIDTH: usize = 1;
// @has - '//*[@id="tymethod.arrayify"]/*[@class="code-header"]' \
// 'fn arrayify(self) -> [Self; Self::WIDTH]'
fn arrayify(self) -> [Self; ... | code_fim | medium | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/tests/rustdoc/generic_const_exprs.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // @has - '//*[@id="tymethod.arrayify"]/*[@class="code-header"]' \
// 'fn arrayify(self) -> [Self; Self::WIDTH]'
fn arrayify(self) -> [Self; Self::WIDTH] {
[self]
}
}<|fim_prefix|>// repo: rust-lang/rust path: /tests/rustdoc/generic_const_exprs.rs
// Regression test for <https://g... | code_fim | medium | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/tests/rustdoc/generic_const_exprs.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/rust path: /tests/rustdoc/generic_const_exprs.rs
// Regression test for <https://github.com/rust-lang/rust/issues/92859>.
<|fim_suffix|> // @has - '//*[@id="tymethod.arrayify"]/*[@class="code-header"]' \
// 'fn arrayify(self) -> [Self; Self::WIDTH]'
fn arrayify(self) -> [Se... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/tests/rustdoc/generic_const_exprs.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl ChainStateReader for RemoteChainStateReader {
fn get_with_proof(&self, access_path: &AccessPath) -> Result<StateWithProof> {
let peer_id = self
.peer_id
.clone()
.ok_or_else(|| anyhow!("peer id not set"))?;
let state_root = self
.sta... | code_fim | hard | {
"lang": "rust",
"repo": "foxtan/starcoin",
"path": "/network-rpc/api/src/remote_chain_state.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn get_account_state(&self, account_address: &AccountAddress) -> Result<Option<AccountState>> {
//TODO: How to verify it
let peer_id = self
.peer_id
.clone()
.ok_or_else(|| anyhow!("peer id not set"))?;
let state_root = self
.stat... | code_fim | hard | {
"lang": "rust",
"repo": "foxtan/starcoin",
"path": "/network-rpc/api/src/remote_chain_state.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: foxtan/starcoin path: /network-rpc/api/src/remote_chain_state.rs
// Copyright (c) The Starcoin Core Contributors
// SPDX-License-Identifier: Apache-2.0
use crate::{gen_client::NetworkRpcClient, GetAccountState, GetStateWithProof};
use anyhow::{anyhow, Result};
use starcoin_crypto::HashValue;
us... | code_fim | hard | {
"lang": "rust",
"repo": "foxtan/starcoin",
"path": "/network-rpc/api/src/remote_chain_state.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg_attr(not(test), alloc_error_handler)]
#[allow(unused)]
fn alloc_error_handler(layout: Layout) -> ! {
panic!("alloc error for layout {:?}", layout)
}
pub fn init_heap() {
unsafe {
HEAP.lock().init(
HEAP_SPACE.as_ptr() as usize, HEAP_SIZE
)
}
}<|fim_prefix|>// ... | code_fim | medium | {
"lang": "rust",
"repo": "HUST-OS/luojia-os-labs",
"path": "/02a-complex-ctx-kern/user/src/heap.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: HUST-OS/luojia-os-labs path: /02a-complex-ctx-kern/user/src/heap.rs
use alloc::alloc::Layout;
use buddy_system_allocator::LockedHeap;
const HEAP_SIZE: usize = 16 * 1024;
static mut HEAP_SPACE: [u8; HEAP_SIZE] = [0; HEAP_SIZE];
// 全局的堆分配器
#[global_allocator]
static HEAP: LockedHeap = LockedHea... | code_fim | medium | {
"lang": "rust",
"repo": "HUST-OS/luojia-os-labs",
"path": "/02a-complex-ctx-kern/user/src/heap.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> panic!("alloc error for layout {:?}", layout)
}
pub fn init_heap() {
unsafe {
HEAP.lock().init(
HEAP_SPACE.as_ptr() as usize, HEAP_SIZE
)
}
}<|fim_prefix|>// repo: HUST-OS/luojia-os-labs path: /02a-complex-ctx-kern/user/src/heap.rs
use alloc::alloc::Layout;
use bu... | code_fim | hard | {
"lang": "rust",
"repo": "HUST-OS/luojia-os-labs",
"path": "/02a-complex-ctx-kern/user/src/heap.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Remove repeated attributes from the method, to omit incorrect expansion.
argument.attrs = mem::take(&mut argument.attrs)
.into_iter()
.filter(|attr| !path_eq_single(&attr.path, "graphql"))
.collect();
let meta = ArgumentMeta::from_attrs("grap... | code_fim | hard | {
"lang": "rust",
"repo": "LegNeato/juniper",
"path": "/juniper_codegen/src/graphql_interface/attr.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> Some(Field {
name,
ty,
description,
deprecated,
method: method_ident.clone(),
arguments,
is_async: method.sig.asyncness.is_some(),
})
}
/// Parses [`MethodArgument`] from the given trait method arg... | code_fim | hard | {
"lang": "rust",
"repo": "LegNeato/juniper",
"path": "/juniper_codegen/src/graphql_interface/attr.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LegNeato/juniper path: /juniper_codegen/src/graphql_interface/attr.rs
path: downcast.inner().clone(),
});
}
None => err_only_implementer_downcast(&downcast.span_joined()),
}
}
proc_macro_error::abort_if_dirty();
let mut ... | code_fim | hard | {
"lang": "rust",
"repo": "LegNeato/juniper",
"path": "/juniper_codegen/src/graphql_interface/attr.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> env_logger::init().unwrap();
let mut g = graphlib::Graph::new();
g.add_edge(0, 1, 1);
g.add_edge(0, 2, 1);
g.add_edge(1, 2, 1);
g.add_edge(2, 3, 2);
g.add_edge(1, 3, 1);
g.add_edge(0, 3, 3);
warn!("Graph: {:?}", g);
warn!("Shortest path from 0 -> 3? {:?}", g.shortes... | code_fim | easy | {
"lang": "rust",
"repo": "willsalz/graphlib",
"path": "/examples/example.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: willsalz/graphlib path: /examples/example.rs
extern crate graphlib;
#[macro_use]
extern crate log;
extern crate env_logger;
<|fim_suffix|> env_logger::init().unwrap();
let mut g = graphlib::Graph::new();
g.add_edge(0, 1, 1);
g.add_edge(0, 2, 1);
g.add_edge(1, 2, 1);
g.ad... | code_fim | easy | {
"lang": "rust",
"repo": "willsalz/graphlib",
"path": "/examples/example.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: akoarum/study-rust path: /generics/src/main.rs
use generics::{self, NewsArticle, Tweet, Summary};
fn get_largest<T: PartialOrd + Copy>(list: &[T]) -> &T {
let mut largest = &list[0];
for item in list {
if item > largest {
largest = item;
}
}
largest
... | code_fim | hard | {
"lang": "rust",
"repo": "akoarum/study-rust",
"path": "/generics/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("The largest number is {}", result);
assert_eq!(result, &100);
let char_list = vec!['y', 'm', 'a', 'q'];
let result = get_largest(&char_list);
println!("The largest char is {}", result);
assert_eq!(result, &'y');
let tweet = Tweet {
username: String::from("ma... | code_fim | medium | {
"lang": "rust",
"repo": "akoarum/study-rust",
"path": "/generics/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: qiniu/rust-sdk path: /http-client/src/regions/endpoints_provider/bucket_domains_provider.rs
use super::{
super::{
super::{Authorization, HttpClient},
cache_key::CacheKey,
},
endpoints_cache::EndpointsCache,
ApiResult, Endpoint, Endpoints, EndpointsProvider, GetOpt... | code_fim | hard | {
"lang": "rust",
"repo": "qiniu/rust-sdk",
"path": "/http-client/src/regions/endpoints_provider/bucket_domains_provider.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl BucketDomainsProvider {
fn make_cache_key(&self, credential: &Credential) -> CacheKey {
CacheKey::new_from_endpoint_and_ak_and_bucket(
&self.queryer.uc_endpoints,
self.bucket_name.to_owned(),
credential.access_key().to_owned(),
)
}
fn d... | code_fim | hard | {
"lang": "rust",
"repo": "qiniu/rust-sdk",
"path": "/http-client/src/regions/endpoints_provider/bucket_domains_provider.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let endpoints: Endpoints = self
.queryer
.http_client
.get(&[ServiceName::Uc], &self.queryer.uc_endpoints)
.path("/v2/domains")
.authorization(Authorization::v2(&self.credential))
.append_query_pair("tbl", self.bucket_name.as_... | code_fim | hard | {
"lang": "rust",
"repo": "qiniu/rust-sdk",
"path": "/http-client/src/regions/endpoints_provider/bucket_domains_provider.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Two aspects that this protocol does not address is security/encryption and authenciation.
/// It is assumed that the lower level transport mechanism will do this. That is, part of
/// establishing a bi-directional channel will be to authenticate and ensure that security
/// needs are met. This protocol... | code_fim | hard | {
"lang": "rust",
"repo": "neofarm/backup-fam",
"path": "/src/peer.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: neofarm/backup-fam path: /src/peer.rs
/// The peer module defines traits and structures relevant to Peers.
/// As the name suggegts, Peers are equal participants in the application -
/// any peer can make a direct request of any other peer.
///
/// Peers communicate with each other over some bid... | code_fim | hard | {
"lang": "rust",
"repo": "neofarm/backup-fam",
"path": "/src/peer.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rerorero/wstetris path: /server/src/user.rs
use std::sync::*;
use std::sync::mpsc::*;
use server_command::*;
use user_rx::*;
pub type UserId = i32;
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct User {
pub id: UserId
}
impl User {
pub fn new(id: UserId) -> User {
return Us... | code_fim | medium | {
"lang": "rust",
"repo": "rerorero/wstetris",
"path": "/server/src/user.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn send_to(&self, cmd: &ServerCommand) -> bool {
match self.ch.send(ServerCommand::to_blob(&cmd)) {
Ok(v) => true,
Err(e) => {
println!("send_to ch failed!! {}", e);
false
}
}
}
}<|fim_prefix|>// repo: rerorero/wstetris path: /server/src/user.rs
u... | code_fim | hard | {
"lang": "rust",
"repo": "rerorero/wstetris",
"path": "/server/src/user.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn on_user_rx(&mut self, cmd: UserRx) {
match self.rx {
Some(_) => {}, //println!("already queued."),
None => self.rx = Some(cmd)
};
}
pub fn pop_user_rx(&mut self) -> Option<UserRx> {
let org = self.rx.clone();
self.rx = None;
return org;
}
pub fn send_to(&self, cmd: &ServerCom... | code_fim | hard | {
"lang": "rust",
"repo": "rerorero/wstetris",
"path": "/server/src/user.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: prisma/opentls path: /src/certificate.rs
use openssl::x509::X509;
/// An X509 certificate.
#[derive(Clone, Debug)]
pub struct Certificate(pub(crate) X509);
<|fim_suffix|> /// Parses a PEM-formatted X509 certificate.
pub fn from_pem(buf: &[u8]) -> crate::Result<Certificate> {
let... | code_fim | hard | {
"lang": "rust",
"repo": "prisma/opentls",
"path": "/src/certificate.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl From<X509> for Certificate {
fn from(inner: X509) -> Self {
Self(inner)
}
}<|fim_prefix|>// repo: prisma/opentls path: /src/certificate.rs
use openssl::x509::X509;
/// An X509 certificate.
#[derive(Clone, Debug)]
pub struct Certificate(pub(crate) X509);
impl Certificate {
/// P... | code_fim | hard | {
"lang": "rust",
"repo": "prisma/opentls",
"path": "/src/certificate.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: satylogin/CODEFORCES path: /1481/E - Sorting Books.rs
use std::cmp::{min, max};
fn main() {
use std::io::{self, Write};
let (stdin, stdout) = (io::stdin(), io::stdout());
let mut sc = cf_scanner::Scanner::new(stdin.lock());
let mut out = io::BufWriter::new(stdout.lock());
<|fi... | code_fim | hard | {
"lang": "rust",
"repo": "satylogin/CODEFORCES",
"path": "/1481/E - Sorting Books.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> impl<R: io::BufRead> Scanner<R> {
pub fn new(reader: R) -> Scanner<R> {
Scanner {
reader,
buf_str: Vec::new(),
buf_iter: "".split_ascii_whitespace(),
}
}
pub fn next<T: FromStr>(&mut self) -> T {
... | code_fim | hard | {
"lang": "rust",
"repo": "satylogin/CODEFORCES",
"path": "/1481/E - Sorting Books.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Component for Handler {
type Message = Msg;
type Properties = HandlerProps;
fn create(ctx: &Context<Self>) -> Self {
let on_tick = ctx.link().callback(|_| Msg::Tick);
let clock_handle = Interval::new(TICK_INTERVAL * 1000, move || on_tick.emit(()));
let config = C... | code_fim | hard | {
"lang": "rust",
"repo": "chorddown/chordr",
"path": "/webchordr/app/src/handler.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chorddown/chordr path: /webchordr/app/src/handler.rs
o, trace, warn};
use std::rc::Rc;
use tri::Tri;
use wasm_bindgen_futures::spawn_local;
use webchordr_common::route::AppRoute;
use webchordr_events::{Event, SetlistEvent, SettingsEvent, SortingChange};
use webchordr_persistence::browser_storage... | code_fim | hard | {
"lang": "rust",
"repo": "chorddown/chordr",
"path": "/webchordr/app/src/handler.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> todo!()
}
fn update(&mut self, _setlist: Setlist) {
todo!()
}
fn fetch_setlists(&mut self) {
todo!()
}
fn setlist_entry_add(&mut self, song: SetlistEntry) {
let song_id = song.id();
let current_setlist = self
.state
... | code_fim | hard | {
"lang": "rust",
"repo": "chorddown/chordr",
"path": "/webchordr/app/src/handler.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>id`
//! let jwt_svid = client.fetch_jwt_svid(target_audience, Some(&spiffe_id))?;
//!
//! // fetch a set of jwt bundles (public keys for validating jwt token)
//! let jwt_bundles_set = client.fetch_jwt_bundles()?;
//!
//! // get the JWT bundle associated to the trust domain
//! let jwt_bundle: &JwtBundle ... | code_fim | hard | {
"lang": "rust",
"repo": "ionut-arm/rust-spiffe",
"path": "/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ionut-arm/rust-spiffe path: /src/lib.rs
#![deny(missing_docs)]
#![warn(missing_debug_implementations)]
// #![warn(rust_2018_idioms)]
//! This library provides functions to interact with the [SPIFFE Workload API](https://github.com/spiffe/spiffe/blob/main/standards/SPIFFE_Workload_API.md)
//! to... | code_fim | hard | {
"lang": "rust",
"repo": "ionut-arm/rust-spiffe",
"path": "/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn default() -> Service {
Service::new("localhost", 80)
}
pub fn get_uri(&self) -> String {
let mut uri = if self.ssl {
String::from("https://")
} else {
String::from("http://")
};
uri.push_str(self.host_name.as_str());
... | code_fim | hard | {
"lang": "rust",
"repo": "Rafagd/webservices-rs",
"path": "/src/service/service.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Rafagd/webservices-rs path: /src/service/service.rs
use std::collections::HashMap;
use std::fmt::{ Debug, Error, Formatter };
use std::string::ToString;
use std::sync::{ Arc, Mutex };
extern crate hyper;
use self::hyper::server::{
Request as HttpRequest,
Response as HttpResponse,
S... | code_fim | hard | {
"lang": "rust",
"repo": "Rafagd/webservices-rs",
"path": "/src/service/service.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> vit_station.shutdown();
wallet_proxy.shutdown();
for node in nodes {
node.logger()
.assert_no_errors(&format!("Errors in logs for node: {}", node.alias()));
node.shutdown().unwrap();
}
controller.finalize();
}
#[tokio::test]
pub async fn load_test_private_... | code_fim | hard | {
"lang": "rust",
"repo": "stjordanis/vit-testing",
"path": "/integration-tests/src/non_functional/load.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stjordanis/vit-testing path: /integration-tests/src/non_functional/load.rs
use crate::non_functional::build_load_config;
use crate::non_functional::private_vote_test_scenario;
use crate::setup::vitup_setup;
use assert_fs::TempDir;
use iapyx::{IapyxLoad, Protocol};
use jormungandr_testing_utils::... | code_fim | hard | {
"lang": "rust",
"repo": "stjordanis/vit-testing",
"path": "/integration-tests/src/non_functional/load.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Returnes a sorted vector with the lowest version at index `0`.
pub(crate) fn versions_from(&self, version: &VersionAndTag) -> Vec<&VersionAndTag> {
let mut values: Vec<&VersionAndTag> = self.version_map.values().collect();
values.retain(|v| *v < version && v.version.pre.is_empt... | code_fim | hard | {
"lang": "rust",
"repo": "ttys3/git-cz",
"path": "/src/git.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ttys3/git-cz path: /src/git.rs
use std::{cmp::Ordering, collections::HashMap};
use git2::{Commit, Error, Object, Oid, Repository, Revwalk};
use semver::Version;
/// git helper for common operations
pub(crate) struct GitHelper {
pub(crate) repo: Repository,
version_map: HashMap<Oid, Ver... | code_fim | hard | {
"lang": "rust",
"repo": "ttys3/git-cz",
"path": "/src/git.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl GitHelper {
pub(crate) fn new(prefix: &str) -> Result<Self, Error> {
let repo = Repository::open_from_env()?;
let version_map = make_oid_version_map(&repo, prefix);
Ok(Self { repo, version_map })
}
/// Get the last version (can be pre-release) for the given revis... | code_fim | hard | {
"lang": "rust",
"repo": "ttys3/git-cz",
"path": "/src/git.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: AurevoirXavier/onething path: /src/dispatcher.rs
// --- std ---
use std::{
env,
path::PathBuf,
sync::Mutex,
thread,
};
// --- custom ---
use crate::{
account::Account,
detector::Detector,
util::{
to_hex,
format_balance,
save_export,
in... | code_fim | hard | {
"lang": "rust",
"repo": "AurevoirXavier/onething",
"path": "/src/dispatcher.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut handles = vec![];
for &kind in &CONF.kinds {
let handle = thread::spawn(move || { dispatch_account(Some(kind), CONF.redeem_with_proxy); });
handles.push(handle);
}
for handle in handles { handle.join().unwrap(); }
}
pub fn dispatch_task() {
let args: Vec<Strin... | code_fim | hard | {
"lang": "rust",
"repo": "AurevoirXavier/onething",
"path": "/src/dispatcher.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: unthawedStroma602/tari path: /base_layer/core/src/transactions/transaction_protocol/mod.rs
//! Transaction Protocol Manager facilitates the process of constructing a Mimblewimble transaction between two parties.
//!
//! The Transaction Protocol Manager implements a protocol to construct a Mimwbl... | code_fim | hard | {
"lang": "rust",
"repo": "unthawedStroma602/tari",
"path": "/base_layer/core/src/transactions/transaction_protocol/mod.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Transaction metadata, including the fee and lock height
#[derive(Debug, Clone, PartialEq, Eq, Default, Deserialize, Serialize)]
pub struct TransactionMetadata {
/// The absolute fee for the transaction
pub fee: MicroTari,
/// The earliest block this transaction can be mined
pub lock_he... | code_fim | hard | {
"lang": "rust",
"repo": "unthawedStroma602/tari",
"path": "/base_layer/core/src/transactions/transaction_protocol/mod.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (settings, app_name) = prelude();
match settings.graphics().mode() {
GraphicsMode::OpenGL => MagnusApplication::<OpenGLContext>::new(app_name, settings).run(),
GraphicsMode::Vulkan => MagnusApplication::<VulkanContext>::new(app_name, settings).ru... | code_fim | hard | {
"lang": "rust",
"repo": "braxtons12/magnus",
"path": "/src/core/entry_point.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[macro_export]
#[cfg(windows)]
macro_rules! magnus_engine {
() => {
pub fn main() {
use magnus::core::setup_logger;
use magnus::core::application::MagnusApplication;
use magnus::core::graphics::opengl::OpenGLContext;
use magnus::core::graphics::... | code_fim | hard | {
"lang": "rust",
"repo": "braxtons12/magnus",
"path": "/src/core/entry_point.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: braxtons12/magnus path: /src/core/entry_point.rs
#![allow(improper_ctypes)]
use crate::core::settings::Settings;
#[no_mangle]
extern "Rust" {
pub fn prelude() -> (Settings, String);
}
#[macro_export]
#[cfg(not(windows))]
macro_rules! magnus_engine {
() => {
pub fn main() {
... | code_fim | hard | {
"lang": "rust",
"repo": "braxtons12/magnus",
"path": "/src/core/entry_point.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JamesShoaf/AlgorithmPractice path: /numericalMethods/pascals_triangle/src/lib.rs
// Given a non-negative index k where k ≤ 33, return the kth index row of the Pascal's triangle.
// O(n^2) time, O(n) space
fn get_row(row_index: i32) -> Vec<i32> {
if row_index <= 12 { return get_row_binomial(r... | code_fim | hard | {
"lang": "rust",
"repo": "JamesShoaf/AlgorithmPractice",
"path": "/numericalMethods/pascals_triangle/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut fac: Vec<i32> = vec![1];
for i in 1..=row_index { fac.push(fac[i as usize - 1] * i); }
let mut output: Vec<i32> = Vec::new();
for i in 0..=(row_index + 1) / 2 {
output.push(fac[row_index as usize] / (fac[i as usize] * fac[(row_index - i) as usize]));
}
for i in (0..... | code_fim | medium | {
"lang": "rust",
"repo": "JamesShoaf/AlgorithmPractice",
"path": "/numericalMethods/pascals_triangle/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
#[test]
fn it_works() {
let test_tuples = vec![
(0, vec![1]),
(1, vec![1, 1]),
(2, vec![1, 2, 1]),
(3, vec![1, 3, 3, 1]),
(12, vec![1, 12, 66, 220, 495, 792, 924, 792, 495, 220, 66, 12, 1]),
(3... | code_fim | hard | {
"lang": "rust",
"repo": "JamesShoaf/AlgorithmPractice",
"path": "/numericalMethods/pascals_triangle/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chipsenkbeil/over-there path: /src/core/msg/content/request/batch.rs
use super::Request;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
/// Represents arguments to a request for a batch of operations
#[derive(
JsonSchema, Serialize, Deserialize, Default, Clone, Debug, Partia... | code_fim | easy | {
"lang": "rust",
"repo": "chipsenkbeil/over-there",
"path": "/src/core/msg/content/request/batch.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl crate::core::SchemaInfo for BatchArgs {}
impl From<Vec<Request>> for BatchArgs {
fn from(operations: Vec<Request>) -> Self {
Self { operations }
}
}<|fim_prefix|>// repo: chipsenkbeil/over-there path: /src/core/msg/content/request/batch.rs
use super::Request;
use schemars::JsonSchem... | code_fim | hard | {
"lang": "rust",
"repo": "chipsenkbeil/over-there",
"path": "/src/core/msg/content/request/batch.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: zhangpf/rux path: /kernel/src/arch/x86_64/interrupt/pic.rs
#![allow(dead_code)]
use arch::{inportb, outportb};
const PIC1_COMMAND: u16 = 0x20;
const PIC1_DATA: u16 = 0x21;
const PIC2_COMMAND: u16 = 0xA0;
const PIC2_DATA: u16 = 0xA1;
const PIC_EOI: u8 = 0x20;
const ICW1_ICW4: u8 = 0x01;
const ... | code_fim | medium | {
"lang": "rust",
"repo": "zhangpf/rux",
"path": "/kernel/src/arch/x86_64/interrupt/pic.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Set ICW4
outportb(0x21, 1);
outportb(0xa1, 1);
// Set OCW1 (interrupt masks)
outportb(0x21, 0xff);
outportb(0xa1, 0xff);
}
/// Send End of Interrupt for PIC.
pub unsafe fn send_pic_eoi(irq: u8) {
if irq >= 8 {
outportb(PIC2_COMMAND, PIC_EOI);
} else {
o... | code_fim | hard | {
"lang": "rust",
"repo": "zhangpf/rux",
"path": "/kernel/src/arch/x86_64/interrupt/pic.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Masterchef365/tiffy path: /src/lowlevel/constants.rs
/// Header magic
pub mod header_magic {
pub const LITTLE_ENDIAN_MAGIC: [u8; 2] = [b'I', b'I'];
pub const BIG_ENDIAN_MAGIC: [u8; 2] = [b'M', b'M'];
pub const VERSION_MAGIC: u16 = 42;
}
<|fim_suffix|> // Extended
pub const IF... | code_fim | hard | {
"lang": "rust",
"repo": "Masterchef365/tiffy",
"path": "/src/lowlevel/constants.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Extended
pub const IFD_TYPE_SBYTE: u16 = 0x0006;
pub const IFD_TYPE_UNDEFINED: u16 = 0x0007;
pub const IFD_TYPE_SSHORT: u16 = 0x0008;
pub const IFD_TYPE_SLONG: u16 = 0x0009;
pub const IFD_TYPE_SRATIONAL: u16 = 0x000A;
pub const IFD_TYPE_FLOAT: u16 = 0x000B;
pub const IFD... | code_fim | hard | {
"lang": "rust",
"repo": "Masterchef365/tiffy",
"path": "/src/lowlevel/constants.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!(
"{} could {}be a palindrome.",
candidate,
match could_be_a_palindrome {
true => "",
false => "not "
}
);
}<|fim_prefix|>// repo: newmancodes/tonys-puzzles path: /palindrome-possibility-detector/src/main.rs
mod palindrome_detector;
... | code_fim | hard | {
"lang": "rust",
"repo": "newmancodes/tonys-puzzles",
"path": "/palindrome-possibility-detector/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let detector = EasyPalindromePossibilityDetector::new();
let candidate = &args[1];
let could_be_a_palindrome = detector.could_be_a_palindrome(&candidate);
println!(
"{} could {}be a palindrome.",
candidate,
match could_be_a_palindrome {
true => "",
... | code_fim | medium | {
"lang": "rust",
"repo": "newmancodes/tonys-puzzles",
"path": "/palindrome-possibility-detector/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: newmancodes/tonys-puzzles path: /palindrome-possibility-detector/src/main.rs
mod palindrome_detector;
use std::env;
use palindrome_detector::PalindromePossibilityDetector;
use palindrome_detector::EasyPalindromePossibilityDetector;
fn main() {
<|fim_suffix|> if args.len() < 2 {
pani... | code_fim | medium | {
"lang": "rust",
"repo": "newmancodes/tonys-puzzles",
"path": "/palindrome-possibility-detector/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let file = options.open(path)?;
Ok(FsDataOutput {
path: path.as_ref().to_str().unwrap().to_owned(),
writer: BufWriter::with_capacity(CHUNK_SIZE, file),
bytes_written: 0,
})
}
}
impl Write for FsDataOutput {
fn write(&mut self, buf: &[u8]... | code_fim | hard | {
"lang": "rust",
"repo": "glorv/kv-demo",
"path": "/src/store/fs.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: glorv/kv-demo path: /src/store/fs.rs
use errors::*;
use std::fs::{File, OpenOptions};
use std::io::{BufReader, BufWriter};
use std::io::{Read, Write};
use std::path::{Path, PathBuf};
use store::{DataInput, DataOutput, KVDataInput, KVDataOutput};
const CHUNK_SIZE: usize = 8 * 1024;
pub(crate) ... | code_fim | hard | {
"lang": "rust",
"repo": "glorv/kv-demo",
"path": "/src/store/fs.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let count = self.writer.write(buf)?;
self.bytes_written += count;
Ok(count)
}
fn flush(&mut self) -> ::std::io::Result<()> {
self.writer.flush()
}
}
impl Drop for FsDataOutput {
fn drop(&mut self) {
if let Err(ref desc) = self.flush() {
... | code_fim | hard | {
"lang": "rust",
"repo": "glorv/kv-demo",
"path": "/src/store/fs.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for n in input.len()..30000000 {
let prev = memory[last];
memory[last] = n;
last = match prev {
0 => 0,
_ => n - prev
}
}
println!("{}", last);
}<|fim_prefix|>// repo: orenfromberg/aoc-2020 path: /day15/part2/src/main.rs
fn main() {
... | code_fim | medium | {
"lang": "rust",
"repo": "orenfromberg/aoc-2020",
"path": "/day15/part2/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: orenfromberg/aoc-2020 path: /day15/part2/src/main.rs
fn main() {
let input: Vec<usize> = vec![0,1,4,13,15,12,16];
let mut memory: Vec<usize> = vec![0;30000000];
<|fim_suffix|> for n in input.len()..30000000 {
let prev = memory[last];
memory[last] = n;
last = m... | code_fim | medium | {
"lang": "rust",
"repo": "orenfromberg/aoc-2020",
"path": "/day15/part2/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn jump(mnem: &str) -> Result<u16, &'static str> {
match mnem {
"null" | "" => Ok(0b000),
"JGT" => Ok(0b001),
"JEQ" => Ok(0b010),
"JGE" => Ok(0b011),
"JLT" => Ok(0b100),
"JNE" => Ok(0b101),
"JLE" => Ok(0b110),
"JMP" => Ok(0b111),
... | code_fim | hard | {
"lang": "rust",
"repo": "emmgame221/HackAssembler",
"path": "/src/code.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: emmgame221/HackAssembler path: /src/code.rs
const DEST_OFS: u8 = 3;
const COMP_OFS: u8 = 6;
pub fn dest(mnem: &str) -> Result<u16, &'static str> {
match mnem {
"null" | "" => Ok(0b000 << DEST_OFS),
"M" => Ok(0b001 << DEST_OFS),
"D" => Ok(0b010 << DEST_OFS),
"... | code_fim | hard | {
"lang": "rust",
"repo": "emmgame221/HackAssembler",
"path": "/src/code.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tkbrigham/dmgr path: /src/command/register.rs
use clap::{App, Arg, ArgMatches, SubCommand};
use std::env;
use std::io;
use std::path::PathBuf;
use log::{info, warn};
use command::DmgrResult;
use command::{Runnable, Subcommand};
use config::ServiceRegistry;
use constants;
use service::Service;... | code_fim | hard | {
"lang": "rust",
"repo": "tkbrigham/dmgr",
"path": "/src/command/register.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let cfg_dir = PathBuf::from(constants::SERVICE_CONFIG_DIR);
ensure_dir_exists(&cfg_dir)?;
info!("registering default services in {:?}...", cfg_dir);
let json_files = find_all_json_files(cfg_dir)?;
let services: Vec<Service> = json_files
.iter()
.map(Service::from_path)... | code_fim | hard | {
"lang": "rust",
"repo": "tkbrigham/dmgr",
"path": "/src/command/register.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: UrkelLabs/handshake-client path: /rpc/tests/client_node_test.rs
mod common;
use common::setup;
#[async_std::test]
async fn test_get_info() {
let client = setup();
let info = client.get_info().await;
assert!(info.is_ok());
}
#[async_std::test]
async fn test_get_memory_info() {
... | code_fim | hard | {
"lang": "rust",
"repo": "UrkelLabs/handshake-client",
"path": "/rpc/tests/client_node_test.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let verified = client.verify_message(address, signature, message).await;
assert!(verified.is_err());
}
////TODO this will break current tests -> Need to find a way to not have this break things.
//// #[test]
//// fn test_setmocktime() {
//// let mut client = common::setup();
//// let ti... | code_fim | hard | {
"lang": "rust",
"repo": "UrkelLabs/handshake-client",
"path": "/rpc/tests/client_node_test.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let signedmessage = client.sign_message_with_priv_key(privkey, message).await;
assert!(signedmessage.is_err());
}
////TODO need valid _ok() test
#[async_std::test]
async fn test_verify_message_fail() {
let client = common::setup();
//Address is bad.
let address = "ts1q7qumafugfglg26... | code_fim | hard | {
"lang": "rust",
"repo": "UrkelLabs/handshake-client",
"path": "/rpc/tests/client_node_test.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Default for Gen {
fn default() -> Self {
Self::new()
}
}<|fim_prefix|>// repo: rune-rs/rune path: /crates/rune/src/shared/gen.rs
use core::cell::Cell;
use core::num::NonZeroU32;
use crate::parse::NonZeroId;
#[derive(Debug)]
pub(crate) struct Gen {
id: Cell<u32>,
}
<|fim_middle... | code_fim | hard | {
"lang": "rust",
"repo": "rune-rs/rune",
"path": "/crates/rune/src/shared/gen.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rune-rs/rune path: /crates/rune/src/shared/gen.rs
use core::cell::Cell;
use core::num::NonZeroU32;
use crate::parse::NonZeroId;
<|fim_suffix|>impl Gen {
/// Construct a new shared generator.
pub(crate) fn new() -> Self {
Self { id: Cell::new(0) }
}
/// Get the next id.... | code_fim | medium | {
"lang": "rust",
"repo": "rune-rs/rune",
"path": "/crates/rune/src/shared/gen.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for pix in img {
bytes.push((pix.x.min(1.) * 255.) as u8);
bytes.push((pix.y.min(1.) * 255.) as u8);
bytes.push((pix.z.min(1.) * 255.) as u8);
}
let w: BufWriter<Box<::std::io::Write>> = match filename {
"-" => BufWriter::new(Box::new(::std::io::stdout())),
... | code_fim | hard | {
"lang": "rust",
"repo": "etwyniel/raytracer",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: etwyniel/raytracer path: /src/lib.rs
extern crate png;
extern crate rayon;
extern crate rand;
pub mod vec3;
pub mod solids;
pub mod surface;
use surface::*;
use vec3::*;
use solids::Object;
use std::fs::File;
use std::io::BufWriter;
use png::{Encoder, HasParameters, ColorType, BitDepth};
use r... | code_fim | hard | {
"lang": "rust",
"repo": "etwyniel/raytracer",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let val = get_hit_object_id(Vec3::default(), dir, objects);
hits[line + x] = val;
if val != hits[line + x - 1] || val != hits[line + x - width] {
img[line + x] = Vec3::new(1., 1., 1.);
}
}
}
/*
for y in 1..height {
... | code_fim | hard | {
"lang": "rust",
"repo": "etwyniel/raytracer",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: adamgreig/stm32ral path: /src/stm32mp/instances/rcc.rs
#![allow(non_snake_case, non_upper_case_globals)]
#![allow(non_camel_case_types)]
//! RCC
//!
//! Used by: stm32mp153, stm32mp157
#[cfg(not(feature = "nosync"))]
pub use crate::stm32mp::peripherals::rcc::Instance;
pub use crate::stm32mp::pe... | code_fim | hard | {
"lang": "rust",
"repo": "adamgreig/stm32ral",
"path": "/src/stm32mp/instances/rcc.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Reset values for each field in RCC
pub const reset: ResetValues = ResetValues {
RCC_TZCR: 0x00000003,
RCC_OCENSETR: 0x00000001,
RCC_OCENCLRR: 0x00000001,
RCC_HSICFGR: 0x00000000,
RCC_CSICFGR: 0x00001000,
RCC_MPCKSELR: 0x80000000,
RCC_ASSC... | code_fim | hard | {
"lang": "rust",
"repo": "adamgreig/stm32ral",
"path": "/src/stm32mp/instances/rcc.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.