blob_id stringlengths 40 40 | language stringclasses 1
value | repo_name stringlengths 5 140 | path stringlengths 5 183 | src_encoding stringclasses 6
values | length_bytes int64 12 5.32M | score float64 2.52 4.94 | int_score int64 3 5 | detected_licenses listlengths 0 47 | license_type stringclasses 2
values | text stringlengths 12 5.32M | download_success bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|
5281539881caf7cf94e59df5563e7280ef0733b1 | Rust | farzonl/interviewPrep | /rust/src/bin/main.rs | UTF-8 | 1,679 | 3.390625 | 3 | [] | no_license |
extern crate interviewprep;
pub fn main() {
}
#[test]
fn ch10_1_merge_blarger() {
let mut a: [i32; 4] = [1, 2, 0, 0];
let b: [i32; 2] = [3, 4];
let sln: [i32; 4] = [1,2,3,4];
interviewprep::merge(& mut a, 2, &b);
assert!(a.iter().zip(sln.iter()).all(|(a,b)| a == b), "Arrays are not equal");
}
... | true |
07a87edffd5d4ac261e39299793bcaed57367aa5 | Rust | TangentW/sine_chat | /src/message/handshake.rs | UTF-8 | 783 | 3.078125 | 3 | [
"MIT"
] | permissive | use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct Handshake {
pub token: String,
}
impl Handshake {
pub fn new(token: String) -> Self {
Self { token }
}
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct HandshakeReply {
pub success: boo... | true |
7762f140935a50b1d4b1bcd27d98062c85d36c8c | Rust | udoprog/async-oauth2 | /src/lib.rs | UTF-8 | 43,724 | 3.171875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! [<img alt="github" src="https://img.shields.io/badge/github-udoprog/async--oauth2-8da0cb?style=for-the-badge&logo=github" height="20">](https://github.com/udoprog/async-oauth2)
//! [<img alt="crates.io" src="https://img.shields.io/crates/v/async-oauth2.svg?style=for-the-badge&color=fc8d62&logo=rust" height="20">](h... | true |
a0c54f26e3647372623a80e0fc1f1288a081b999 | Rust | nkotlyarov/zenith | /zenith_utils/src/sock_split.rs | UTF-8 | 6,111 | 2.90625 | 3 | [
"Apache-2.0",
"PostgreSQL"
] | permissive | use std::{
io::{self, BufReader, Write},
net::{Shutdown, TcpStream},
sync::Arc,
};
use rustls::Session;
/// Wrapper supporting reads of a shared TcpStream.
pub struct ArcTcpRead(Arc<TcpStream>);
impl io::Read for ArcTcpRead {
fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
(&*s... | true |
86a2e3f4370a7837c6c64b16cab9710f03d59bb7 | Rust | p-alik/wundergraph | /wundergraph/tests/mutations/delete.rs | UTF-8 | 3,202 | 2.546875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::helper::*;
use wundergraph_example::MyContext;
#[test]
fn delete_existing() {
let (schema, pool) = get_example_schema();
let ctx = MyContext::new(pool.get().unwrap());
let res = execute_query(
&schema,
&ctx,
"
{
Heros {
id
heroName
}
}
",
);
... | true |
777e71beb1a05475c280d0baaacd20506f504535 | Rust | kaz184/rust-comp-snippets | /src/sequence01.rs | UTF-8 | 3,316 | 3.421875 | 3 | [] | no_license | #[snippet = "BinarySearch"]
#[doc = "lower,upper are inclusive range"]
pub struct BinarySearch<F> {
pub p: F,
pub lower: i64,
pub upper: i64,
}
#[snippet = "BinarySearch"]
impl <F: Fn(i64) -> bool> BinarySearch<F> {
#[doc = "O(log(upper-lower))"]
pub fn lower_bound(&self) -> i64 {
let lower ... | true |
82ab7ad2e368d2f936bcea351e89be95b5c4d6af | Rust | AlexxNica/hornet | /src/client/metric/timer.rs | UTF-8 | 4,192 | 3.234375 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use super::*;
use time;
use time::Tm;
/// A timer metric for tracking elapsed time
///
/// Internally uses a `Metric<i64>` with `Semantics::Instant` and `1` time dimension
pub struct Timer {
metric: Metric<i64>,
time_scale: Time,
start_time: Option<Tm>
}
/// Error encountered while starting or stopping a ... | true |
490c13a6c1902ba571447ede640c4507e9c0cb56 | Rust | rhololkeolke/nphysics_model_explorer | /model-explorer/src/state/run_sim.rs | UTF-8 | 1,449 | 2.53125 | 3 | [] | no_license | use crate::resource;
use amethyst::{
input::is_key_down, renderer::VirtualKeyCode, GameData, SimpleState, SimpleTrans, StateData,
StateEvent, Trans,
};
pub struct RunSimState;
impl SimpleState for RunSimState {
fn handle_event(
&mut self,
data: StateData<'_, GameData<'_, '_>>,
even... | true |
feefcd027cbf70facf8093eed3082b3afecb42ae | Rust | steamroller-airmash/airmash-server | /server-config/src/util.rs | UTF-8 | 3,569 | 3.171875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::cell::Cell;
use std::mem::ManuallyDrop;
use std::ops::{Deref, DerefMut};
pub(crate) mod duration {
use std::time::Duration;
use serde::{Deserialize, Deserializer, Serializer};
pub(crate) fn serialize<S: Serializer>(dur: &Duration, ser: S) -> Result<S::Ok, S::Error> {
ser.serialize_f64(dur.as_secs_... | true |
7dcedb38627774b125e8f24756d2dd5d6d7812ab | Rust | FreskyZ/fff-lang | /src/common/arena/tests.rs | UTF-8 | 6,035 | 2.9375 | 3 | [
"Apache-2.0"
] | permissive |
use super::*;
#[test]
fn basic() {
struct Node1 { span: u32, isid: u32 }
struct Node2 { span: u32, isid: u32, span2: u128, keyword: u8, separator: u8 }
struct Node3 { span: u32, node1: Index<Node1>, node4: Option<Index<Node4>> }
struct Node4 { span: u32, node3s: Slice<Index<Node3>> }
let arena = ... | true |
cae1b82286641665ad16b0f8035d1f963ff8f607 | Rust | jiricodes/rust_http_server | /src/http/query_string.rs | UTF-8 | 1,150 | 3.453125 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
#[derive(Debug)]
pub struct QueryString<'a> {
data: HashMap<&'a str, QueryValue<'a>>,
}
#[derive(Debug)]
pub enum QueryValue<'a> {
Single(&'a str),
Multiple(Vec<&'a str>),
}
impl<'a> QueryString<'a> {
pub fn get(&self, key: &str) -> Option<&QueryValue> {
self.da... | true |
45b13478db85fc36bb450913f61b9be474c9f245 | Rust | mikialex/rxsl | /src/symbol_table.rs | UTF-8 | 1,561 | 3.0625 | 3 | [] | no_license | use crate::ir::PrimitiveType;
use std::collections::HashMap;
#[derive(Clone, Copy)]
pub struct SymbolInfo {
pub is_const: bool,
pub ty: PrimitiveType,
}
pub struct SymbolTable {
scopes: Vec<ScopeSymbolTable>,
}
impl SymbolTable {
pub fn new() -> Self {
Self { scopes: Vec::new() }
}
p... | true |
abaf8cd3ab7fceea4eeaf047d5c8d75a8a4799cf | Rust | sa77/rusty-converter | /src/main.rs | UTF-8 | 727 | 3.109375 | 3 | [] | no_license | #[allow(unused_imports)]
use std::error::Error;
use std::io;
use std::process;
fn main() {
// graceful exit
if let Err(err) = run() {
println!("{}", err);
process::exit(1);
}
}
// Box<dyn Error> means 'any kind of error' - hard to inspect
fn run() -> Result<(), Box<dyn Error>> {
let m... | true |
cc292a965d76f15260480d7add263863f975b8b8 | Rust | sprt/linkerd2-proxy | /src/control/destination/client.rs | UTF-8 | 2,832 | 2.515625 | 3 | [
"Apache-2.0"
] | permissive | use futures::{Async, Poll, Stream};
use tower_grpc::{self as grpc, generic::client::GrpcService, BoxBody};
use api::destination::{client::Destination, GetDestination, Update};
use control::remote_stream::{self, Remote};
use std::sync::Arc;
use NameAddr;
/// A client for making service discovery requests to the des... | true |
188f2abac075d9e3d4e104f02d886acbe8efed76 | Rust | tmtz/haphazard-1 | /src/deleter.rs | UTF-8 | 1,332 | 3.234375 | 3 | [] | no_license | pub trait Reclaim {}
impl<T> Reclaim for T {}
pub trait Deleter {
/// # Safety
/// `ptr` must have been allocated by the corresponding allocation method.
/// delete must be called at most once for each `ptr`.
unsafe fn delete(&self, ptr: *mut dyn Reclaim);
}
impl Deleter for unsafe fn(*mut (dyn Reclai... | true |
65cb76f09dfabcaeb1b94b95265b12108501aed2 | Rust | boxdot/advent-of-code-2019 | /stiar/day25/src/lib.rs | UTF-8 | 2,259 | 2.890625 | 3 | [] | no_license | mod intcode;
pub use intcode::*;
pub fn run_command(program: &mut Program, iter: impl Iterator<Item = i64>) -> String {
program.run(iter).map(|c| (c as u8) as char).collect()
}
pub fn to_ascii(input: &str) -> Vec<i64> {
input.chars().map(|c| (c as u8) as i64).collect()
}
pub fn collect_inventory(program: &mu... | true |
2522b3b93bdc6de77b1352d7e236b49b6343ce9e | Rust | COLDTURNIP/raphanus_leetcode | /rust/src/p740.rs | UTF-8 | 2,726 | 3.796875 | 4 | [] | no_license | /*
Problem 740. Delete and Earn
============================
https://leetcode.com/problems/delete-and-earn/
Given an array nums of integers, you can perform operations on the array.
In each operation, you pick any nums[i] and delete it to earn nums[i] points. After, you must
delete every element equal to nums[i] - 1... | true |
c803bb62b40598cc5006184591a5990580928aae | Rust | Plutor/advent-of-code-2020 | /8.rs | UTF-8 | 739 | 2.78125 | 3 | [] | no_license | fn main() {
let data = std::fs::read_to_string("8.dat").expect("oops");
let mut instructions = data.lines().collect::<Vec<&str>>();
let mut acc: i32 = 0;
let mut pc: i32 = 0;
loop {
let instruction = instructions[pc as usize];
println!("pc={}, acc={}, running {}", pc, acc, instruc... | true |
0e3b47f81fac4e25dbbbba2a0596b6f614461244 | Rust | yjhmelody/leetcode-rust | /src/design_circular_queue.rs | UTF-8 | 2,324 | 3.6875 | 4 | [
"MIT"
] | permissive | #![allow(dead_code)]
#![allow(unused_variables)]
use std::iter;
// One more space
#[derive(Debug, Clone)]
pub struct MyCircularQueue {
q: Vec<i32>,
head: usize,
tail: usize,
size: usize,
}
impl MyCircularQueue {
/** Initialize your data structure here. Set the size of the queue to be k. */
pu... | true |
d14f9efb7db7f635d3a46e3d3a331b53aebadcbd | Rust | khonsulabs/stylecs | /stylecs-macros/src/lib.rs | UTF-8 | 2,162 | 2.8125 | 3 | [] | no_license | use attribute_derive::Attribute;
use manyhow::manyhow;
use proc_macro2::{Ident, TokenStream};
use quote::quote;
use syn::{DeriveInput, Expr};
#[derive(Attribute, Debug)]
#[attribute(ident = style)]
struct StyleComponent {
name: Option<Ident>,
authority: Option<Ident>,
inherited: Option<bool>,
merge: Op... | true |
01d1e146bef1efc5f76882c41ca0c23aafbcc975 | Rust | afnanenayet/oars | /oars/src/perm_vec.rs | UTF-8 | 1,230 | 4.03125 | 4 | [
"MIT"
] | permissive | //! Provides an interface for a permutation vector class that makes it easy to
//! randomly shuffle orthogonal arrays, or shuffle any set.
use rand::seq::SliceRandom;
use std::ops::Index;
/// This is a vector containing the elements ${0, 1 \cdots n - 1}$, shuffled
/// around to easily allow for a user to create a per... | true |
a945b4b261dd3673ead6c72bc929493217c80e9d | Rust | tclfs/rust | /src/test/ui/underscore-lifetime/dyn-trait-underscore.rs | UTF-8 | 1,118 | 2.8125 | 3 | [
"MIT",
"LicenseRef-scancode-other-permissive",
"Apache-2.0",
"BSD-2-Clause",
"BSD-3-Clause",
"NCSA"
] | permissive | // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | true |
9d14d59e5951876f021c428256b3f4c104c34fa9 | Rust | heliumbrain/axum | /src/extract/path/mod.rs | UTF-8 | 3,924 | 3.015625 | 3 | [
"MIT"
] | permissive | mod de;
use super::{rejection::*, FromRequest};
use crate::{extract::RequestParts, routing::UrlParams};
use async_trait::async_trait;
use serde::de::DeserializeOwned;
use std::ops::{Deref, DerefMut};
/// Extractor that will get captures from the URL and parse them using
/// [`serde`].
///
/// # Example
///
/// ```rus... | true |
41cc42e1bce4ffd04aa1689b4e6780924f738d5b | Rust | roy-ganz/toql | /crates/sql_expr_macro/src/sql_expr_macro.rs | UTF-8 | 5,667 | 2.546875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use syn::parse::{Parse, ParseStream};
use syn::punctuated::Punctuated;
use syn::{Expr, LitStr, Result, Token};
use proc_macro2::TokenStream;
use toql_sql_expr_parser::PestSqlExprParser;
use pest::Parser;
use toql_sql_expr_parser::Rule;
#[derive(Debug)]
pub struct SqlExprMacro {
pub query: LitStr,
pub argume... | true |
e0447eb58e41ec5cf6b772a09d6f42f22a6a41fd | Rust | l1lhu1hu1/rust-practice | /else/thread/src/4.rs | UTF-8 | 931 | 3.5625 | 4 | [] | no_license | use std::sync::{Arc, Mutex};
use std::thread;
fn main() {
let mut handles = Vec::new();
// Arcだけだと排他制御はできないのMutexを用いている
// Arc stands for Atomically Reference Counted
// Mutexはlockメソッドをもつ
// Arcはマルチスレッド版のrcで、所有者カウンタが0になったらメモリを解放するという仕組みになっている
let data = Arc::new(Mutex::new(vec![1; 10]));
fo... | true |
0160240cfad8f4d568a176248ef2b1732b9258b9 | Rust | automerge/automerge | /rust/automerge/src/columnar/column_range/key.rs | UTF-8 | 7,721 | 2.765625 | 3 | [
"MIT"
] | permissive | use std::{convert::Infallible, ops::Range};
use super::{DeltaRange, RleRange};
use crate::{
columnar::{
encoding::{
raw, DecodeColumnError, DeltaDecoder, DeltaEncoder, RleDecoder, RleEncoder, Sink,
},
SpliceError,
},
convert,
types::{ElemId, OpId},
};
#[derive(Clone... | true |
af8ede2617d9a07b742c73a435f0f9b74088ff5c | Rust | silverweed/ecsde | /inle/inle_physics/src/collider.rs | UTF-8 | 1,223 | 2.5625 | 3 | [] | no_license | use super::layers::Collision_Layer;
use super::phys_world::{Collider_Handle, Physics_Body_Handle};
use inle_ecs::ecs_world::Entity;
use inle_math::vector::Vec2f;
#[derive(Copy, Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum Collision_Shape {
Rect { width: f32, height: f32 },
Circle { radius: f32 },
}
im... | true |
eba966bd3532b9b151bf4ffc1bb1c523fb141447 | Rust | jendakol/rbackup-cli | /src/commands.rs | UTF-8 | 5,123 | 2.625 | 3 | [] | no_license | use std::fs::canonicalize;
use std::future::Future;
use std::path::PathBuf;
use std::time::Duration;
use err_context::AnyError;
use futures::StreamExt;
use futures_retry::{ErrorHandler, FutureRetry, RetryPolicy};
use log::{debug, info, warn};
use tokio::fs::File;
use tokio::prelude::*;
use url::Url;
use walkdir::WalkD... | true |
a19f345d9c86e3759be38ff22b56793f71cd3d27 | Rust | rapidclock/estahr | /src/strings/distance.rs | UTF-8 | 5,854 | 3.390625 | 3 | [
"MIT"
] | permissive | use std::cmp::{max, min};
fn levenshtein_distance<A: PartialOrd>(it_a: &mut dyn Iterator<Item=A>, it_b: &mut dyn Iterator<Item=A>) -> usize {
let vec_a: Vec<_> = it_a.collect();
let vec_b: Vec<_> = it_b.collect();
match (vec_a.len(), vec_b.len()) {
(0, b) => b,
(a, 0) => a,
... | true |
c54600160e5d680cd8c127a91ba9b9a5682ecbc4 | Rust | Jonesey13/aoc-2020 | /day_13/part_2/src/main.rs | UTF-8 | 1,437 | 3.28125 | 3 | [] | no_license | use std::path::Path;
use std::fs;
fn main() {
let time_and_buses_string = fs::read_to_string(Path::new("time_and_buses.txt"))
.expect("Time & buses file not found!");
let mut time_and_buses_split = time_and_buses_string.split("\n");
let time = time_and_buses_split.next().unwrap().parse::<usize>()... | true |
a420556b72ee81955d516ecad6e0d916993886ba | Rust | sia-services/foundation-rs | /oracle_derive/src/internals/ast.rs | UTF-8 | 4,306 | 3 | 3 | [
"MIT"
] | permissive | use syn;
use syn::punctuated::Punctuated;
use super::ctx::Ctxt;
use syn::token::Token;
/// A source data structure annotated with '#[derive(Query)]'
/// parsed into an internal representation.
pub struct Container<'a> {
/// The struct or enum name (without generics).
pub ident: &'a syn::Ident,
/// The con... | true |
de12ec731bd2747cafc43f60aeed1158ab976a24 | Rust | cginternals/yage | /yage-core/src/geometry/geometry.rs | UTF-8 | 4,441 | 3.609375 | 4 | [
"Apache-2.0",
"MIT"
] | permissive | use crate::{
Context, GpuObject, Drawable, ResourceManager,
Primitive, Buffer, VertexAttribute, Material
};
///
/// Represents a renderable geometry
///
/// A geometry represents polygonal geometry that can be rendered
/// onto the screen. It consists of the primitives that make up
/// the parts of the geometr... | true |
6f172dde844b9906a86f99d250cc3824204f2ef3 | Rust | barlog-m/yew-bootsrap-modal-example | /src/app.rs | UTF-8 | 1,395 | 2.578125 | 3 | [] | no_license | use yew::prelude::*;
use super::modal::ModalComponent;
pub struct App {
link: ComponentLink<Self>,
is_modal_shown: bool,
}
pub enum AppMessage {
ModalShow,
ModalHide,
}
impl Component for App {
type Message = AppMessage;
type Properties = ();
fn create(_props: Self::Properties, link: Co... | true |
dbcf0668b28c913be4b665a9d7154e49dad7afe0 | Rust | manarimo/ICFPC2021 | /kenkoooo/no-wasm/src/bin/globalist-optimize.rs | UTF-8 | 3,626 | 2.609375 | 3 | [
"MIT"
] | permissive | use anyhow::Result;
use brute_force::PathRefExt;
use manarimo_lib::geometry::{
count_contained_edges, count_contained_points, count_valid_edges, dislike, Point,
};
use manarimo_lib::types::{Bonus, Pose, Problem};
use rand::prelude::*;
use std::collections::BTreeSet;
use std::path::Path;
fn main() -> Result<()> {
... | true |
d4b956bc08523ebeec0584095cf03670bb1daf26 | Rust | eldruin/tm4c-hal | /tm4c123x-hal/src/timer.rs | UTF-8 | 5,235 | 2.78125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"MIT"
] | permissive | //! Timers
use crate::{
hal::timer::{CountDown, Periodic},
sysctl::{self, Clocks},
};
#[rustfmt::skip]
use tm4c123x::{
TIMER0, TIMER1, TIMER2, TIMER3, TIMER4, TIMER5,
WTIMER0, WTIMER1, WTIMER2, WTIMER3, WTIMER4, WTIMER5,
};
use tm4c_hal::time::Hertz;
use void::Void;
/// Hardware timers
pub struct Tim... | true |
42a0a160159ca0a8927627be96eea4fc8bc220b7 | Rust | meow-chip/MeowSBI | /src/platform/qemu.rs | UTF-8 | 2,944 | 2.640625 | 3 | [] | no_license | use super::PlatformOps;
use crate::utils::clint::CLINT;
use crate::utils::uart::UART16550;
pub struct QEMU {
hartid: usize,
serial: UART16550,
clint: CLINT,
}
impl PlatformOps for QEMU {
fn new(hartid: usize, fdt: fdt::FDT) -> Self {
use core::convert::TryInto;
let mut clint_addr = Non... | true |
abf8186e9f3a8bdf262bf3d7469849fb51035199 | Rust | nambrosini/adventofcode | /2022/src/day13.rs | UTF-8 | 3,289 | 3.265625 | 3 | [] | no_license | use itertools::Itertools;
use nom::branch::alt;
use nom::bytes::complete::tag;
use nom::character::complete::i32;
use nom::combinator::map;
use nom::multi::separated_list0;
use nom::sequence::delimited;
use nom::IResult;
use std::cmp::Ordering;
#[aoc_generator(day13)]
pub fn generator(input: &str) -> Vec<Packet> {
... | true |
9cf616f59d0dbe777abdcbda7dbbf6152f6ccd3c | Rust | agemor/sage | /src/tensor/ops/stats.rs | UTF-8 | 2,486 | 2.96875 | 3 | [
"Apache-2.0"
] | permissive | use crate::tensor::backend::{BinaryIndexOperation, BinaryOperation};
use crate::tensor::shape::{ToIndex, ToIndices};
use crate::tensor::Tensor;
impl Tensor {
pub fn sum<Is>(&self, axes: Is, retain_axis: bool) -> Tensor
where
Is: ToIndices,
{
self.reduce(BinaryOperation::Add, axes, retain_ax... | true |
61df68388397092a4c5c65488e9b14e51fdacb02 | Rust | j4ckzh0u/usbip | /src/device.rs | UTF-8 | 17,513 | 2.671875 | 3 | [
"MIT"
] | permissive | use super::*;
/// Represent a USB device
#[derive(Clone, Default)]
pub struct UsbDevice {
pub path: String,
pub bus_id: String,
pub bus_num: u32,
pub dev_num: u32,
pub speed: u32,
pub vendor_id: u16,
pub product_id: u16,
pub device_bcd: u16,
pub device_class: u8,
pub device_subc... | true |
36c8321ebc45e5e73c8cf6767064d9978ead5605 | Rust | yorkart/collector-rs | /src/utils/file.rs | UTF-8 | 3,968 | 2.859375 | 3 | [
"Apache-2.0"
] | permissive |
use std::io;
use std::fmt;
use std::fmt::Formatter;
use std::error;
use std::fs::File;
use std::io::Read;
use std::io::Seek;
use bytes::BytesMut;
use bytes::BufMut;
#[cfg(not(target_os = "windows"))]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct StatOS {
pub inode: u64,
pub device: u6... | true |
f2d858d39181675d7ce2a0a5aa4ded28a97789fc | Rust | Bastczuak/PiXr | /examples/network/main.rs | UTF-8 | 1,532 | 2.953125 | 3 | [
"MIT"
] | permissive | extern crate PiXr;
use PiXr::{run, Pix, PixGameLoop, PixMsgPack};
struct Game {
t: f32,
text: String,
chat: Vec<String>,
}
impl PixGameLoop for Game {
fn on_init(&mut self, pix: &mut Pix) -> Result<(), String> {
pix.open_socket(4055, true)?;
pix.screen(256, 240, "PiX Chat")
}
fn on_update(&mut se... | true |
a0c7acdccac7be9e803895f263880c48d826024c | Rust | dimforge/rapier | /examples3d/one_way_platforms3.rs | UTF-8 | 4,661 | 2.5625 | 3 | [
"Apache-2.0"
] | permissive | use rapier3d::prelude::*;
use rapier_testbed3d::Testbed;
struct OneWayPlatformHook {
platform1: ColliderHandle,
platform2: ColliderHandle,
}
impl PhysicsHooks for OneWayPlatformHook {
fn modify_solver_contacts(&self, context: &mut ContactModificationContext) {
// The allowed normal for the first p... | true |
18fe737d92473a4212e042a965cf43fb39048c66 | Rust | wolfgang/tetrs | /src/game/brick_factory.rs | UTF-8 | 4,375 | 2.625 | 3 | [] | no_license | use crate::game::brick_provider::BrickDef;
pub const I_BLOCK: u8 = 1;
pub const O_BLOCK: u8 = 2;
pub const T_BLOCK: u8 = 3;
pub const J_BLOCK: u8 = 4;
pub const S_BLOCK: u8 = 5;
pub const Z_BLOCK: u8 = 6;
pub const L_BLOCK: u8 = 7;
pub fn i_block() -> BrickDef {
BrickDef {
brick_type: I_BLOCK,
bri... | true |
a445bebd9a5159f697f197bafbf1543924bc77b2 | Rust | jiangzhe/mybin | /mybin-core/src/cmd/field_list.rs | UTF-8 | 1,988 | 2.71875 | 3 | [] | no_license | use crate::col::ColumnDefinition;
use crate::flag::CapabilityFlags;
use crate::packet::{EofPacket, ErrPacket};
use crate::Command;
use bytes::{Buf, Bytes, BytesMut};
use bytes_parser::error::{Error, Needed, Result};
use bytes_parser::{WriteBytesExt, WriteToBytes};
/// get column definitions of a table
///
/// deprecat... | true |
37e6cdd5014167b8b7febbe4b5f2698f813d3598 | Rust | khernyo/quirc-rs | /src/math.rs | UTF-8 | 3,602 | 2.984375 | 3 | [
"ISC"
] | permissive | use std::{f32, f64};
pub trait RoundToNearestFavorEven {
// TODO Remove when Rust grows this rounding mode.
fn round_to_nearest_favor_even(self) -> Self;
}
macro_rules! impl_round_to_nearest_favor_even {
($t:tt) => {
impl RoundToNearestFavorEven for $t {
fn round_to_nearest_favor_even(... | true |
0545f46743a2e1327ab40fa4d43e7a2ea70d1ea3 | Rust | JamesMenetrey/rust-web-app | /src/domain/products/commands/set_product_title.rs | UTF-8 | 1,516 | 3.03125 | 3 | [] | no_license | /*! Contains the `SetProductTitleCommand`. */
use auto_impl::auto_impl;
use crate::domain::{
error::{
err_msg,
Error,
},
products::{
ProductId,
ProductStore,
},
Resolver,
};
pub type Result = ::std::result::Result<(), Error>;
/** Input for a `SetProductTitleComman... | true |
6cd866f26f0e18cdd21805d90c06d1726e48e323 | Rust | scottlamb/http-serve | /benches/file.rs | UTF-8 | 4,215 | 2.578125 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | // Copyright (c) 2016-2018 The http-serve developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE.txt or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT.txt or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or dist... | true |
454bcdefe462285936ebdd316f8e980d94713a82 | Rust | ogoestcc/recommender | /src/models/recommender.rs | UTF-8 | 5,475 | 2.703125 | 3 | [] | no_license | use array_tool::vec::Intersect;
use std::{cmp::Ordering, collections::HashMap};
use super::{alert::Alert, user::User};
#[derive(Debug, Clone)]
pub struct Recommender {
pub users: HashMap<u32, User>,
pub alerts: HashMap<String, Alert>,
// alerts: &'b mut HashMap<&'b str, &'b Alert>,
// ratings: &'b Vec... | true |
7c8dc9176cba3cd323e76a50a5c0e5a425d52e83 | Rust | audunhalland/dyn-symbol | /src/lib.rs | UTF-8 | 18,751 | 3.78125 | 4 | [] | no_license | //!
//! Dynamic, plugin-based [Symbol](https://en.wikipedia.org/wiki/Symbol_(programming)) abstraction.
//!
//! A [Symbol] can be used as an _identifier_ in place of the more primitive workhorse [String].
//! There could be multiple reasons to do so:
//!
//! 1. Mixing of different domains in the same runtime code
//! 2... | true |
3fc89be3621243b93081c49ec6eb8ddfbde91afd | Rust | xbsura/arrow-datafusion | /ballista/rust/client/src/lib.rs | UTF-8 | 4,659 | 2.578125 | 3 | [
"Apache-2.0",
"JSON",
"NTP",
"CC-BY-4.0",
"LicenseRef-scancode-protobuf",
"BSD-3-Clause",
"CC-BY-3.0",
"OpenSSL",
"Zlib",
"CC0-1.0",
"LLVM-exception",
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"ZPL-2.1",
"BSL-1.0",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause"
] | permissive | // Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may... | true |
9e9ef78d7c71e53cc600f59d387ab91a54a1c9b2 | Rust | ytitov/json_to_csv_tables | /src/parts.rs | UTF-8 | 9,763 | 2.9375 | 3 | [] | no_license | use clap::Clap;
use serde_json::Value;
use std::collections::{BTreeMap, HashMap};
use std::fmt;
use std::fs::File;
use std::io::prelude::*;
use std::io::BufReader;
pub mod err;
pub mod table;
pub use table::Table;
#[derive(Clap, Debug, Clone)]
#[clap(version = "0.1.0", author = "Yuri Titov <ytitov@gmail.com>")]
pub... | true |
e17a2e609b57088d4ee59d095283a11828ab13c2 | Rust | brandon515/Chess-Bot | /src/chess.rs | UTF-8 | 14,523 | 2.890625 | 3 | [] | no_license | use rustc_serialize::json;
use std::vec::Vec;
use std::collections::HashMap;
use std::fs::{
File,
OpenOptions,
};
use std::io;
use std::io::{
Write,
Read,
};
#[derive(RustcDecodable,RustcEncodable)]
struct ChessMap {
pub moves: Vec<String>,
board: HashMap<u64, String>,
pub disca... | true |
b087f00078a7ef846d11d165003601a6a18c5c8e | Rust | LaurentMazare/tch-rs | /src/tensor/iter.rs | UTF-8 | 1,495 | 2.921875 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use super::Tensor;
use crate::TchError;
pub struct Iter<T> {
index: i64,
len: i64,
content: Tensor,
phantom: std::marker::PhantomData<T>,
}
impl Tensor {
pub fn iter<T>(&self) -> Result<Iter<T>, TchError> {
Ok(Iter {
index: 0,
len: self.size1()?,
content... | true |
f45df52385f9b9352a1d90b0f3a7ae9d5a49428c | Rust | nikomatsakis/optopodi | /src/metrics.rs | UTF-8 | 3,973 | 2.921875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use anyhow::Error;
use async_trait::async_trait;
use fehler::throws;
use serde::Deserialize;
use tokio::sync::mpsc::{Receiver, Sender};
use crate::util;
mod export_to_sheets;
mod list_repos;
mod print;
#[async_trait]
pub trait Producer {
fn column_names(&self) -> Vec<String>;
async fn producer_task(self, tx:... | true |
c42a650fca50f63c6e685f50bb94dc19fe1caadf | Rust | adisney3000/Rust-SCSI | /src/bin/parse_raw_sense.rs | UTF-8 | 624 | 2.734375 | 3 | [
"MIT"
] | permissive | //#![warn(missing_docs)]
use scsi::Sense;
use std::io;
use std::io::BufRead;
fn main() {
let mut buffer: Vec <u8> = Vec::new();
let stdin = io::stdin();
let stdin_handle = stdin.lock();
let mut iter = stdin_handle.lines();
while let Some(Ok(line)) = iter.next() {
for token in line.split_whitespace() {
... | true |
c5a5518929cf81f6a8a25d43f603be981345e530 | Rust | cmeissl/wayland-rs | /wayland-commons/src/map.rs | UTF-8 | 8,595 | 3.046875 | 3 | [
"MIT"
] | permissive | //! Wayland objects map
use crate::{Interface, MessageGroup, NoMessage};
use std::cmp::Ordering;
/// Limit separating server-created from client-created objects IDs in the namespace
pub const SERVER_ID_LIMIT: u32 = 0xFF00_0000;
/// A trait representing the metadata a wayland implementation
/// may attach to an objec... | true |
74119e22087d27e1d04f671f89f8a49257ef26e9 | Rust | philippeitis/isbn-rs | /src/lib.rs | UTF-8 | 23,728 | 3.15625 | 3 | [
"MIT"
] | permissive | //! A library for handling [International Standard Book Number], or ISBNs.
//!
//! # Examples
//!
//! ```
//! use isbn2::{Isbn10, Isbn13};
//!
//! let isbn_10 = Isbn10::new([8, 9, 6, 6, 2, 6, 1, 2, 6, 4]).unwrap();
//! assert_eq!(isbn_10.hyphenate().unwrap().as_str(), "89-6626-126-4");
//! assert_eq!(isbn_10.registrati... | true |
3f0f9f3b26eabd4683365588c0a2708d68a6eb10 | Rust | Mimikkk/leetcode-rust | /src/tests/utils.rs | UTF-8 | 220 | 2.765625 | 3 | [] | no_license | #[test]
fn sorted_should_return_new_sorted_vec() {
use crate::utils::Sorted;
let original_vector = vec![4, 3, 2, 1];
assert_eq!(original_vector.sorted(), vec![1, 2, 3, 4], "Should return new sorted vec");
}
| true |
edcc54f604c7bb2d176c3fe961c1cc29e0ef69c0 | Rust | TheooAndre/rust-beginner-projects | /src/pythagorean_triples_checker.rs | UTF-8 | 3,008 | 3.796875 | 4 | [] | no_license | use std::io::{self, Write};
/// Checks for a pythagorean triple
/// # Examples
/// ```
/// # use rust_beginner_projects::pythagorean_triples_checker::check;
/// assert_eq!(check(Some((3, 4, 5))), true);
/// assert_eq!(check(Some((1, 2, 3))), false);
/// ```
/// # Parameters
/// `nums` - An optional tuple containing th... | true |
06b2c02e7f5eb88111d1c39b973378587c997ec3 | Rust | dogewanwan/rust-simple-benchmarker | /src/observation_logger.rs | UTF-8 | 2,120 | 3.109375 | 3 | [
"MIT"
] | permissive | use chrono::{DateTime, Utc};
use std::fmt::{Formatter, Display};
impl PreciseTime for DateTime<Utc> {
fn now() -> Self {
Utc::now()
}
fn is_before(&self, time: &DateTime<Utc>) -> bool {
self <= &time
}
}
pub trait PreciseTime {
fn now() -> Self;
fn is_before(&self, time: &Date... | true |
79c53d5dd724dea357e56e6bf52daf1a3a676301 | Rust | dellams/devcamp7-leap | /dna/course/zomes/courses/code/src/section/entry.rs | UTF-8 | 2,023 | 2.859375 | 3 | [] | no_license | use hdk::{
entry_definition::ValidatingEntryType,
holochain_core_types::{dna::entry_types::Sharing, validation::EntryValidationData},
holochain_json_api::{error::JsonError, json::JsonString},
holochain_persistence_api::cas::content::Address,
};
use holochain_entry_utils::HolochainEntry;
#[derive(Serial... | true |
cf03d7342df3ac3cced29c7a806b264a638ef686 | Rust | evq/atsaml11xxx | /src/adc/seqstatus/mod.rs | UTF-8 | 1,641 | 2.875 | 3 | [] | no_license | #[doc = r" Value read from the register"]
pub struct R {
bits: u8,
}
impl super::SEQSTATUS {
#[doc = r" Reads the contents of the register"]
#[inline]
pub fn read(&self) -> R {
R {
bits: self.register.get(),
}
}
}
#[doc = r" Value of the field"]
pub struct SEQSTATER {
... | true |
48c3bef54cfe3e76420f28ed6e95a42a3802d83f | Rust | dmit/tachibana | /src/vec.rs | UTF-8 | 2,700 | 3.59375 | 4 | [
"CC0-1.0",
"LicenseRef-scancode-public-domain"
] | permissive | use std::ops::{Add, Div, Mul, Neg, Sub};
#[derive(Clone, Copy, Debug)]
pub struct Vec3 {
pub x: f32,
pub y: f32,
pub z: f32,
}
impl Vec3 {
pub const ZERO: Vec3 = Vec3 {
x: 0.,
y: 0.,
z: 0.,
};
pub const ONE: Vec3 = Vec3 {
x: 1.,
y: 1.,
z: 1.,
... | true |
85fbf5a7adb82600e8bdec97c2c9ea055c8e7a97 | Rust | wlindley/advent2018 | /sixth/one/src/main.rs | UTF-8 | 7,346 | 3.171875 | 3 | [
"MIT"
] | permissive | use std::cmp;
use std::collections::HashMap;
use std::fs::File;
use std::io::prelude::*;
use std::io::BufReader;
fn main() {
let points = load_points();
let areas = calculate_areas(points);
let mut point = Point::new(0, 0);
let mut largest = std::i32::MIN;
for (p, area) in areas {
if area >... | true |
4568cd74d37017cb2a1e09a40c0d6dc7a5b089f1 | Rust | winksaville/fuchsia | /third_party/rust_crates/vendor/tokio/tests/enumerate.rs | UTF-8 | 508 | 2.5625 | 3 | [
"BSD-3-Clause",
"MIT"
] | permissive | extern crate futures;
extern crate tokio;
extern crate tokio_executor;
extern crate tokio_timer;
use futures::sync::mpsc;
use tokio::util::StreamExt;
#[test]
fn enumerate() {
use futures::*;
let (mut tx, rx) = mpsc::channel(1);
std::thread::spawn(|| {
for i in 0..5 {
tx = tx.send(i *... | true |
84975ba85886a35f09d0c422c8355396cba5d0a6 | Rust | Miniwoffer/gitfuse-rs | /src/filesystem/filesystem_entry.rs | UTF-8 | 8,678 | 3.078125 | 3 | [
"MIT"
] | permissive | use filesystem::error_codes;
use git2::{Oid, Repository, Tree, TreeEntry};
use std::os::raw::c_int;
use std::str::Split;
use fuse::FileType;
#[derive(PartialEq)]
#[derive(Debug)]
pub struct FilesystemEntry {
pub name: String,
pub file_type: FileType,
pub oid: Option<Oid>,
pub ino: usize,
pub childr... | true |
2eff298ba11c320c6ac2361f09f6f52e8e2d387a | Rust | wezm/dslite2svd | /crates/tm4c123x/src/uart0/im/mod.rs | UTF-8 | 15,079 | 2.78125 | 3 | [
"0BSD",
"BSD-3-Clause"
] | permissive | #[doc = r" Value read from the register"]
pub struct R {
bits: u32,
}
#[doc = r" Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::IM {
#[doc = r" Modifies the contents of the register"]
#[inline]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w mut W)... | true |
ba8a793c44d40ff7fd1962b0b02116f693ae3e1b | Rust | triptych/Oxygengine | /oxygengine-ignite/src/main.rs | UTF-8 | 11,437 | 2.6875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use cargo_metadata::MetadataCommand;
use clap::{App, Arg, SubCommand};
use serde::Deserialize;
use std::{
collections::HashMap,
env::{current_dir, current_exe, vars},
fs::{copy, create_dir_all, read_dir, read_to_string, write},
io::{Error, ErrorKind, Result},
path::Path,
process::{Command, Stdio... | true |
d16a9af1c925e15e0f1a81e7a2053ba1633eee57 | Rust | dimforge/nalgebra | /src/linalg/balancing.rs | UTF-8 | 2,745 | 3.078125 | 3 | [
"Apache-2.0"
] | permissive | //! Functions for balancing a matrix.
use simba::scalar::RealField;
use std::ops::{DivAssign, MulAssign};
use crate::allocator::Allocator;
use crate::base::dimension::Dim;
use crate::base::{Const, DefaultAllocator, OMatrix, OVector};
/// Applies in-place a modified Parlett and Reinsch matrix balancing with 2-norm to... | true |
06fc77f6b098a290c738e2a56c90869de8338982 | Rust | emkay/insertion_sort | /src/lib.rs | UTF-8 | 488 | 3.328125 | 3 | [] | no_license | mod insertion_sort;
#[cfg(test)]
mod test {
#[test]
fn it_works() {
use super::insertion_sort;
let vec = vec![3, 1, 2, 8, 4, 7, 5];
let sorted = insertion_sort::sort(vec);
assert_eq!(sorted.len(), 7);
assert_eq!(sorted[0], 1);
assert_eq!(sorted[1], 2);
as... | true |
0b8398bd32e3a121be71d74707ba65e6ab921fc7 | Rust | iosmanthus/regular-language-utils | /src/re.rs | UTF-8 | 6,779 | 2.875 | 3 | [] | no_license | use crate::ast::Ast;
use crate::nfa::{Nfa, Transition};
use maplit::{hashmap, hashset};
use std::rc::Rc;
use ReOperator::*;
use ReToken::*;
#[derive(Clone, Copy, PartialEq, Debug)]
pub enum ReOperator {
Concat,
Alter,
Star,
Left,
Right,
}
impl ReOperator {
pub fn priority(self) -> i32 {
... | true |
48599e09f880e21259945e6f7a2b48599ac35002 | Rust | sepiggy/rust-basic-datacamp | /ch03/demo01variables/src/main.rs | UTF-8 | 1,139 | 3.640625 | 4 | [] | no_license | const MAX_POINTS: i32 = 100_000;
//region mut
// fn main() {
// let mut x = 5;
// println!("The value of x is {}", x);
// println!("The max points is {}", MAX_POINTS);
// x = 100;
// }
//endregion
//region shadowing
// fn main() {
// let x = 5;
// let x = x + 1;
// let x = x * 2;
// pr... | true |
783bd379299c84b142c9b3df973b79f4e65359d2 | Rust | samwho/rust-lisp-with-traits | /examples/map_reduce.rs | UTF-8 | 243 | 2.859375 | 3 | [] | no_license | use lisp::prelude::*;
fn add_one(a: i32) -> i32 {
a + 1
}
fn main() {
let v = vec![1, 2, 3];
let res = eval((map, add_one, v));
// let res = eval((reduce, 0, add, (map, add_one, vec![1, 2, 3])));
println!("{:?}", res);
}
| true |
b631dd0a70e28e731bf5f9a3effeeba8665516c3 | Rust | humantree/rusty-boy | /src/registers.rs | UTF-8 | 1,942 | 3.359375 | 3 | [
"MIT"
] | permissive | use self::RegisterPair::*;
use std::ops::{Index, IndexMut};
#[derive(Clone, Copy, Debug)]
pub enum Register { A, B, C, D, E, H, L }
#[derive(Clone, Copy, Debug)]
pub enum RegisterPair { BC, DE, HL }
#[derive(Debug)]
pub struct Registers {
pub a: u8,
pub b: u8,
pub c: u8,
pub d: u8,
pub e: u8,
... | true |
790589bd8ce2519715243f81fe218e8a242e4cac | Rust | microsoft/synthetic-data-showcase | /packages/core/src/utils/reporting/processing_stopped_error.rs | UTF-8 | 891 | 2.71875 | 3 | [
"MIT",
"LicenseRef-scancode-generic-cla"
] | permissive | use std::fmt::{Debug, Display, Formatter, Result as FmtResult};
#[cfg(feature = "pyo3")]
use pyo3::exceptions::PyIOError;
#[cfg(feature = "pyo3")]
use pyo3::prelude::*;
/// Indicates that a processing step that reports progress
/// has been stopped
#[derive(Default)]
pub struct ProcessingStoppedError;
impl Display ... | true |
13e037782860e94b96b534dde49917678208954d | Rust | germangb/lua-rs | /src/error.rs | UTF-8 | 1,439 | 3 | 3 | [
"MIT"
] | permissive | use ffi;
use std::error::Error as StdError;
use std::{fmt, io, io::ErrorKind};
#[derive(Debug, Clone, Eq, PartialEq)]
pub enum Error {
/// Error during UTF-8 encoding/decoding
Utf8,
/// Error during IO
Io(io::ErrorKind),
/// Lua program execution error
Runtime,
/// Malformed lua syntax
... | true |
2fd087746c69b6890403a4f2904340a135bca4aa | Rust | zerosign/envit | /src/de.rs | UTF-8 | 5,110 | 3.4375 | 3 | [
"MIT"
] | permissive | use std::{
cmp::Ordering,
collections::{BinaryHeap, HashMap, HashSet},
io::{BufRead, Cursor},
iter::FromIterator,
};
#[derive(Debug, Clone)]
pub(crate) struct EnvPair {
fields: Vec<String>,
value: String,
}
impl EnvPair {
#[inline]
pub fn from_str<'a>(line: &'a str, comment: char, kv_s... | true |
1ef9a92601374134789f461e7cf8e898e170d1a9 | Rust | delventhalz/pirate-talk | /processor-rust/src/handler.rs | UTF-8 | 1,998 | 2.703125 | 3 | [
"CC-BY-4.0",
"Apache-2.0"
] | permissive | use std::iter::repeat;
use sawtooth_sdk::processor::handler::ApplyError;
use sawtooth_sdk::processor::handler::TransactionContext;
use sawtooth_sdk::processor::handler::TransactionHandler;
use sawtooth_sdk::messages::processor::TpProcessRequest;
fn piratify(msg: String) -> String {
let rs = repeat("r").take(msg.l... | true |
556feee412cb401cb9ad76ebc1580f0956ddb2d3 | Rust | iCodeIN/slabmap | /src/lib.rs | UTF-8 | 21,550 | 3.953125 | 4 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | /*! This crate provides the type [`SlabMap`].
[`SlabMap`] is HashMap-like collection that automatically determines the key.
# Examples
```
use slabmap::SlabMap;
let mut s = SlabMap::new();
let key_a = s.insert("aaa");
let key_b = s.insert("bbb");
assert_eq!(s[key_a], "aaa");
assert_eq!(s[key_b], "bbb");
for (key, ... | true |
c0680c9ab3f248a3bd0ac1a643a6085d3a8b02a0 | Rust | jonhoo/bystander | /src/help_queue.rs | UTF-8 | 7,656 | 2.890625 | 3 | [] | no_license | use crate::OperationRecordBox;
use std::sync::atomic::{AtomicPtr, Ordering};
struct Node<T> {
value: Option<T>,
next: AtomicPtr<Self>,
enq_id: Option<usize>,
}
impl<T> Node<T> {
fn new(value: T, enq_id: usize) -> *mut Self {
Box::into_raw(Box::new(Self {
value: Some(value),
... | true |
4ba8978b21eeb26fe6d4fdf3ef94a566b811a3c6 | Rust | nsclass/raft-rs | /datadriven/src/lib.rs | UTF-8 | 2,534 | 2.78125 | 3 | [
"Apache-2.0"
] | permissive | /*!
# datadriven
**datadriven** is a tool for testing. Ported from [cockroachdb/datadriven](https://github.com/cockroachdb/datadriven)
To execute data-driven tests, pass the path of the test file as well as a
function which can interpret and execute whatever commands are present in
the test file. The framework invokes... | true |
5543f83a4fb62c1eb82aacbea9bc8202ec3e483a | Rust | TheCowKingmoo/Practice_Problems | /Rust/phone_combo/src/main.rs | UTF-8 | 1,495 | 3.71875 | 4 | [] | no_license | fn main() {
println!("Hello, world!");
}
fn letter_combinations(digits: String) -> Vec<String> {
let chars: Vec<char> = s.chars().collect();
let mut string_array: Vec<String> = Vec::new();
for i in 0..chars.len() {
let current_char: char = chars[i];
letter_vec: Vec<char> = digit_char_... | true |
357086db9a089b59d58c94ac692d543963c2c733 | Rust | charlescerisier/tempest | /tempest/src/service/cli.rs | UTF-8 | 4,682 | 2.8125 | 3 | [
"MIT"
] | permissive | use crate::service::config::{get_topology_config, TopologyConfig};
use structopt::StructOpt;
/// PackageOpt provides an interface for
/// parsing Topology Package command line arguments
#[derive(Debug, Clone, StructOpt)]
#[structopt(name = "Tempest Package", about = "Topology cli options")]
pub(crate) struct PackageOp... | true |
e157a0aa626655ff7f0647bf24ad233629124dfe | Rust | frankegoesdown/LeetCode-in-Go | /Algorithms/0210.course-schedule-ii/course-schedule-ii.go | UTF-8 | 1,108 | 3.078125 | 3 | [
"MIT"
] | permissive | package problem0210
func findOrder(numCourses int, prerequisites [][]int) []int {
n, p := build(numCourses, prerequisites)
return search(n, p)
}
func build(num int, requires [][]int) (next [][]int, pre []int) {
// next[i][j] : i -> next[i]... ,i 是 next[i] 的先修课
next = make([][]int, num)
// pres[i] : i 的先修课程的**个数*... | true |
dd9cb0278706bb4bc94a70007cec6942888ada3e | Rust | joserbl/llama | /libllama/src/cpu/instructions_arm/program_status.rs | UTF-8 | 2,529 | 2.625 | 3 | [
"BSD-3-Clause"
] | permissive | use cpu;
use cpu::Cpu;
use cpu::decoder_arm as arm;
pub fn mrs(cpu: &mut Cpu, data: arm::mrs::InstrDesc) -> cpu::InstrStatus {
if !cpu::cond_passed(bf!(data.cond), &cpu.cpsr) {
return cpu::InstrStatus::InBlock;
}
let rd = bf!(data.rd);
let r_bit = bf!(data.r_bit);
if r_bit == 1 {
... | true |
802e764425de24e3ef9c40fe8159bade01027dd6 | Rust | IThawk/rust-project | /rust-master/src/test/run-pass/intrinsics/intrinsic-move-val-cleanups.rs | UTF-8 | 6,986 | 2.953125 | 3 | [
"MIT",
"LicenseRef-scancode-other-permissive",
"Apache-2.0",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | // run-pass
#![allow(unused_unsafe)]
#![allow(unreachable_code)]
// ignore-emscripten no threads support
#![allow(stable_features)]
// This test is checking that the move_val_init intrinsic is
// respecting cleanups for both of its argument expressions.
//
// In other words, if either DEST or SOURCE in
//
// `intrin... | true |
1f2b02b5630f40dd1e06e3305bec1d2bbba21c94 | Rust | kannanvijayan-zz/binjs-ref | /crates/binjs_io/src/bytes/varnum.rs | UTF-8 | 2,282 | 3.296875 | 3 | [
"MIT"
] | permissive | use std;
use std::io::{Read, Write};
pub trait WriteVarNum {
fn write_varnum(&mut self, num: u32) -> Result<usize, std::io::Error>;
}
pub trait ReadVarNum {
fn read_varnum_2(&mut self) -> Result<u32, std::io::Error>;
fn read_varnum(&mut self, num: &mut u32) -> Result<usize, std::io::Error>;
}
impl<T> Wri... | true |
f8ea646004a8eda14e352f0a51f2e9f1a7bc4a32 | Rust | Cannonbait/RustRaytracer | /src/main.rs | UTF-8 | 2,806 | 3.109375 | 3 | [] | no_license | use std::fs::File;
use std::io::prelude::*;
mod point;
mod shape;
use point::*;
use shape::*;
const WIDTH: usize = 100;
const HEIGHT: usize = 100;
const FOV: usize = 90;
const FILENAME: &str = "render";
pub type Number = u32;
pub type Area = Vec<Vec<Number>>;
fn calculate_fov() -> f32 {
std::cmp::max(WIDTH, HEI... | true |
94e09cfe8103f30d8979c3235e70e166a5469461 | Rust | HerringtonDarkholme/leetcode | /src/1320_minimum_distance.rs | UTF-8 | 1,919 | 3.515625 | 4 | [] | no_license | /*
So this problem is to give two subsequences that has minimum target value.
A brute force solution has exponential complexity 2**n.
But we know we are to assign a sequence of elements to 2 bins so that the target value is minimized. This looks like a dynamic programming.
If we know some min distances to type a word w... | true |
ee5b7f46d59342da40895f009d7a9613a24cb6eb | Rust | metasyn/aoc | /2021/src/bin/day01.rs | UTF-8 | 1,226 | 3.3125 | 3 | [
"Unlicense"
] | permissive | mod util;
use std::io::Result;
fn main() -> Result<()> {
let input: Vec<i32> = util::load_file_split("input/day01.txt")
.unwrap()
.iter()
.filter(|x| !x.is_empty())
.map(|x| x.parse::<i32>().unwrap())
.collect();
let sample = vec![199, 200, 208, 210, 200, 207, 240, 269... | true |
e52daaba7d804a549315c55759f47b45aed30a3c | Rust | z2oh/lase | /src/components/laser.rs | UTF-8 | 592 | 2.953125 | 3 | [
"Unlicense"
] | permissive | //! This component holds properties about a laser.
use amethyst::ecs::prelude::{Component, DenseVecStorage};
use crate::vector::StorageTy;
pub struct Laser {
// TODO: is this idiomatic? I should probably be using amethyst's color
// types.
/// The color of the laser. This is currently applied as a tint ov... | true |
07088a54163450e54ff6a50c50cb655097f781a7 | Rust | hassanin/azure-sdk-for-rust | /sdk/identity/src/token_credentials/managed_identity_credentials.rs | UTF-8 | 2,580 | 2.578125 | 3 | [
"LicenseRef-scancode-generic-cla",
"MIT"
] | permissive | use azure_core::errors::AzureError;
use azure_core::{TokenCredential, TokenResponse};
use chrono::{DateTime, Utc};
use oauth2::AccessToken;
use serde::Deserialize;
use url::Url;
use std::str;
const MSI_ENDPOINT_ENV_KEY: &str = "IDENTITY_ENDPOINT";
const MSI_SECRET_ENV_KEY: &str = "IDENTITY_HEADER";
const MSI_API_VERS... | true |
c59e946bd37c360cde5d74584ff7d24cd7083e52 | Rust | bytebuddha/cli-table | /src/error.rs | UTF-8 | 565 | 3.390625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"Apache-2.0"
] | permissive | use std::fmt;
/// Errors returned by functions in this crate
#[derive(Debug)]
pub enum Error {
/// Returned when there is a mismatch in number of columns in different rows of a [`Table`](struct.Table.html)
MismatchedColumns,
}
impl std::error::Error for Error {}
impl fmt::Display for Error {
fn fmt(&self... | true |
8731a9bf870580e2380923086e45f6185938039a | Rust | preston-evans98/bitcoin-warp | /shared/src/merkle_tree.rs | UTF-8 | 2,814 | 3.078125 | 3 | [
"MIT"
] | permissive | use warp_crypto::merkleize;
pub use crate::hashes::MerkleRoot;
use crate::TxID;
// #[derive(Serializable, Deserializable, Debug)]
// pub struct MerkleRoot {
// root: [u8; 32],
// }
// impl PartialEq for MerkleRoot {
// fn eq(&self, other: &Self) -> bool {
// self.root == other.root
// }
// }
// s... | true |
4273464c098f64e1e36d0c1155bb684a4902c224 | Rust | hderms/kefka | /src/database.rs | UTF-8 | 756 | 2.671875 | 3 | [] | no_license | use sled::{IVec, Result as SledResult};
use crate::NodeConfig;
#[derive(Clone)]
pub struct Database {
pub db: sled::Db,
}
impl Database {
pub fn default(node_config: NodeConfig) -> Database {
let db_path = node_config.db_path;
let config = sled::Config::default()
.path(db_path)
... | true |
d91189c5fc21f77e17d84c8d86fa281b97bfd5a5 | Rust | CPSSD/cerberus | /libcerberus/examples/end-to-end.rs | UTF-8 | 2,110 | 2.578125 | 3 | [
"MIT"
] | permissive | extern crate cerberus;
#[macro_use]
extern crate error_chain;
use cerberus::*;
struct TestMapper;
impl Map for TestMapper {
type Key = String;
type Value = String;
fn map<E>(&self, input: MapInputKV, mut emitter: E) -> Result<()>
where
E: EmitIntermediate<Self::Key, Self::Value>,
{
... | true |
314af3d908ec32973decca42825d7fb7c9e47bbb | Rust | sugyan/leetcode | /problems/0856-score-of-parentheses/lib.rs | UTF-8 | 934 | 3.609375 | 4 | [] | no_license | pub struct Solution;
impl Solution {
pub fn score_of_parentheses(s: String) -> i32 {
let s = s.as_bytes();
let (mut answer, mut depth) = (0, 0);
for (i, b) in s.iter().enumerate() {
match b {
b'(' => depth += 1,
b')' => {
depth... | true |
0ab54e803919e6e78eacd61875fd494f598ec23c | Rust | activeledger/SDK-Rust | /src/key/import.rs | UTF-8 | 6,299 | 2.84375 | 3 | [
"MIT"
] | permissive | /*
* MIT License (MIT)
* Copyright (c) 2019 Activeledger
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use,... | true |
e906bbbcb9063809e7e37ed875a9e14d043288b9 | Rust | brianjd/merit | /humanize/src/lib.rs | UTF-8 | 8,543 | 3.84375 | 4 | [
"MIT"
] | permissive | //! Formatter for human readable number or struct
//!
//! This crate exposes `humanize` fn to format numbers to human readable string
//!
//! # Quick Start
//!
//! Add `humanize` to your `Cargo.toml` as as a dependency.
//!
//! # Examples
//!
//! ```rust
//! use humanize::*;
//!
//! fn main() {
//! let opts = Humaniz... | true |
e5e36e5a0f0eced4ee5646d7091ce661485df81f | Rust | InteractiveComputerGraphics/higher_order_embedded_fem | /fenris/tests/unit_tests/reorder.rs | UTF-8 | 999 | 2.796875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | use fenris::reorder::{cuthill_mckee, reverse_cuthill_mckee};
use fenris::sparse::CsrMatrix;
use nalgebra::DMatrix;
#[test]
fn cuthill_mckee_basic_examples() {
// Basic example
{
let matrix = DMatrix::from_row_slice(4, 4, &[1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1]);
let pattern = CsrMatri... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.