text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: JJWasyl/Rusty-Bar path: /src/graph_builder/mod.rs
//! An implementation of a Graphing library with a plot object and
//! a client facing builder.
use crossterm::{
cursor, execute,
style::{Color, Print, ResetColor, SetForegroundColor},
};
//use std::collections::HashMap;
use std::fmt;
us... | code_fim | hard | {
"lang": "rust",
"repo": "JJWasyl/Rusty-Bar",
"path": "/src/graph_builder/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let height = self.get_graph_height();
for _ in 0..height {
execute!(
stdout(),
Print(" ".repeat(self.width as usize)),
Print("\n")
)
.unwrap();
}
self.reset_cursor(height as u16);
}
... | code_fim | hard | {
"lang": "rust",
"repo": "JJWasyl/Rusty-Bar",
"path": "/src/graph_builder/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Prints an individual row of data and column labels
fn print_label_group(
&self,
label: &str,
row_idx: usize,
max_label_len: usize,
max_col_len: usize,
mut output: impl Write,
) {
if !label.is_empty() {
self.print_label(
... | code_fim | hard | {
"lang": "rust",
"repo": "JJWasyl/Rusty-Bar",
"path": "/src/graph_builder/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mre/slack path: /src/files/shared_public_url.rs
//! # files_shared_public_url
//!
//! This method enables public/external sharing for a file.
//! See https://api.slack.com/methods/files.sharedPublicURL
//!
//! ## Required arguments:
//! `file` (String)
//! File to share.
//! Example:... | code_fim | hard | {
"lang": "rust",
"repo": "mre/slack",
"path": "/src/files/shared_public_url.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> SharedPublicURLOptions {
file: file.into(),
..Default::default()
}
}
}
impl From<SharedPublicURLOptions> for String {
fn from(options: SharedPublicURLOptions) -> Self {
// This should never fail, so calling unwrap() on the result.
// There mig... | code_fim | hard | {
"lang": "rust",
"repo": "mre/slack",
"path": "/src/files/shared_public_url.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
/// Send the request to Slack and try to convert the response to a SharedPublicURLResponse
pub fn send(&mut self) -> Result<FilesSharedPublicURLResponse> {
let payload = self.client.send(format!("{}?{:?}", "files.sharedPublicURL", &self.params))?;
payload.to_type::<FilesSharedPubl... | code_fim | hard | {
"lang": "rust",
"repo": "mre/slack",
"path": "/src/files/shared_public_url.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[macro_export]
macro_rules! call_ins {
($node_id:expr) => {{
use $crate::ir::CfgInstruction;
CfgInstruction::Call($node_id)
}};
}
#[macro_export]
macro_rules! ret_ins {
() => {{
$crate::ir::CfgInstruction::Return
}};
}
#[macro_export]
macro_rules! trap_ins {
... | code_fim | hard | {
"lang": "rust",
"repo": "spacemeshos/tytle",
"path": "/tytle_core/src/ir/macros.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let cmd = Command::parse(stringify!($cmd)).unwrap();
CfgInstruction::Command(cmd)
}};
}
#[macro_export]
macro_rules! direct_ins {
($direct:ident) => {{
use $crate::ast::statement::Direction;
use $crate::ir::CfgInstruction;
let direct = Direction::from(stri... | code_fim | hard | {
"lang": "rust",
"repo": "spacemeshos/tytle",
"path": "/tytle_core/src/ir/macros.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: spacemeshos/tytle path: /tytle_core/src/ir/macros.rs
#[macro_export]
macro_rules! int_ins {
($num:expr) => {{
use $crate::ir::CfgInstruction;
CfgInstruction::Int($num)
}};
}
#[macro_export]
macro_rules! bool_ins {
($bool:expr) => {{
use $crate::ir::CfgInstruc... | code_fim | hard | {
"lang": "rust",
"repo": "spacemeshos/tytle",
"path": "/tytle_core/src/ir/macros.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: g2xpf/binary_size_comparison path: /build.rs
use std::process::Command;
<|fim_suffix|> Command::new("gcc")
.args(&["src/main.c", "-o", "bin/hello"])
.status()
.unwrap();
println!("cargo:rerun-if-changed=src/main.c");
}<|fim_middle|>fn main() {
| code_fim | easy | {
"lang": "rust",
"repo": "g2xpf/binary_size_comparison",
"path": "/build.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Command::new("gcc")
.args(&["src/main.c", "-o", "bin/hello"])
.status()
.unwrap();
println!("cargo:rerun-if-changed=src/main.c");
}<|fim_prefix|>// repo: g2xpf/binary_size_comparison path: /build.rs
use std::process::Command;
<|fim_middle|>fn main() {
| code_fim | easy | {
"lang": "rust",
"repo": "g2xpf/binary_size_comparison",
"path": "/build.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lgphp/rtmp path: /src/stream.rs
use std::collections::HashMap;
use std::io::{self, Write};
use std::net::TcpStream;
use super::error::{Error, Result};
use super::utils::{aggregate, read_buffer, read_buffer_sized, read_numeric, read_u32};
pub struct RtmpStream {
channels: HashMap<u16, Messa... | code_fim | hard | {
"lang": "rust",
"repo": "lgphp/rtmp",
"path": "/src/stream.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl RtmpStream {
pub fn new(stream: TcpStream) -> Self {
RtmpStream {
channels: HashMap::new(),
prev_message_header: HashMap::new(),
stream,
max_chunk_size_read: 128,
max_chunk_size_write: 128,
}
}
fn read_chunk_basi... | code_fim | hard | {
"lang": "rust",
"repo": "lgphp/rtmp",
"path": "/src/stream.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let dyn_foo = call(9090, "env?key=DYN_FOO").expect("call");
assert_eq!("dynamic".to_string(), dyn_foo);
let def_foo = call(9090, "env?key=DEF_FOO").expect("call");
assert_eq!("default".to_string(), def_foo);
}
#[test]
fn sets_cwd() {
let mut f = Fixtur... | code_fim | hard | {
"lang": "rust",
"repo": "kjdv/decompose",
"path": "/tests/ensemble.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> f.stop();
f.expect_stop();
}
#[test]
fn sets_env() {
std::env::set_var("DYN_FOO", "dynamic");
let mut f = Fixture::new("ensemble.toml");
assert_ready(&mut f);
let foo = call(9090, "env?key=FOO").expect("call");
assert_eq!("BAR".to_stri... | code_fim | hard | {
"lang": "rust",
"repo": "kjdv/decompose",
"path": "/tests/ensemble.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kjdv/decompose path: /tests/ensemble.rs
mod common;
mod ensemble {
use super::common::*;
fn assert_ready(f: &mut Fixture) -> (ProgramInfo, ProgramInfo) {
f.expect_start();
let srv = f.expect_program_ready();
assert_eq!("server", srv.name);
let proxy = ... | code_fim | hard | {
"lang": "rust",
"repo": "kjdv/decompose",
"path": "/tests/ensemble.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: redox-os/mio path: /src/sys/redox/selector.rs
use event::Event;
use std::{
self,
collections::{HashMap, HashSet},
fs::File,
io::prelude::*,
mem,
os::unix::io::{AsRawFd, RawFd},
slice,
sync::{
Mutex,
atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT... | code_fim | hard | {
"lang": "rust",
"repo": "redox-os/mio",
"path": "/src/sys/redox/selector.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut timeout_token = None;
if let Some(file) = timeout_fd {
self.inner_register(file.as_raw_fd(), TIMEOUT_TOKEN, 0)?;
timeout_token = Some(TIMEOUT_TOKEN.into());
}
let mut awakener_found = false;
let awakener = awakener.into();
e... | code_fim | hard | {
"lang": "rust",
"repo": "redox-os/mio",
"path": "/src/sys/redox/selector.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Events {
pub fn with_capacity(u: usize) -> Events {
Events { events: Vec::with_capacity(u) }
}
pub fn len(&self) -> usize {
self.events.len()
}
pub fn capacity(&self) -> usize {
self.events.capacity()
}
pub fn is_empty(&self) -> bool {
self.... | code_fim | hard | {
"lang": "rust",
"repo": "redox-os/mio",
"path": "/src/sys/redox/selector.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: boxdot/tonic-ws-transport path: /transport/src/web.rs
use crate::Error;
use futures_util::{sink::Sink, stream::Stream};
use js_sys::Uint8Array;
use pin_project::pin_project;
use tokio::sync::mpsc::{unbounded_channel, UnboundedReceiver};
use tungstenite::Error as TungsteniteError;
use wasm_bindg... | code_fim | hard | {
"lang": "rust",
"repo": "boxdot/tonic-ws-transport",
"path": "/transport/src/web.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Sink<Vec<u8>> for WebClientSink {
type Error = Error;
fn poll_ready(self: Pin<&mut Self>, _cx: &mut Context) -> Poll<Result<(), Self::Error>> {
Poll::Ready(if self.ws.ready_state() == WebSocket::OPEN {
Ok(())
} else {
Err(TungsteniteError::ConnectionCl... | code_fim | hard | {
"lang": "rust",
"repo": "boxdot/tonic-ws-transport",
"path": "/transport/src/web.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (dt, n) = particles.time_until_next_collisions(i, j, x_max, y_max);
return make_collision(t + dt, i as usize, n, cc_1, cc_2);
}
pub fn make_collision(t: f64, p_1: usize, p_2: i32, cc_1: u32, cc_2: u32)
-> Collision
{
assert!(p_2 >= -2);
Collision
{
time: t,
... | code_fim | hard | {
"lang": "rust",
"repo": "jonasbue/granular_gas",
"path": "/src/collisions.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jonasbue/granular_gas path: /src/collisions.rs
//extern crate ndarray;
//use ndarray::prelude::*;
use crate::particle;
use crate::simulation::status_bar;
use std::collections::BinaryHeap;
use std::cmp::{Ordering, Eq};
#[derive(PartialEq)]
pub struct Collision
{
time: f64,
particle_1_i... | code_fim | hard | {
"lang": "rust",
"repo": "jonasbue/granular_gas",
"path": "/src/collisions.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Iterates through all existing particles, and
// adds all expected collisions to CollisionQueue.
// This will create double entries.
pub fn fill_collision_queue(&mut self, particles: &particle::Particles, t_0: f64, x_max: f64, y_max: f64)
{
for i in 0..particles.get_len()
... | code_fim | hard | {
"lang": "rust",
"repo": "jonasbue/granular_gas",
"path": "/src/collisions.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: blakepettersson/autoimpl path: /autoimpl/src/lib.rs
#[macro_use] extern crate proc_macro_hack;
#[allow(unused_imports)]
#[macro_use] extern crate autoimpl_derive;
#[doc(hidden)]
pub use autoimpl_derive::*;
<|fim_suffix|>proc_macro_item_decl! {
/// Generates a default blanket impl for a ge... | code_fim | medium | {
"lang": "rust",
"repo": "blakepettersson/autoimpl",
"path": "/autoimpl/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>proc_macro_item_decl! {
/// Generates a default blanket impl for a generic trait that gets passed into
/// `autoimpl!`, with the same type parameters and type bounds as its trait.
///
/// # Panics
///
/// * If a trait is not a generic trait
/// * If more than one trait gets pas... | code_fim | medium | {
"lang": "rust",
"repo": "blakepettersson/autoimpl",
"path": "/autoimpl/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mesainner/crates-io path: /vendor/hyper/src/proto/h2/bdp.rs
// What should it do?
//
// # BDP Algorithm
//
// 1. When receiving a DATA frame, if a BDP ping isn't outstanding:
// 1a. Record current time.
// 1b. Send a BDP ping.
// 2. Increment the number of received bytes.
// 3. When the BDP ... | code_fim | hard | {
"lang": "rust",
"repo": "mesainner/crates-io",
"path": "/vendor/hyper/src/proto/h2/bdp.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // if the current `bytes` sample is at least 2/3 the previous
// bdp, increase to double the current sample.
if (bytes as f64) >= (self.bdp as f64) * 0.66 {
self.bdp = (bytes * 2).min(BDP_LIMIT) as WindowSize;
trace!("BDP increased to {}", self.bdp);
... | code_fim | hard | {
"lang": "rust",
"repo": "mesainner/crates-io",
"path": "/vendor/hyper/src/proto/h2/bdp.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(bdp) = self.calculate(bytes, rtt) {
Poll::Ready(bdp)
} else {
// XXX: this doesn't register a waker...?
Poll::Pending
}
}
fn calculate(&mut self, bytes: usize, rtt: Duration) -> Option<WindowSize> {
// No need to do a... | code_fim | hard | {
"lang": "rust",
"repo": "mesainner/crates-io",
"path": "/vendor/hyper/src/proto/h2/bdp.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rrybarczyk/path-gen path: /src/main.rs
mod chart;
mod common;
mod error;
mod horizontal;
mod vertical;
pub(crate) use crate::common::*;
fn main() -> Result<()> {
<|fim_suffix|> // Generate 5 horizontal lines
Horizontal::new()
.x_range(x.0, x.1)
.y_range(y.0, y.1)
... | code_fim | medium | {
"lang": "rust",
"repo": "rrybarczyk/path-gen",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Chart::new()
.x_range(x.0, x.1)
.y_range(y.0, y.1)
.h_lines(5)
.v_lines(5)
.write(None)?;
Ok(())
}<|fim_prefix|>// repo: rrybarczyk/path-gen path: /src/main.rs
mod chart;
mod common;
mod error;
mod horizontal;
mod vertical;
pub(crate) use crate::common::*... | code_fim | medium | {
"lang": "rust",
"repo": "rrybarczyk/path-gen",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
p_lens.push(p_len);
let new_r = i + p_len;
if new_r > r {
c = i;
r = new_r;
}
if p_len > max_p_len {
max_p_len = p_len;
idx = i;
}
}
let start = (idx - m... | code_fim | hard | {
"lang": "rust",
"repo": "xieweiking/leetcode-cn",
"path": "/problems/0005_longest-palindromic-substring/manacher/Solution.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: xieweiking/leetcode-cn path: /problems/0005_longest-palindromic-substring/manacher/Solution.rs
use std::cmp;
impl Solution {
pub fn longest_palindrome(s: String) -> String {
let s_len = s.len();
if s_len <= 1 {
return s;
}
let ptr = s.as_ptr();
... | code_fim | hard | {
"lang": "rust",
"repo": "xieweiking/leetcode-cn",
"path": "/problems/0005_longest-palindromic-substring/manacher/Solution.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JesseWright/aws-sdk-rust path: /sdk/mediastore/src/operation_ser.rs
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub fn serialize_operation_create_container(
input: &crate::input::CreateContainerInput,
) -> Result<smithy_http::body::SdkBody, smithy_types::... | code_fim | hard | {
"lang": "rust",
"repo": "JesseWright/aws-sdk-rust",
"path": "/sdk/mediastore/src/operation_ser.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn serialize_operation_list_tags_for_resource(
input: &crate::input::ListTagsForResourceInput,
) -> Result<smithy_http::body::SdkBody, smithy_types::Error> {
let mut out = String::new();
let mut object = smithy_json::serialize::JsonObjectWriter::new(&mut out);
crate::json_ser::serializ... | code_fim | hard | {
"lang": "rust",
"repo": "JesseWright/aws-sdk-rust",
"path": "/sdk/mediastore/src/operation_ser.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Prior99/musicpi-display path: /src/spectrum.rs
extern crate dft;
use std::sync::mpsc::{Sender, SendError};
use pulse_simple::Record;
use dft::{Operation, Plan};
use bus::{BusReader};
use ControlStatus;
use std::thread;
use core::cmp::Ordering;
const SAMPLE_RATE: u32 = 48000;
const DFT_WINDOW_S... | code_fim | hard | {
"lang": "rust",
"repo": "Prior99/musicpi-display",
"path": "/src/spectrum.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn run(mut control_rx: BusReader<ControlStatus>, sender: Sender<SpectrumResult>) -> Result<(), SendError<SpectrumResult>> {
let record = Record::new("MusicPi Display", "Record", None, SAMPLE_RATE);
let mut stereo_data = (0 .. DFT_WINDOW_SIZE).map(|_| [0.0, 0.0]).collect::<Vec<[f32;2]>>();
... | code_fim | hard | {
"lang": "rust",
"repo": "Prior99/musicpi-display",
"path": "/src/spectrum.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ansark88/rim_mod_translate_downloader path: /src/zip_archiver.rs
use std::fs;
use std::path::{Path, PathBuf};
pub struct ZipArchiver {
zip_file: PathBuf,
}
impl ZipArchiver {
pub fn new(zip_file: PathBuf) -> Self {
Self { zip_file }
}
pub fn extract<P: AsRef<Path>>(&se... | code_fim | hard | {
"lang": "rust",
"repo": "ansark88/rim_mod_translate_downloader",
"path": "/src/zip_archiver.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let archive = zip::ZipArchive::new(file.unwrap());
match archive {
Ok(_) => (),
Err(e) => return Err(format!("ZipFile Read Error!!!: {}", e.to_string())),
}
// Todo: 解凍した時に1段階フォルダが多いケースがある。Languagesフォルダがあるところまで降りる必要がある。それが実装されていない。
let extra... | code_fim | hard | {
"lang": "rust",
"repo": "ansark88/rim_mod_translate_downloader",
"path": "/src/zip_archiver.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // 반환할 배열
let obj_array = env.new_object_array(size,
string_class, fir_ele).unwrap();
for i in 0..size {
let item = env.new_string( rust_array[i as usize]).unwrap();
env.set_object_array_element(obj_array, i, item ).unwrap();
}
return obj_array;
}<|fim_... | code_fim | hard | {
"lang": "rust",
"repo": "Creon12/JavaArrayToRust",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Creon12/JavaArrayToRust path: /src/lib.rs
use jni::{objects::JString, sys::{jint, jobjectArray}};
use jni::objects::JClass;
use jni::JNIEnv;
#[no_mangle]
pub extern fn Java_Test_toRustFromStringArray(
env: JNIEnv,
_: JClass,
array: jobjectArray ,
length: jint) -> jobjectA... | code_fim | medium | {
"lang": "rust",
"repo": "Creon12/JavaArrayToRust",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RevelationOfTuring/Rust-exercise path: /src/error_handling_option_and_unwrap.rs
/*
在标准库(std)中有个叫做 Option<T>(选项)的枚举类型,
用于有 “不存在” 的可能性的情况。
它表现为以下两个 “option”(选项)中的一个:
- Some(T):找到一个属于 T 类型的元素
- None:找不到相应元素
<|fim_suffix|> // 指出每种情况下的做法
match mark {
... | code_fim | hard | {
"lang": "rust",
"repo": "RevelationOfTuring/Rust-exercise",
"path": "/src/error_handling_option_and_unwrap.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> occurs_panic_implicit(Some("michael.w"));
// 会panic
occurs_panic_implicit(None);
// 会panic
occurs_panic_implicit(Some("panic"));
}
}<|fim_prefix|>// repo: RevelationOfTuring/Rust-exercise path: /src/error_handling_option_and_unwrap.rs
/*
在标准库(std)中有个叫做 Opti... | code_fim | hard | {
"lang": "rust",
"repo": "RevelationOfTuring/Rust-exercise",
"path": "/src/error_handling_option_and_unwrap.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>:?}", siter.next());
println!("{:?}", siter.next());
println!("{:?}", siter.next());
println!("{:?}", siter.next());
}<|fim_prefix|>// repo: emergent/rust-sandbox path: /src/bin/iter.rs
fn main() {
let s = "aaa aaa aaaa";
let mut siter = s.sp<|fim_middle|>litn(2, ' ');
println!("{... | code_fim | medium | {
"lang": "rust",
"repo": "emergent/rust-sandbox",
"path": "/src/bin/iter.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: emergent/rust-sandbox path: /src/bin/iter.rs
fn main() {
let s = "aaa aaa aaaa";
let mut siter = s.sp<|fim_suffix|>:?}", siter.next());
println!("{:?}", siter.next());
println!("{:?}", siter.next());
println!("{:?}", siter.next());
}<|fim_middle|>litn(2, ' ');
println!("{... | code_fim | medium | {
"lang": "rust",
"repo": "emergent/rust-sandbox",
"path": "/src/bin/iter.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: romatthe/console path: /console-subscriber/src/lib.rs
enum Event {
Metadata(&'static Metadata<'static>),
Spawn {
id: span::Id,
metadata: &'static Metadata<'static>,
at: SystemTime,
fields: String,
},
Enter {
id: span::Id,
at: System... | code_fim | hard | {
"lang": "rust",
"repo": "romatthe/console",
"path": "/console-subscriber/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Event::Exit { id, at } => {
let mut stats = stats.update_or_default(id);
stats.current_polls -= 1;
if stats.current_polls == 0 {
if let Some(last_poll) = stats.last_p... | code_fim | hard | {
"lang": "rust",
"repo": "romatthe/console",
"path": "/console-subscriber/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T> TaskData<T> {
fn update_or_default(&mut self, id: span::Id) -> Updating<'_, T>
where
T: Default,
{
Updating(self.data.entry(id).or_default())
}
// fn update(&mut self, id: &span::Id) -> Option<Updating<'_, T>> {
// Some(Updating(self.data.get_mut(id)?))... | code_fim | hard | {
"lang": "rust",
"repo": "romatthe/console",
"path": "/console-subscriber/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: burnt43/json-rust path: /src/parsing/object.rs
use parsing::{Parser, ParseError};
use parsing::string::{StringParser};
use parsing::nil::{NilParser};
use types::{Object, Value};
enum ParseState {
SquareOne,
ExpectingStringKeyName,
}
struct ObjectParser {
object: Object,
s... | code_fim | hard | {
"lang": "rust",
"repo": "burnt43/json-rust",
"path": "/src/parsing/object.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Parser for ObjectParser {
fn get_result(&self) -> Result<Value, ParseError> {
Ok(Value::Object(Object::new()))
}
fn push_token(&mut self, ch: char) -> Result<(),ParseError> {
match self.state {
ParseState::SquareOne => {
match ch {
... | code_fim | hard | {
"lang": "rust",
"repo": "burnt43/json-rust",
"path": "/src/parsing/object.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn fails_when_disconnected() {
let mut grid = testing_grid();
*grid.get_mut(V2i(2, 1)).expect("Failed to get cell") = 1;
let res = grid.path::<Linf>(V2i(1, 3), V2i(3, 3), None);
println!("path: {:?}", res);
assert!(res.is_err());
}
#[test]
... | code_fim | hard | {
"lang": "rust",
"repo": "Grissess/rogue_utils",
"path": "/src/grid/path.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Grissess/rogue_utils path: /src/grid/path.rs
use crate::*;
use super::{Grid, region::{Region, RegionConfig}};
use std::cmp::{Reverse, Ordering};
use std::collections::{BinaryHeap, HashMap};
pub trait Traversable: {
fn can_pass(&self) -> bool;
}
pub trait Neighbors<T>: Sized {
fn neigh... | code_fim | hard | {
"lang": "rust",
"repo": "Grissess/rogue_utils",
"path": "/src/grid/path.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T: Traversable> Grid<T> {
pub fn path<N>(&self, start: V2i, goal: V2i, radius: Option<usize>) -> Result<Vec<V2i>, Error>
where
V2i: Neighbors<N>
{
let limsq = radius.map(|x| x*x);
path::<N, _>(start, goal, |pos| {
if let Some(l2sq) = limsq {
... | code_fim | hard | {
"lang": "rust",
"repo": "Grissess/rogue_utils",
"path": "/src/grid/path.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kaisellgren/collada path: /src/param.rs
use asset::Asset;
#[derive(Debug)]
pu<|fim_suffix|> String,
semantic: Option<Asset>
}<|fim_middle|>b struct Param {
sid: Option<String>,
name: Option<String>,
typ: | code_fim | medium | {
"lang": "rust",
"repo": "kaisellgren/collada",
"path": "/src/param.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> String,
semantic: Option<Asset>
}<|fim_prefix|>// repo: kaisellgren/collada path: /src/param.rs
use asset::Asset;
#[derive(Debug)]
pub struct Param {
sid: Option<Strin<|fim_middle|>g>,
name: Option<String>,
typ: | code_fim | easy | {
"lang": "rust",
"repo": "kaisellgren/collada",
"path": "/src/param.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use super::*;
use test::Bencher;
use xavier_initialize;
#[test]
fn sample_eval() {
let weights = arr2(&[[1.0, 2.0, 3.0, 4.0], [5.0, 6.0, 7.0, 8.0]]).into_dyn();
let vecs = arr2(&[[1.0, 2.0], [3.0, 4.0]]).into_dyn();
let m = MatMul();
... | code_fim | hard | {
"lang": "rust",
"repo": "CasperN/drug",
"path": "/src/nodes/matmul.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn sample_eval() {
let weights = arr2(&[[1.0, 2.0, 3.0, 4.0], [5.0, 6.0, 7.0, 8.0]]).into_dyn();
let vecs = arr2(&[[1.0, 2.0], [3.0, 4.0]]).into_dyn();
let m = MatMul();
let o = m.eval(&[weights.view(), vecs.view()]);
assert_eq!(
o,
... | code_fim | hard | {
"lang": "rust",
"repo": "CasperN/drug",
"path": "/src/nodes/matmul.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: CasperN/drug path: /src/nodes/matmul.rs
use ndarray::prelude::*;
use nodes::Operation;
/// implements matrix multiply [Operation](trait.Operation.html).
/// See [Node](enum.Node.html) constructor for full description.
#[derive(Debug, Serialize, Deserialize)]
pub struct MatMul();
impl Operation... | code_fim | hard | {
"lang": "rust",
"repo": "CasperN/drug",
"path": "/src/nodes/matmul.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: despawnerer/spready path: /src/graph.rs
use std::collections::HashMap;
use std::collections::HashSet;
use std::hash::Hash;
#[derive(Debug)]
pub struct GraphHasCycles;
#[derive(Debug, Clone)]
pub struct DirectedGraph<R>
where
R: Hash + Eq + Clone + Copy,
{
nodes: HashMap<R, Node<R>>,
}
... | code_fim | hard | {
"lang": "rust",
"repo": "despawnerer/spready",
"path": "/src/graph.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.nodes.entry(reference).or_insert_with(Node::default)
}
fn get_references_with_no_incoming_edges(&self) -> Vec<R> {
self.nodes
.iter()
.filter(|(_, n)| !n.has_incoming_edges())
.map(|(r, _)| r.clone())
.collect()
}
// WA... | code_fim | hard | {
"lang": "rust",
"repo": "despawnerer/spready",
"path": "/src/graph.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if graph.has_edges() {
Err(GraphHasCycles)
} else {
Ok(sorted_references)
}
}
fn get(&self, reference: R) -> Option<&Node<R>> {
self.nodes.get(&reference)
}
fn get_mut(&mut self, reference: R) -> Option<&mut Node<R>> {
self.... | code_fim | hard | {
"lang": "rust",
"repo": "despawnerer/spready",
"path": "/src/graph.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(())
}
fn normalize_vendor(vendor: &str) -> String {
match vendor {
"0x41" => String::from("ARM Limited"),
_ => String::from("3rd Party Limited"),
}
}
fn normalize_model(model: &str) -> String {
match model {
"8" => St... | code_fim | hard | {
"lang": "rust",
"repo": "bergwolf/kata-containers",
"path": "/src/tools/kata-ctl/src/arch/aarch64/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bergwolf/kata-containers path: /src/tools/kata-ctl/src/arch/aarch64/mod.rs
// Copyright (c) 2022 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0
//
#[cfg(target_arch = "aarch64")]
pub use arch_specific::*;
mod arch_specific {
use crate::check;
use crate::types::*;
use c... | code_fim | hard | {
"lang": "rust",
"repo": "bergwolf/kata-containers",
"path": "/src/tools/kata-ctl/src/arch/aarch64/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn get_cpu_details() -> Result<(String, String)> {
let (vendor, model) = utils::get_generic_cpu_details(check::PROC_CPUINFO)?;
let norm_vendor = normalize_vendor(&vendor);
let norm_model = normalize_model(&model);
Ok((norm_vendor, norm_model))
}
pub fn get_... | code_fim | hard | {
"lang": "rust",
"repo": "bergwolf/kata-containers",
"path": "/src/tools/kata-ctl/src/arch/aarch64/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MaxBrinegar/stack-rust path: /src/main.rs
mod list;
mod stack;
pub use crate::stack::Stack;
<|fim_suffix|> let mut stack: Stack<i32> = Stack::new();
stack.push(3);
stack.push(5);
println!("{:?}", stack);
}<|fim_middle|>fn main() {
| code_fim | easy | {
"lang": "rust",
"repo": "MaxBrinegar/stack-rust",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MaxBrinegar/stack-rust path: /src/main.rs
mod list;
mod stack;
pub use crate::stack::Stack;
fn main() {
<|fim_suffix|> stack.push(3);
stack.push(5);
println!("{:?}", stack);
}<|fim_middle|> let mut stack: Stack<i32> = Stack::new();
| code_fim | easy | {
"lang": "rust",
"repo": "MaxBrinegar/stack-rust",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("{:?}", stack);
}<|fim_prefix|>// repo: MaxBrinegar/stack-rust path: /src/main.rs
mod list;
mod stack;
pub use crate::stack::Stack;
<|fim_middle|>fn main() {
let mut stack: Stack<i32> = Stack::new();
stack.push(3);
stack.push(5);
| code_fim | medium | {
"lang": "rust",
"repo": "MaxBrinegar/stack-rust",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>{
*b += 1;
}
Ok(bytes)
})?
.sink_into(output)
})
}<|fim_prefix|>// repo: alibaba/GraphScope path: /interactive_engine/executor/engine/pegasus/server/examples/dynlib_exp/src/lib.rs
use pegasus::api::{Map, Sink};
use pegasus::B... | code_fim | medium | {
"lang": "rust",
"repo": "alibaba/GraphScope",
"path": "/interactive_engine/executor/engine/pegasus/server/examples/dynlib_exp/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alibaba/GraphScope path: /interactive_engine/executor/engine/pegasus/server/examples/dynlib_exp/src/lib.rs
use pegasus::api::{Map, Sink};
use pegasus::BuildJobError;
use pegasus::Worker;
#[no_mangle]
pub extern "Rust" fn build_job(source: &[u8], worker: &mut Worker<Vec<u8>, Vec<u8>>) -> Result<... | code_fim | medium | {
"lang": "rust",
"repo": "alibaba/GraphScope",
"path": "/interactive_engine/executor/engine/pegasus/server/examples/dynlib_exp/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl LogItem {
pub fn new() -> Self {
LogItem {
content: Vec::with_capacity(NORMAL_LOG_SIZE),
}
}
pub fn u64(&mut self, mut n: u64) -> &mut Self {
// max length of a u64 is 20: 18442240474082181120
let mut current_cursor = self.content.len()... | code_fim | hard | {
"lang": "rust",
"repo": "longfangsong/flog",
"path": "/src/lib.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn log_str(content: &str) {
COLLECTOR.with(move |collector| {
let mut collector = collector.borrow_mut();
collector.buffer.extend_from_slice(content.as_bytes());
if collector.buffer.len() > BUFFER_SIZE {
collector.to_file.borrow_mut().write_all(&collector.buffer... | code_fim | hard | {
"lang": "rust",
"repo": "longfangsong/flog",
"path": "/src/lib.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: longfangsong/flog path: /src/lib.rs
use std::fs::File;
use std::cell::RefCell;
use std::io::Write;
use std::thread;
use std::cmp::max;
// todo: make it configurable
const BUFFER_SIZE: usize = 16384;
const NORMAL_LOG_SIZE: usize = 64;
pub struct Collector {
buffer: Vec<u8>,
to_file: Ref... | code_fim | hard | {
"lang": "rust",
"repo": "longfangsong/flog",
"path": "/src/lib.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
#[cfg(not(debug_assertions))]
fn prod() {
let asset = embed!("examples/public/".to_owned());
match asset("index.html".to_owned()) {
None => assert!(false, "index.html should exist"),
_ => assert!(true),
}
match asset("gg.html".to_... | code_fim | hard | {
"lang": "rust",
"repo": "jgrowl/rust-embed",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jgrowl/rust-embed path: /src/lib.rs
#[macro_use]
extern crate log;
extern crate walkdir;
pub type Asset = Box<Fn(String) -> Option<Vec<u8>> + std::marker::Sync + std::marker::Send>;
#[cfg(debug_assertions)]
pub fn generate_assets(parent_path: String) -> Asset {
use std::fs::File;
use s... | code_fim | hard | {
"lang": "rust",
"repo": "jgrowl/rust-embed",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> {
return false;
}
}
_ => ()
}
}
if !stack.is_empty() {
return false;
}
true
}<|fim_prefix|>// repo: Schenk75/Learn-Rust path: /exercism/matching-brackets/src/lib.rs
pub fn brackets_are_balanced(string: &str) -> b... | code_fim | hard | {
"lang": "rust",
"repo": "Schenk75/Learn-Rust",
"path": "/exercism/matching-brackets/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if stack.pop() != Some('[') {
return false;
}
}
'}' => {
if stack.pop() != Some('{') {
return false;
}
}
_ => ()
}
}
if !stack.is_empty() {
... | code_fim | hard | {
"lang": "rust",
"repo": "Schenk75/Learn-Rust",
"path": "/exercism/matching-brackets/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Schenk75/Learn-Rust path: /exercism/matching-brackets/src/lib.rs
pub fn brackets_are_balanced(string: &str) -> bool {
let mut stack = Vec::new();
for s in string.chars() {
match s {
'(' | '[' | '{' => stack<|fim_suffix|> {
return false;
... | code_fim | hard | {
"lang": "rust",
"repo": "Schenk75/Learn-Rust",
"path": "/exercism/matching-brackets/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("first word from value :{}",first_word(&s));
let a = [1, 2, 3, 4, 5];
let slice = &a[1..3];
println!("slice value :{:?}",slice);
}
fn first_word(s: &String) -> &str {
let bytes = s.as_bytes();
for (i, &item) in bytes.iter().enumerate() {
if item == b' ' {
... | code_fim | hard | {
"lang": "rust",
"repo": "DhanAnJay-Ahire/Rust",
"path": "/ownership_assignment/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // slices
slices_outpuy();
}
fn cal_string_len(str1 :&String) -> usize{
str1.len()
}
fn return_string_reference(str1:String)->String{
str1
}
fn slices_outpuy(){
// slices can not borrow as a mutable
let s = String::from("hello world");
let hello = &s[0..5];
let world = &s... | code_fim | hard | {
"lang": "rust",
"repo": "DhanAnJay-Ahire/Rust",
"path": "/ownership_assignment/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DhanAnJay-Ahire/Rust path: /ownership_assignment/src/main.rs
fn main() {
/*
Memories allocating :
1. heap - dynamic type of data types are allocating memories into heap -m string , Clone - deep copy
2. stack - fixed size data allocated into stack, copy - deep copy
Fixed Siz... | code_fim | hard | {
"lang": "rust",
"repo": "DhanAnJay-Ahire/Rust",
"path": "/ownership_assignment/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Scttpr/api_rest_actix path: /src/services/env.rs
use std::env;
use crate::utils::errors::error_messages;
<|fim_suffix|>pub fn get_var(name: &str) -> String {
env::var(&name).expect(&error_messages::not_found(name))
}<|fim_middle|>pub fn load_dotenv() {
dotenv::dotenv().expect("Failed to... | code_fim | medium | {
"lang": "rust",
"repo": "Scttpr/api_rest_actix",
"path": "/src/services/env.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn get_var(name: &str) -> String {
env::var(&name).expect(&error_messages::not_found(name))
}<|fim_prefix|>// repo: Scttpr/api_rest_actix path: /src/services/env.rs
use std::env;
use crate::utils::errors::error_messages;
<|fim_middle|>pub fn load_dotenv() {
dotenv::dotenv().expect("Failed to... | code_fim | medium | {
"lang": "rust",
"repo": "Scttpr/api_rest_actix",
"path": "/src/services/env.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wBanano/banano_rs path: /src/types/mod.rs
//! Banano Types
use data_encoding::{Encoding};
use data_encoding_macro::new_encoding;
use blake2::{
VarBlake2b,
digest::{Update, VariableOutput},
};
pub use self::seed::Seed;
pub use self::block::BlockHash;
pub use self::address::Address;
pub u... | code_fim | hard | {
"lang": "rust",
"repo": "wBanano/banano_rs",
"path": "/src/types/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn can_convert_address_to_public_key() {
let addr = Address("ban_3t6k35gi95xu6tergt6p69ck76ogmitsa8mnijtpxm9fkcm736xtoncuohr3".into());
let public_key = addr.to_public_key().unwrap();
let p_key_str = HEXLOWER_PERMISSIVE.encode(&public_key.0[..]);
// shamelessly copied from https://git... | code_fim | hard | {
"lang": "rust",
"repo": "wBanano/banano_rs",
"path": "/src/types/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> addresses.into_iter().for_each(|addr| {
Address(addr.into()).to_public_key().expect("Couldn't Validate Address");
})
}
#[test]
fn can_invalidate_addresses() {
let addresses = vec![
"ban_38nm8t5rimw6h6j7wyokbs8jiygzs7baoha4pqzhfw1k79npyr1km8w6y7r7",
"bam_38nm8t5rimw6h6j7wyokbs8jiygzs7... | code_fim | hard | {
"lang": "rust",
"repo": "wBanano/banano_rs",
"path": "/src/types/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let ty = GlobalType::new(ValType::F64, Mutability::Const);
let g = Global::new(store, ty, Val::F64(0x4084_d000_0000_0000)).unwrap();
ret.insert("global_f64", Extern::Global(g));
let ty = TableType::new(ValType::FuncRef, Limits::new(10, Some(20)));
let table = Table::new(store, ty, Val... | code_fim | hard | {
"lang": "rust",
"repo": "jfoote/wasmtime",
"path": "/crates/wast/src/spectest.rs",
"mode": "spm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_suffix|> let ty = GlobalType::new(ValType::I64, Mutability::Const);
let g = Global::new(store, ty, Val::I64(666)).unwrap();
ret.insert("global_i64", Extern::Global(g));
let ty = GlobalType::new(ValType::F32, Mutability::Const);
let g = Global::new(store, ty, Val::F32(0x4426_8000)).unwrap();
... | code_fim | hard | {
"lang": "rust",
"repo": "jfoote/wasmtime",
"path": "/crates/wast/src/spectest.rs",
"mode": "spm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jfoote/wasmtime path: /crates/wast/src/spectest.rs
use anyhow::Result;
use std::collections::HashMap;
use std::rc::Rc;
use wasmtime::*;
struct MyCall<F>(F);
impl<F> Callable for MyCall<F>
where
F: Fn(&[Val], &mut [Val]) -> Result<(), Trap>,
{
fn call(&self, params: &[Val], results: &mu... | code_fim | hard | {
"lang": "rust",
"repo": "jfoote/wasmtime",
"path": "/crates/wast/src/spectest.rs",
"mode": "psm",
"license": "LLVM-exception",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hellow554/stm32l4x6-memory-map path: /src/dfsdm.rs
AwcfrW { bits: 0u32 }
}
# [ doc = "Bits 8:15 - Clear the analog watchdog high threshold flag" ]
pub fn clrawhtf(&mut self, value: u8) -> &mut Self {
const OFFSET: u8 = 8u8;
const MASK: u8 = 255;
self.bits &= !... | code_fim | hard | {
"lang": "rust",
"repo": "hellow554/stm32l4x6-memory-map",
"path": "/src/dfsdm.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hellow554/stm32l4x6-memory-map path: /src/dfsdm.rs
{
bits: u32,
}
impl Dfsdm0IcrR {
# [ doc = "Bits 24:31 - Clear the short-circuit detector flag" ]
pub fn clrscdf(&self) -> u8 {
const MASK: u32 = 255;
const OFFSET: u8 = 24u8;
((self.bits >> OFFSET) & MASK) ... | code_fim | hard | {
"lang": "rust",
"repo": "hellow554/stm32l4x6-memory-map",
"path": "/src/dfsdm.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|># [ derive ( Clone , Copy ) ]
# [ repr ( C ) ]
pub struct Dfsdm2JchgrR {
bits: u32,
}
impl Dfsdm2JchgrR {
# [ doc = "Bits 0:7 - Injected channel group selection" ]
pub fn jchg(&self) -> u8 {
const MASK: u32 = 255;
const OFFSET: u8 = 0u8;
((self.bits >> OFFSET) & MASK) ... | code_fim | hard | {
"lang": "rust",
"repo": "hellow554/stm32l4x6-memory-map",
"path": "/src/dfsdm.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: putuwaw/tlx-toki-answer path: /10. Subprogram/C. Membalik yang Terbalik/c_membalik_yang_terbalik.rs
fn reverse(mut x: i32) -> i32 {
let mut rev: i32 = 0;
while x > 0 {
rev = rev * 10 + x % 10;
x = x / 10;
}
return rev;
}
<|fim_suffix|> let mut reader = String:... | code_fim | medium | {
"lang": "rust",
"repo": "putuwaw/tlx-toki-answer",
"path": "/10. Subprogram/C. Membalik yang Terbalik/c_membalik_yang_terbalik.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ernestas-poskus/text.rs path: /src/sort/mod.rs
use std::collections::HashMap;
use occurrence::Occurrence;
pub trait Sort {
fn sort_by_occurrence(&self) -> Vec<String>;
fn sort_by_occurrence_with_map(&self, &HashMap<&str, usize>) -> Vec<String>;
fn repetitions(&self) -> Vec<(String, ... | code_fim | hard | {
"lang": "rust",
"repo": "ernestas-poskus/text.rs",
"path": "/src/sort/mod.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> sorted.dedup();
for s in sorted {
let times = *occurred.get(s.as_str()).unwrap();
repetitions.push((s, times));
}
repetitions
}
}<|fim_prefix|>// repo: ernestas-poskus/text.rs path: /src/sort/mod.rs
use std::collections::HashMap;
use occurrenc... | code_fim | hard | {
"lang": "rust",
"repo": "ernestas-poskus/text.rs",
"path": "/src/sort/mod.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> for s in sorted {
let times = *occurred.get(s.as_str()).unwrap();
repetitions.push((s, times));
}
repetitions
}
}<|fim_prefix|>// repo: ernestas-poskus/text.rs path: /src/sort/mod.rs
use std::collections::HashMap;
use occurrence::Occurrence;
pub trait... | code_fim | hard | {
"lang": "rust",
"repo": "ernestas-poskus/text.rs",
"path": "/src/sort/mod.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vijfhoek/trillium path: /forwarding/src/lib.rs
/*!
# Trillium handler for `x-forwarded-*` / `forwarded`
This simple handler rewrites the request's host, secure setting, and
peer ip based on headers added by a trusted reverse proxy.
The specific headers that are understood by this handler are:
... | code_fim | hard | {
"lang": "rust",
"repo": "vijfhoek/trillium",
"path": "/forwarding/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>use std::{fmt::Debug, net::IpAddr, ops::Deref};
use trillium::{async_trait, conn_unwrap, Conn, Handler};
#[derive(Debug)]
#[non_exhaustive]
enum TrustProxy {
Always,
Never,
Cidr(Vec<cidr::AnyIpCidr>),
Function(TrustFn),
}
struct TrustFn(Box<dyn Fn(&IpAddr) -> bool + Send + Sync + 'static... | code_fim | hard | {
"lang": "rust",
"repo": "vijfhoek/trillium",
"path": "/forwarding/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> ```
# use trillium_forwarding::Forwarding;
# use std::net::IpAddr;
let forwarding = Forwarding::trust_fn(IpAddr::is_loopback);
let forwarding = Forwarding::trust_fn(|ip| match ip {
IpAddr::V6(_) => false,
IpAddr::V4(ipv4) => ipv4.is_link_local()
});
```
*/
... | code_fim | hard | {
"lang": "rust",
"repo": "vijfhoek/trillium",
"path": "/forwarding/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kas-gui/kas path: /crates/kas-core/src/theme/traits.rs
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License in the LICENSE-APACHE file or at:
// https://www.apache.org/li... | code_fim | hard | {
"lang": "rust",
"repo": "kas-gui/kas",
"path": "/crates/kas-core/src/theme/traits.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
/// Requirements on theme config (with `config` feature)
#[cfg(feature = "serde")]
pub trait ThemeConfig:
Clone + std::fmt::Debug + 'static + for<'a> serde::Deserialize<'a> + serde::Serialize
{
/// Has the config ever been updated?
fn is_dirty(&self) -> bool;
/// Apply startup effects
... | code_fim | hard | {
"lang": "rust",
"repo": "kas-gui/kas",
"path": "/crates/kas-core/src/theme/traits.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.