text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>impl<'a> ExtensionsMut<'a> {
#[cfg(feature = "registry")]
pub(crate) fn new(inner: RwLockWriteGuard<'a, ExtensionsInner>) -> Self {
Self { inner }
}
/// Insert a type into this `Extensions`.
///
/// Note that extensions are _not_
/// [subscriber]-specific—they are _spa... | code_fim | hard | {
"lang": "rust",
"repo": "tokio-rs/tracing",
"path": "/tracing-subscriber/src/registry/extensions.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tokio-rs/tracing path: /tracing-subscriber/src/registry/extensions.rs
// taken from https://github.com/hyperium/http/blob/master/src/extensions.rs.
use crate::sync::{RwLockReadGuard, RwLockWriteGuard};
use std::{
any::{Any, TypeId},
collections::HashMap,
fmt,
hash::{BuildHasherD... | code_fim | hard | {
"lang": "rust",
"repo": "tokio-rs/tracing",
"path": "/tracing-subscriber/src/registry/extensions.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self.0
}
}
#[doc = "Field `TFCSTS` reader - MAC Transmit Packet Controller Status This field indicates the state of the MAC Transmit Packet Controller module."]
pub struct TFCSTS_R(crate::FieldReader<u8, u8>);
impl TFCSTS_R {
pub(crate) fn new(bits: u8) -> Self {
TFCSTS_R(crate::F... | code_fim | hard | {
"lang": "rust",
"repo": "lpc-rs/lpc-pac",
"path": "/lpc54608/src/enet/mac_dbg.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lpc-rs/lpc-pac path: /lpc54608/src/enet/mac_dbg.rs
#[doc = "Register `MAC_DBG` reader"]
pub struct R(crate::R<MAC_DBG_SPEC>);
impl core::ops::Deref for R {
type Target = crate::R<MAC_DBG_SPEC>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl From<cra... | code_fim | hard | {
"lang": "rust",
"repo": "lpc-rs/lpc-pac",
"path": "/lpc54608/src/enet/mac_dbg.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("OUT_DIR {:?}", out_dir);
}
assert!(artefacts_built(out_dir_path.as_path()));
println!("cargo:rustc-link-search=native={}", out_dir);
if let Some(lib_dir) = get_env("LIBNFTNL_LIB_DIR") {
if !lib_dir.is_dir() {
panic!(
"libnftnl library ... | code_fim | hard | {
"lang": "rust",
"repo": "jackkleeman/nf_simulator",
"path": "/iptables/build.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(lib_dir) = get_env("LIBMNL_LIB_DIR") {
if !lib_dir.is_dir() {
panic!(
"libmnl library directory does not exist: {}",
lib_dir.display()
);
}
println!("cargo:rustc-link-search=native={}", lib_dir.display());
... | code_fim | hard | {
"lang": "rust",
"repo": "jackkleeman/nf_simulator",
"path": "/iptables/build.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jackkleeman/nf_simulator path: /iptables/build.rs
use std::env;
use std::path::{Path, PathBuf};
use std::process::Command;
use pkg_config;
//use bindgen;
use num_cpus;
fn artefacts_built(build_dir: &Path) -> bool {
build_dir.join("libiptables.a").exists()
}
fn get_env(var: &'static str) ->... | code_fim | hard | {
"lang": "rust",
"repo": "jackkleeman/nf_simulator",
"path": "/iptables/build.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wschella/rsrl-types path: /src/agent.rs
use crate::domains;
use crate::memory::Shared;
use rand::Rng;
pub trait OnlineLearner<S, A> {
/// Handle a single transition collected from the problem environment.
fn handle_transition(&mut self, transition: &domains::Transition<S, A>);
///... | code_fim | hard | {
"lang": "rust",
"repo": "wschella/rsrl-types",
"path": "/src/agent.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.borrow().sample_target(rng, s)
}
fn sample_behaviour(&self, rng: &mut impl Rng, s: &S) -> A {
self.borrow().sample_behaviour(rng, s)
}
}
pub trait OnlineController<S, A> {
/// Sample the target policy for a given state `s`.
fn sample_target(&mut self, rng: &mut i... | code_fim | hard | {
"lang": "rust",
"repo": "wschella/rsrl-types",
"path": "/src/agent.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /*
for (k,v) in tmp { // 这种方式是移动! for循环之后tmp就无效了
println!("k:{:?}, v:{:?}", k, v);
}
*/
for (k,v) in &tmp { //这种方式才是借用
println!("k:{:?}, v:{:?}", k, v);
}
tmp.insert("name".to_string(), "messi".to_string()); //如果键已经存在, 则新值替换就值
// 只有键不存在时才插入
tmp.entr... | code_fim | hard | {
"lang": "rust",
"repo": "youngqqcn/RustNotes",
"path": "/examples/ch08/rust_hashmap_1.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: youngqqcn/RustNotes path: /examples/ch08/rust_hashmap_1.rs
use std::collections::HashMap;
fn main() {
let mut scores = HashMap::new();
scores.insert("Alice", 10);
scores.insert("Bob", 199);
let names = vec!["Alice", "Bob", "Coris"];
let ages = vec![11, 10, 14];
le... | code_fim | medium | {
"lang": "rust",
"repo": "youngqqcn/RustNotes",
"path": "/examples/ch08/rust_hashmap_1.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for (k,v) in &tmp { //这种方式才是借用
println!("k:{:?}, v:{:?}", k, v);
}
tmp.insert("name".to_string(), "messi".to_string()); //如果键已经存在, 则新值替换就值
// 只有键不存在时才插入
tmp.entry("name".to_string()).or_insert("news".to_string());
println!("{:?}", tmp);
let text = "hello world w... | code_fim | hard | {
"lang": "rust",
"repo": "youngqqcn/RustNotes",
"path": "/examples/ch08/rust_hashmap_1.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: samlet/bluecc path: /common/src/tests/data_format_tests.rs
use serde_derive::{Deserialize, Serialize};
use url::Url;
#[derive(Serialize, Deserialize)]
struct Person {
name: String,
age: i32,
phones: Vec<String>,
}
/*
// https://crates.io/crates/bson
#[test]
fn bson_works() {
//... | code_fim | hard | {
"lang": "rust",
"repo": "samlet/bluecc",
"path": "/common/src/tests/data_format_tests.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert!(issue_list_url.scheme() == "https");
assert!(issue_list_url.username() == "");
assert!(issue_list_url.password() == None);
assert!(issue_list_url.host_str() == Some("github.com"));
assert!(issue_list_url.host() == Some(Host::Domain("github.com")));
assert!(issue_list_url.po... | code_fim | hard | {
"lang": "rust",
"repo": "samlet/bluecc",
"path": "/common/src/tests/data_format_tests.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: suspend0/aws-sdk-rust path: /sdk/health/src/client.rs
inner.set_next_token(input);
self
}
/// <p>The maximum number of items to return in one batch, between 10 and 100, inclusive.</p>
pub fn max_results(mut self, inp: i32) -> Self {
self.inner = se... | code_fim | hard | {
"lang": "rust",
"repo": "suspend0/aws-sdk-rust",
"path": "/sdk/health/src/client.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: suspend0/aws-sdk-rust path: /sdk/health/src/client.rs
ut::DescribeEntityAggregatesOutput,
aws_smithy_http::result::SdkError<crate::error::DescribeEntityAggregatesError>,
>
where
R::Policy: aws_smithy_client::bounds::SmithyRetryPolicy<
crate... | code_fim | hard | {
"lang": "rust",
"repo": "suspend0/aws-sdk-rust",
"path": "/sdk/health/src/client.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn send(
from_wallet: &str,
from_account: &str,
to_account: &str,
amount: &str,
) -> Result<(), Box<Error>> {
let json_command: String = serde_json::to_string(&SendCommand {
action: "send",
wallet: from_wallet.to_string(),
source: from_account.to_string(),
... | code_fim | hard | {
"lang": "rust",
"repo": "evaldast/rusty-nanobot",
"path": "/src/node.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: evaldast/rusty-nanobot path: /src/node.rs
use futures::{Future, Stream};
use hyper::header::{ContentLength, ContentType};
use hyper::Client;
use hyper::{Chunk, Method, Request};
use serde_json;
use std::error::Error;
use std::str;
use tokio_core::reactor::Core;
#[derive(Deserialize)]
pub struct... | code_fim | hard | {
"lang": "rust",
"repo": "evaldast/rusty-nanobot",
"path": "/src/node.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Deserialize)]
pub struct Balance {
pub balance: String,
pub pending: String,
}
#[derive(Deserialize)]
pub struct Wallet {
pub wallet: String,
}
#[derive(Serialize)]
struct BasicCommand {
action: &'static str,
}
#[derive(Serialize)]
struct AccountCommand {
action: &'static s... | code_fim | hard | {
"lang": "rust",
"repo": "evaldast/rusty-nanobot",
"path": "/src/node.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jpopesculian/rise-wasm path: /src/funcs/resolvers/mem_alloc.rs
use super::{FuncResolver, FuncResolverBuild, ResolverTarget};
use alloc::prelude::*;
use wasmi::{RuntimeArgs, RuntimeValue, Signature, Trap, ValueType};
pub struct MemAllocResolver;
impl<T: ResolverTarget> FuncResolver<T> for MemAl... | code_fim | hard | {
"lang": "rust",
"repo": "jpopesculian/rise-wasm",
"path": "/src/funcs/resolvers/mem_alloc.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> 0
}
}
impl<T: ResolverTarget> FuncResolverBuild<T> for MemAllocResolver {
fn build() -> Box<dyn FuncResolver<T>> {
Box::new(MemAllocResolver {})
}
}<|fim_prefix|>// repo: jpopesculian/rise-wasm path: /src/funcs/resolvers/mem_alloc.rs
use super::{FuncResolver, FuncResolverBuil... | code_fim | medium | {
"lang": "rust",
"repo": "jpopesculian/rise-wasm",
"path": "/src/funcs/resolvers/mem_alloc.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Signature::new(
&[
ValueType::I32, // size
][..],
Some(ValueType::I32), // ptr
)
}
fn run(&self, target: &mut T, args: RuntimeArgs) -> Result<Option<RuntimeValue>, Trap> {
let size = args.nth_checked(0)?;
let ptr ... | code_fim | medium | {
"lang": "rust",
"repo": "jpopesculian/rise-wasm",
"path": "/src/funcs/resolvers/mem_alloc.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
/** Benchmark loading of parameter data */
#[bench] fn bench_params(b: &mut Bencher) {
b.iter(|| black_box(JoeKuoD6::standard()));
}<|fim_prefix|>// repo: Wsiegenthaler/sobol-rs path: /benches/params.rs
#![feature(test)]
extern crate sobol;
extern crate test;
<|fim_middle|>use test::{Bencher, blac... | code_fim | medium | {
"lang": "rust",
"repo": "Wsiegenthaler/sobol-rs",
"path": "/benches/params.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Wsiegenthaler/sobol-rs path: /benches/params.rs
#![feature(test)]
extern crate sobol;
extern crate test;
use test::{Bencher, black_box};
<|fim_suffix|>
/** Benchmark loading of parameter data */
#[bench] fn bench_params(b: &mut Bencher) {
b.iter(|| black_box(JoeKuoD6::standard()));
}<|fim... | code_fim | easy | {
"lang": "rust",
"repo": "Wsiegenthaler/sobol-rs",
"path": "/benches/params.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> if should_disconnect {
ctx.system.stop(state.peer_ref.clone());
}
});
}
}
impl Receive<CheckChainCompleteness> for ChainManager {
type Msg = ChainManagerMsg;
fn receive(&mut self, ctx: &Context<Self::Msg>, _msg: CheckChainComple... | code_fim | hard | {
"lang": "rust",
"repo": "sbnair/tezedge",
"path": "/shell/src/chain_manager.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sbnair/tezedge path: /shell/src/chain_manager.rs
rrent_head.header).clone(), history));
tell_peer(msg.into(), peer);
}
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "sbnair/tezedge",
"path": "/shell/src/chain_manager.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // notify others that new block was received
shell_channel.tell(
Publish {
msg: BlockReceived {
hash: ... | code_fim | hard | {
"lang": "rust",
"repo": "sbnair/tezedge",
"path": "/shell/src/chain_manager.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DuncanHills/sled path: /src/io/log/mod.rs
//! This module contains the systems that deal with files
//! directly. The `Log` is the point of contact for other
//! modules.
use std::cell::UnsafeCell;
use std::fmt::{self, Debug};
use std::io::{self, SeekFrom};
use super::*;
mod lss;
mod iobuf;
mo... | code_fim | hard | {
"lang": "rust",
"repo": "DuncanHills/sled",
"path": "/src/io/log/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let crc16 = [buf[0], buf[1]];
let lsn_buf = &buf[2..10];
let mut lsn_arr = [0u8; 8];
lsn_arr.copy_from_slice(&*lsn_buf);
let lsn: LogID = unsafe { std::mem::transmute(lsn_arr) };
let crc16_tested = crc16_arr(&lsn_arr);
SegmentTrailer {
... | code_fim | hard | {
"lang": "rust",
"repo": "DuncanHills/sled",
"path": "/src/io/log/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut line: String = String::new();
io::stdin().read_line(&mut line).expect("Failed to read input");
for c in line.chars() {
computer.push_input(c as Unit);
}
// computer.push_input(10);
}
}<|fim_prefix|>// repo: auno/adventofcode-2019 path: /25a... | code_fim | hard | {
"lang": "rust",
"repo": "auno/adventofcode-2019",
"path": "/25a/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: auno/adventofcode-2019 path: /25a/src/main.rs
use crate::int_code::{Computer, Unit};
use crate::int_code::State::Halted;
use std::io;
use std::fs;
mod int_code;
fn main() {
let memory = fs::read_to_string("input.txt").expect("Failed to read file: input.txt");
let memory: Vec<Unit> = me... | code_fim | medium | {
"lang": "rust",
"repo": "auno/adventofcode-2019",
"path": "/25a/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod test {
use super::*;
#[test]
fn smoke() {
::test::smoke::<SuffixArrayHaystack>();
}
}<|fim_prefix|>// repo: ryanpbrewster/needles-in-haystack path: /src/suffix_array.rs
#[derive(Default)]
pub struct SuffixArrayHaystack {
haystack: Vec<u8>,
suffix_position... | code_fim | hard | {
"lang": "rust",
"repo": "ryanpbrewster/needles-in-haystack",
"path": "/src/suffix_array.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ryanpbrewster/needles-in-haystack path: /src/suffix_array.rs
#[derive(Default)]
pub struct SuffixArrayHaystack {
haystack: Vec<u8>,
suffix_positions: Vec<usize>,
}
impl ::Haystack for SuffixArrayHaystack {
/// This is the naive SuffixArray construction, and it's much slower than mor... | code_fim | hard | {
"lang": "rust",
"repo": "ryanpbrewster/needles-in-haystack",
"path": "/src/suffix_array.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: slinkydeveloper/extending-kubernetes-api-in-process-poc path: /kube-rs/src/api/resource.rs
lector", &fields);
}
if let Some(labels) = &lp.label_selector {
qp.append_pair("labelSelector", &labels);
}
if let Some(limit) = &lp.limit {
qp.appen... | code_fim | hard | {
"lang": "rust",
"repo": "slinkydeveloper/extending-kubernetes-api-in-process-poc",
"path": "/kube-rs/src/api/resource.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: slinkydeveloper/extending-kubernetes-api-in-process-poc path: /kube-rs/src/api/resource.rs
// The kind of the resource.
///
/// This is the string used in the kind field of the resource's serialized form.
pub kind: String,
/// The version of the resource.
pub version: String... | code_fim | hard | {
"lang": "rust",
"repo": "slinkydeveloper/extending-kubernetes-api-in-process-poc",
"path": "/kube-rs/src/api/resource.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let r = Resource::all::<storagev1::VolumeAttachment>();
let req = r.create(&PostParams::default(), vec![]).unwrap();
assert_eq!(req.uri(), "/apis/storage.k8s.io/v1/volumeattachments?");
}
#[test]
fn api_url_admission() {
let r = Resource::all::<adregv1beta1::Va... | code_fim | hard | {
"lang": "rust",
"repo": "slinkydeveloper/extending-kubernetes-api-in-process-poc",
"path": "/kube-rs/src/api/resource.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gdanezis/simple-mix path: /src/format.rs
//! # The `simple_mix` format
//!
//! We define a simple mix packet format geared towards simplicity and performance with the features that are
//! specifically required by a stratified mix topology.
//!
//! `Simple_mix` assumes that all
//! paths are ... | code_fim | hard | {
"lang": "rust",
"repo": "gdanezis/simple-mix",
"path": "/src/format.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> unreachable!();
}
}
/// A structure representing the parameters of a single stage of mixing.
pub struct MixStageParameters {
/// The routing information length for this stage of mixing
pub routing_information_length_bytes: usize,
/// The reamining header length for this stage of m... | code_fim | hard | {
"lang": "rust",
"repo": "gdanezis/simple-mix",
"path": "/src/format.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> {
let robots = combo.fetch_block("web:robots.txt");
println!("{}", String::from_utf8_lossy(robots.unwrap()));
} {
let multi = combo.fetch_block("file:multi.rs");
println!("{}", String::from_utf8_lossy(multi.unwrap()));
}
}<|fim_prefix|>// repo: tomaka/asset_stor... | code_fim | hard | {
"lang": "rust",
"repo": "tomaka/asset_store",
"path": "/examples/multi.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tomaka/asset_store path: /examples/multi.rs
extern crate asset_store;
use asset_store::from_url;
use asset_store::from_directory;
use asset_store::AssetStore;
use asset_store::MultiStore;
fn id<A>(a:A) -> A { a }
fn main() {
// Create a file store for the local file system
let file_st... | code_fim | medium | {
"lang": "rust",
"repo": "tomaka/asset_store",
"path": "/examples/multi.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: aashoo17/rust path: /lang/src/std/net/tcp.rs
use std::error::Error;
use std::io::{self, Read, Write};
use std::net::{TcpListener, TcpStream};
#[test]
pub fn client() -> io::Result<()> {
//connect call create a tcp socket and makes a connection request to this address
//TODO: what addres... | code_fim | medium | {
"lang": "rust",
"repo": "aashoo17/rust",
"path": "/lang/src/std/net/tcp.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> //create a tcp socket and bind the socket to this known address where other clients can connect to
//this call creates the tcp socket and binds it to the given address
let server_socket = TcpListener::bind("127.0.0.1:3000")?;
//iterate over all clients accepting connection and write to the... | code_fim | medium | {
"lang": "rust",
"repo": "aashoo17/rust",
"path": "/lang/src/std/net/tcp.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jolestar/libra path: /language/move-lang/src/hlir/translate.rs
er);
fields.push((f, fa))
}
L::Unpack(s, bs, fields)
}
A::BorrowUnpack(mut_, _m, s, _tss, tfields) => {
let tmp = context.new_temp(loc, rvalue_ty.clone());
... | code_fim | hard | {
"lang": "rust",
"repo": "jolestar/libra",
"path": "/language/move-lang/src/hlir/translate.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> context: &mut Context,
result: &mut Block,
_eloc: Loc,
sp!(loc, tb_): T::BuiltinFunction,
targ: Box<T::Exp>,
) -> H::UnannotatedExp_ {
use H::{BuiltinFunction_ as HB, UnannotatedExp_ as E};
use T::BuiltinFunction_ as TB;
match tb_ {
TB::MoveTo(bt) => {
l... | code_fim | hard | {
"lang": "rust",
"repo": "jolestar/libra",
"path": "/language/move-lang/src/hlir/translate.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jolestar/libra path: /language/move-lang/src/hlir/translate.rs
************************************************************************************
fn function(context: &mut Context, _name: FunctionName, f: T::Function) -> H::Function {
assert!(context.has_empty_locals());
let visibilit... | code_fim | hard | {
"lang": "rust",
"repo": "jolestar/libra",
"path": "/language/move-lang/src/hlir/translate.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 0x00A5/aws-sdk-rust path: /sdk/sagemaker/src/json_deser.rs
&[u8],
mut builder: crate::output::get_device_fleet_report_output::Builder,
) -> std::result::Result<crate::output::get_device_fleet_report_output::Builder, serde_json::Error>
{
let parsed_body: crate::serializer::GetDeviceFleetR... | code_fim | hard | {
"lang": "rust",
"repo": "0x00A5/aws-sdk-rust",
"path": "/sdk/sagemaker/src/json_deser.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn create_flow_definition_deser_operation(
input: &[u8],
mut builder: crate::output::create_flow_definition_output::Builder,
) -> std::result::Result<crate::output::create_flow_definition_output::Builder, serde_json::Error> {
let parsed_body: crate::serializer::CreateFlowDefinitionOutputBo... | code_fim | hard | {
"lang": "rust",
"repo": "0x00A5/aws-sdk-rust",
"path": "/sdk/sagemaker/src/json_deser.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn list_pipeline_parameters_for_execution_deser_operation(
input: &[u8],
mut builder: crate::output::list_pipeline_parameters_for_execution_output::Builder,
) -> std::result::Result<
crate::output::list_pipeline_parameters_for_execution_output::Builder,
serde_json::Error,
> {
let p... | code_fim | hard | {
"lang": "rust",
"repo": "0x00A5/aws-sdk-rust",
"path": "/sdk/sagemaker/src/json_deser.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ehntoo/bl702-pac path: /src/glb/gpio_cfgctl2.rs
f_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}
impl From<crate::W<GPIO_CFGCTL2_SPEC>> for W {
#[inline(always)]
fn from(writer: crate::W<GPIO_CFGCTL2_SPEC>) -> Self {
W(writer)
}
}
#[doc = "Field `reg_gpio_5... | code_fim | hard | {
"lang": "rust",
"repo": "ehntoo/bl702-pac",
"path": "/src/glb/gpio_cfgctl2.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self.0
}
}
#[doc = "Field `reg_gpio_4_drv` writer - "]
pub struct REG_GPIO_4_DRV_W<'a> {
w: &'a mut W,
}
impl<'a> REG_GPIO_4_DRV_W<'a> {
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub unsafe fn bits(self, value: u8) -> &'a mut W {
self.w.bits = (self.w.... | code_fim | hard | {
"lang": "rust",
"repo": "ehntoo/bl702-pac",
"path": "/src/glb/gpio_cfgctl2.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ehntoo/bl702-pac path: /src/glb/gpio_cfgctl2.rs
>> for R {
#[inline(always)]
fn from(reader: crate::R<GPIO_CFGCTL2_SPEC>) -> Self {
R(reader)
}
}
#[doc = "Register `GPIO_CFGCTL2` writer"]
pub struct W(crate::W<GPIO_CFGCTL2_SPEC>);
impl core::ops::Deref for W {
type Target... | code_fim | hard | {
"lang": "rust",
"repo": "ehntoo/bl702-pac",
"path": "/src/glb/gpio_cfgctl2.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>e
{
None
}
}
}
#
[
cfg
(
test
)
]
pub
mod
test
{
use
super
:
:
*
;
use
string
:
:
CFString
;
use
boolean
:
:
CFBoolean
;
#
[
test
]
fn
test_property_list_serialization
(
)
{
use
base
:
:
{
TCFType
CFEqual
}
;
use
boolean
:
:
CFBoolean
;
use
number
:
:
CFNumber
;
use
dictionary
:
:
CFDictionary
;
use
strin... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/core-foundation/src/propertylist.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marco-c/gecko-dev-wordified path: /third_party/rust/core-foundation/src/propertylist.rs
/
/
Copyright
2013
The
Servo
Project
Developers
.
See
the
COPYRIGHT
/
/
file
at
the
top
-
level
directory
of
this
distribution
.
/
/
/
/
Licensed
under
the
Apache
License
Version
2
.
0
<
LICENSE
-
APACHE
or
/... | code_fim | hard | {
"lang": "rust",
"repo": "marco-c/gecko-dev-wordified",
"path": "/third_party/rust/core-foundation/src/propertylist.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jfoote/wasmtime path: /crates/wasi-common/src/sys/unix/emscripten/filetime.rs
//! This internal module consists of helper types and functions for dealing
//! with setting the file times specific to Emscripten.
use crate::{sys::unix::filetime::FileTime, Result};
use std::fs::File;
use std::io;
<... | code_fim | medium | {
"lang": "rust",
"repo": "jfoote/wasmtime",
"path": "/crates/wasi-common/src/sys/unix/emscripten/filetime.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> let flags = if symlink_nofollow {
libc::AT_SYMLINK_NOFOLLOW
} else {
0
};
let p = CString::new(path.as_bytes())?;
let times = [to_timespec(&atime)?, to_timespec(&mtime)?];
let rc = unsafe { libc::utimensat(dirfd.as_raw_fd(), p.as_ptr(), times.as_ptr(), flags) };
... | code_fim | hard | {
"lang": "rust",
"repo": "jfoote/wasmtime",
"path": "/crates/wasi-common/src/sys/unix/emscripten/filetime.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: indeyets/freefeed.rs path: /src/lib/reqwest_extensions.rs
use reqwest::{RequestBuilder};
use reqwest::header::{AUTHORIZATION};
pub trait Authorizable {
fn authorize(self, token: &str) -> RequestBuilder;
fn authorize_maybe(self, token: Option<&str>) -> RequestBuilder;
<|fim_suffix|> ... | code_fim | hard | {
"lang": "rust",
"repo": "indeyets/freefeed.rs",
"path": "/src/lib/reqwest_extensions.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match token {
Some(token) => self.authorize(token),
None => self
}
}
}<|fim_prefix|>// repo: indeyets/freefeed.rs path: /src/lib/reqwest_extensions.rs
use reqwest::{RequestBuilder};
use reqwest::header::{AUTHORIZATION};
pub trait Authorizable {
fn authoriz... | code_fim | hard | {
"lang": "rust",
"repo": "indeyets/freefeed.rs",
"path": "/src/lib/reqwest_extensions.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.header(AUTHORIZATION, format!("Bearer {}", token))
}
fn authorize_maybe(self, token: Option<&str>) -> RequestBuilder {
match token {
Some(token) => self.authorize(token),
None => self
}
}
}<|fim_prefix|>// repo: indeyets/freefeed.rs path: ... | code_fim | medium | {
"lang": "rust",
"repo": "indeyets/freefeed.rs",
"path": "/src/lib/reqwest_extensions.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn enumerate_roads(&self) -> impl Iterator<Item = (RoadIndex, (AxisDirection, &R))> {
use AxisDirection::*;
self.horizontal_roads
.indices()
.zip(std::iter::repeat(Horizontal).zip(self.horizontal_roads.iter()))
.chain(
self.vertic... | code_fim | hard | {
"lang": "rust",
"repo": "linyinfeng/mpi-traffic",
"path": "/src/model/board.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn lane_to_intersection_index(
&self,
road_direction: AxisDirection,
road_index: RoadIndex,
lane_direction: LaneDirection,
) -> MatrixIndex {
use AxisDirection::*;
use LaneDirection::*;
match lane_direction {
HighToLow => road... | code_fim | hard | {
"lang": "rust",
"repo": "linyinfeng/mpi-traffic",
"path": "/src/model/board.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: linyinfeng/mpi-traffic path: /src/model/board.rs
use crate::{
model::common::{Around, AxisDirection, LaneDirection},
util::matrix::{Matrix, MatrixIndex, MatrixShape},
};
use serde::{Deserialize, Serialize};
pub type IntersectionIndex = MatrixIndex;
pub type RoadIndex = MatrixIndex;
#[d... | code_fim | hard | {
"lang": "rust",
"repo": "linyinfeng/mpi-traffic",
"path": "/src/model/board.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn add(self, o: Self) -> Vec3 {
Vec3::new(self.x + o.x, self.y + o.y, self.z + o.z)
}
}
impl AddAssign for Vec3 {
fn add_assign(&mut self, o: Vec3) {
self.x += o.x;
self.y += o.y;
self.z += o.z;
}
}
impl Sub for &Vec3 {
type Output = Vec3;
fn sub(... | code_fim | hard | {
"lang": "rust",
"repo": "msakuta/ray-rust",
"path": "/src/vec3.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: msakuta/ray-rust path: /src/vec3.rs
use std::ops::{Add, AddAssign, Mul, Sub};
#[derive(Clone, Debug, Copy, Serialize, Deserialize)]
pub struct Vec3 {
pub x: f32,
pub y: f32,
pub z: f32,
//reserved: f32,
}
impl Vec3 {
pub fn new(x: f32, y: f32, z: f32) -> Vec3 {
Vec3... | code_fim | hard | {
"lang": "rust",
"repo": "msakuta/ray-rust",
"path": "/src/vec3.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn scaled(&self, o: f32) -> Self {
Self::new(self.x * o, self.y * o, self.z * o)
}
pub fn scale(&mut self, o: f32) {
self.x *= o;
self.y *= o;
self.z *= o;
}
}
// It's a shame that we cannot omit '&' in front of Vec3 object
// if we want to use multipl... | code_fim | hard | {
"lang": "rust",
"repo": "msakuta/ray-rust",
"path": "/src/vec3.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yorkart/rust-hdfs-native path: /rhdfs/src/cmdx.rs
use std::net::SocketAddr;
use std::collections::{VecDeque, HashMap};
use futures::{Stream, Async, Sink, AsyncSink};
use dt::*;
use nn::*;
use *;
use util::*;
use proto_tools::{ProtoFrontEndSourceQ, UserDeliver};
/// Connector abstraction
pub ... | code_fim | hard | {
"lang": "rust",
"repo": "yorkart/rust-hdfs-native",
"path": "/rhdfs/src/cmdx.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
//TODO add idle timer functionality
///Connection manager. Does connection management for an upper layer together with passing
///messages up/down
struct CM<C, Q, A> {
s: CMS<C>,
q: VecDeque<Q>,
a: Option<A>
}
const OUT_Q_SIZE: usize = 16;
impl<C, Q, R, A> CM<C, Q, A> where
C: Sink<Sink... | code_fim | hard | {
"lang": "rust",
"repo": "yorkart/rust-hdfs-native",
"path": "/rhdfs/src/cmdx.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: qthree/itm path: /src/error.rs
//! Representations of errors returned by this crate.
use std::io;
error_chain! {
foreign_links {
Io(io::Error) #[doc = "I/O error"];
}
errors {
<|fim_suffix|>/ end of file during packet
EofDuringPacket {
descripti... | code_fim | medium | {
"lang": "rust",
"repo": "qthree/itm",
"path": "/src/error.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// end of file before packet
EofBeforePacket {
description("end of file before packet"),
display("end of file before packet"),
}
}
}<|fim_prefix|>// repo: qthree/itm path: /src/error.rs
//! Representations of errors returned by this crate.
use std::io;
error... | code_fim | medium | {
"lang": "rust",
"repo": "qthree/itm",
"path": "/src/error.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn generate_individual(
breeding: &Rc<Breeding>,
fitness_calculator: &Rc<FitnessCalculator>,
) -> Individual {
let chromosome = breeding.generate_chromosome();
Individual {
fitness: fitness_calculator.calc_fitness(&chromosome.decode_genotype()),
... | code_fim | hard | {
"lang": "rust",
"repo": "jinnzest/genetic-algorithm-rust",
"path": "/src/incubator.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jinnzest/genetic-algorithm-rust path: /src/incubator.rs
use generation::Generation;
use individual::Individual;
use breeding::Breeding;
use random_utils::{RandomUtils, ChoosingProbability};
use fitness_calculator::FitnessCalculator;
use generation;
use chromosome::Chromosome;
use generation::Par... | code_fim | hard | {
"lang": "rust",
"repo": "jinnzest/genetic-algorithm-rust",
"path": "/src/incubator.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Incubator {
pub fn get_best_individual(&self) -> Individual {
generation::find_best_individual(&self.generation.individuals)
}
pub fn get_worst_individual(&self) -> Individual {
generation::find_worst_individual(
&self.generation.individuals,
gener... | code_fim | hard | {
"lang": "rust",
"repo": "jinnzest/genetic-algorithm-rust",
"path": "/src/incubator.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Cristiandi/course-rust-in-motion path: /src/unit-1/05_functions.rs
fn next_birthday(name: &str, current_age: u8) {
let next_age = current_age + 1;
println!("Hi {}, on your next birthday, you'll be {}!", name, next_age);
}
fn square(num: i32) -> i32 {
<|fim_suffix|>fn main() {
next_birthda... | code_fim | medium | {
"lang": "rust",
"repo": "Cristiandi/course-rust-in-motion",
"path": "/src/unit-1/05_functions.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> next_birthday("Cristian David Ippolito", 23);
next_birthday("Karen Cortes", 21);
println!("the answer is {}", square(3));
discount(10);
}<|fim_prefix|>// repo: Cristiandi/course-rust-in-motion path: /src/unit-1/05_functions.rs
fn next_birthday(name: &str, current_age: u8) {
let next_age = curre... | code_fim | medium | {
"lang": "rust",
"repo": "Cristiandi/course-rust-in-motion",
"path": "/src/unit-1/05_functions.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let hwb = Color::new_hwb(h, w, b);
let hex_string = hwb.to_hex_string();
let hex_str = hex_string.as_str();
let grayscaled = hwb.grayscale();
let grayscaled_string = grayscaled.to_hex_string();
let grayscaled_str = grayscaled_string.as_str();
let grayscaled_hdtv = hwb.graysca... | code_fim | hard | {
"lang": "rust",
"repo": "forkkit/rust-color-processing",
"path": "/html_visualizer/src/main.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn build_grayscaling_html() -> String {
let mut html_content = String::new();
html_content.push_str("<!DOCTYPE html>\n");
html_content.push_str("<html>\n");
html_content.push_str(" <head>\n");
html_content.push_str(" <title>grayscaling</title>\n");
html_content.push_str(" <... | code_fim | hard | {
"lang": "rust",
"repo": "forkkit/rust-color-processing",
"path": "/html_visualizer/src/main.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: forkkit/rust-color-processing path: /html_visualizer/src/main.rs
ld_hsl_color_table_row(h as f64 * 60.0, 1.0, 0.5).as_str());
}
for h in 0..6 {
html_content.push_str(build_hsl_color_table_row(h as f64 * 60.0, 1.0, 0.75).as_str());
}
html_content.push_str(build_hsl_color_t... | code_fim | hard | {
"lang": "rust",
"repo": "forkkit/rust-color-processing",
"path": "/html_visualizer/src/main.rs",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn day_03_challenge_1() -> usize {
let forest = load_forest_from_file(DATA_FILE_PATH);
return toboggan_travel(&forest, 3, 1);
}
pub fn day_03_challenge_2() -> usize {
let forest = load_forest_from_file(DATA_FILE_PATH);
let run_1 = toboggan_travel(&forest, 1, 1);
let run_2 = tobogg... | code_fim | hard | {
"lang": "rust",
"repo": "jungaretti/advent-of-code-2020",
"path": "/src/day_03.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jungaretti/advent-of-code-2020 path: /src/day_03.rs
use std::fs::File;
use std::io::BufRead;
use std::io::BufReader;
const DATA_FILE_PATH: &str = "./data/day03.txt";
#[derive(PartialEq)]
enum ForestEntity {
Square,
Tree,
}
fn char_to_entity(entity: char) -> ForestEntity {
<|fim_suffix... | code_fim | hard | {
"lang": "rust",
"repo": "jungaretti/advent-of-code-2020",
"path": "/src/day_03.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stevelorenz/programming-playground path: /language/rust/programming_rust/libgit2-rs-safe/build.rs
/// Build script to tell
<|fim_suffix|> // Tell the compiler where to find the shared library for linking.
println!(r"cargo:rustc-link-search=native=/Users/zuoxiang/dev_projects/libgit2/buil... | code_fim | easy | {
"lang": "rust",
"repo": "stevelorenz/programming-playground",
"path": "/language/rust/programming_rust/libgit2-rs-safe/build.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Tell the compiler where to find the shared library for linking.
println!(r"cargo:rustc-link-search=native=/Users/zuoxiang/dev_projects/libgit2/build");
}<|fim_prefix|>// repo: stevelorenz/programming-playground path: /language/rust/programming_rust/libgit2-rs-safe/build.rs
/// Build script to ... | code_fim | easy | {
"lang": "rust",
"repo": "stevelorenz/programming-playground",
"path": "/language/rust/programming_rust/libgit2-rs-safe/build.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mitermayer/augmented-audio path: /crates/augmented/augmented/src/lib.rs
/// Run [`audio::processor::AudioProcessor`]s and [`audio::processor::midi::MidiEventHandler`] as
/// stand-alone applications.
pub mod application;
/// Process<|fim_suffix|>rs)
pub mod dsp;
/// GUI utilities, subject to cha... | code_fim | hard | {
"lang": "rust",
"repo": "mitermayer/augmented-audio",
"path": "/crates/augmented/augmented/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>rs)
pub mod dsp;
/// GUI utilities, subject to change, wrapping [`iced`]
pub mod gui;
/// Operational utilities
pub mod ops;
/// Testing helpers
pub mod testing;<|fim_prefix|>// repo: mitermayer/augmented-audio path: /crates/augmented/augmented/src/lib.rs
/// Run [`audio::processor::AudioProcessor`]s and... | code_fim | hard | {
"lang": "rust",
"repo": "mitermayer/augmented-audio",
"path": "/crates/augmented/augmented/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use super::*;
use anyhow::{bail, Result as Fallible};
#[test]
fn deserialize_queryresult() -> Fallible<()> {
let query_result_str = r#"{
"status": "success",
"data": {
"resultType": "vector",
"result"... | code_fim | hard | {
"lang": "rust",
"repo": "openshift/cincinnati",
"path": "/prometheus-query/src/v1/queries/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: openshift/cincinnati path: /prometheus-query/src/v1/queries/mod.rs
//! Implements calls to the /v1/query endpoint
use super::Client;
use serde::Deserialize;
mod instant;
#[derive(Deserialize, Debug, PartialEq)]
#[serde(tag = "status", rename_all = "lowercase")]
pub enum QueryResult {
Succ... | code_fim | hard | {
"lang": "rust",
"repo": "openshift/cincinnati",
"path": "/prometheus-query/src/v1/queries/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let expected_result = QuerySuccess {
data: QueryData::Vector(vec![
VectorResult {
metric: json!({ "version": "4.0.0-0.alpha-2019-03-05-054505" }),
value: VectorValue {
time: 1551992754.228,
... | code_fim | hard | {
"lang": "rust",
"repo": "openshift/cincinnati",
"path": "/prometheus-query/src/v1/queries/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[cfg(test)]
pub fn from_str_and_path(path: PathBuf, content: &str) -> std::io::Result<Config> {
Config::from_slice(path, content.as_bytes())
}
pub fn get_path(&self) -> &PathBuf {
&self.path
}
pub fn get_temp_path(&self) -> PathBuf {
self.get_path().parent... | code_fim | hard | {
"lang": "rust",
"repo": "jplevyak/sdk",
"path": "/src/dfx/src/config/dfinity.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jplevyak/sdk path: /src/dfx/src/config/dfinity.rs
DEFAULTS_REPLICA: ConfigDefaultsReplica = ConfigDefaultsReplica {
message_gas_limit: None,
port: None,
round_gas_limit: None,
};
const DEFAULT_LOCAL_BIND: &str = "127.0.0.1:8000";
pub const DEFAULT_IC_GATEWAY: &str = "https://ic0.app... | code_fim | hard | {
"lang": "rust",
"repo": "jplevyak/sdk",
"path": "/src/dfx/src/config/dfinity.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> std::fs::create_dir_all(config_path.parent().unwrap()).unwrap();
std::fs::write(&config_path, "{}").unwrap();
assert!(
Config::resolve_config_path(config_path.parent().unwrap().parent().unwrap()).is_err()
);
}
#[test]
fn find_dfinity_config_subdir(... | code_fim | hard | {
"lang": "rust",
"repo": "jplevyak/sdk",
"path": "/src/dfx/src/config/dfinity.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lythesia/leet path: /rs/src/quests/longest_palindromic_substring.rs
/**
* [5] Longest Palindromic Substring
*
* Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.
Example 1:
Input: "babad"
Output: "bab"
Note: "aba" is also a v... | code_fim | hard | {
"lang": "rust",
"repo": "lythesia/leet",
"path": "/rs/src/quests/longest_palindromic_substring.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> ans
}
pub fn longest_palindrome(s: String) -> String {
let n = s.len();
if n == 0 {
return s;
}
let ss = s.as_bytes();
let mut p = [0; 2002];
let (mut id, mut mx) = (0usize, 0usize);
for i in 0..2*(n-1)+1 {
let... | code_fim | hard | {
"lang": "rust",
"repo": "lythesia/leet",
"path": "/rs/src/quests/longest_palindromic_substring.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: xet7/RefineDB path: /rdb-analyzer/src/data/treewalker/asm/mod.rs
use lalrpop_util::lalrpop_mod;
mod ast;
pub mod codegen;
mod state;
#[cfg(test)]
mod asm_test;
lalrpop_mod!(language, "/data/treewalker/asm/language.rs");
use thiserror::Error;
#[derive(Error, Debug)]
pub enum TwAsmError {
#... | code_fim | hard | {
"lang": "rust",
"repo": "xet7/RefineDB",
"path": "/rdb-analyzer/src/data/treewalker/asm/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[error("duplicate node name: {0}")]
DuplicateNodeName(String),
#[error("duplicate type alias: {0}")]
DuplicateTypeAlias(String),
#[error("graph not found: {0}")]
GraphNotFound(String),
}<|fim_prefix|>// repo: xet7/RefineDB path: /rdb-analyzer/src/data/treewalker/asm/mod.rs
use lalrpop_util... | code_fim | medium | {
"lang": "rust",
"repo": "xet7/RefineDB",
"path": "/rdb-analyzer/src/data/treewalker/asm/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: containerd/ttrpc-rust path: /src/context.rs
// Copyright (c) 2021 Ant group
//
// SPDX-License-Identifier: Apache-2.0
//
use crate::proto::KeyValue;
use std::collections::HashMap;
#[derive(Clone, Default, Debug)]
pub struct Context {
pub metadata: HashMap<String, Vec<String>>,
pub time... | code_fim | hard | {
"lang": "rust",
"repo": "containerd/ttrpc-rust",
"path": "/src/context.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn to_pb(kvs: HashMap<String, Vec<String>>) -> Vec<KeyValue> {
let mut meta = Vec::with_capacity(kvs.len());
for (k, vl) in kvs {
for v in vl {
let key = KeyValue {
key: k.clone(),
value: v.clone(),
..Default::default()
... | code_fim | hard | {
"lang": "rust",
"repo": "containerd/ttrpc-rust",
"path": "/src/context.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: valarauca/elfdecode path: /src/value.rs
use std::cell::RefCell;
use super::nom::IResult;
use super::header::endian::Endian;
use super::header::wordsize::Platform;
thread_local!( static ENDIAN: RefCell<Endian> = RefCell::new(Endian::Little));
thread_local!( static PLATFORM: RefCell<Platform> = ... | code_fim | hard | {
"lang": "rust",
"repo": "valarauca/elfdecode",
"path": "/src/value.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/*
* Read Endianess/Plaform word size
*/
#[inline(always)]
fn get_endian() -> Endian {
ENDIAN.with(|cell| -> Endian {
*cell.borrow()
})
}
#[inline(always)]
pub fn get_platform() -> Platform {
PLATFORM.with(|cell| -> Platform {
*cell.borrow()
})
}
/*
* Macro based defin... | code_fim | hard | {
"lang": "rust",
"repo": "valarauca/elfdecode",
"path": "/src/value.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match get_platform() {
Platform::Bit32 => match read_u32(i) {
IResult::Done(x,y) => IResult::Done(x,y as u64),
IResult::Error(z) => IResult::Error(z),
IResult::Incomplete(z) => IResult::Incomplete(z)
},
Platform::Bit64 => read_u64(i)
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "valarauca/elfdecode",
"path": "/src/value.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: castelao/GSW-rs path: /src/earth.rs
//! Planet Earth properties
use crate::conversions::z_from_p;
use crate::gsw_internal_const::{DEG2RAD, GAMMA};
use crate::{Error, Result};
/// Coriolis parameter (f)
///
/// # Arguments
///
/// * `lat`: latitude \[decimal degrees\] (positive northward)
///
/... | code_fim | hard | {
"lang": "rust",
"repo": "castelao/GSW-rs",
"path": "/src/earth.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn distance_with_depth() {
let d = distance(0.0, 0.0, 0.0, 0.0, 1.0, 1000.0).unwrap();
assert!((d - 111186.2584129753).abs() <= f64::EPSILON);
}
#[test]
// Vertical distance is not included
fn distance_on_depth() {
let d = distance(0.0, 0.0, 0.0, 0.... | code_fim | hard | {
"lang": "rust",
"repo": "castelao/GSW-rs",
"path": "/src/earth.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> let dlon = (lon2 - lon1) * DEG2RAD;
let dlat = (lat2 - lat1) * DEG2RAD;
let sdlat = libm::sin(0.5 * dlat);
let sdlon = libm::sin(0.5 * dlon);
let a =
(sdlat * sdlat) + libm::cos(lat1 * DEG2RAD) * libm::cos(lat2 * DEG2RAD) * (sdlon * sdlon);
let angles = 2.0 * libm::atan2(l... | code_fim | hard | {
"lang": "rust",
"repo": "castelao/GSW-rs",
"path": "/src/earth.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.