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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
51457d63f7b6e78e9cdf23aaecd2516628cd37a6 | Rust | sshashank124/graphite | /src/core/interpolate.rs | UTF-8 | 1,207 | 2.8125 | 3 | [] | no_license | use std::ops::{Add, Mul};
use super::*;
#[derive(Clone, Copy, Debug)]
#[cfg_attr(feature="serde-derive", derive(Deserialize, Serialize))]
pub struct LinearScale;
#[derive(Clone, Copy, Debug)]
#[cfg_attr(feature="serde-derive", derive(Deserialize, Serialize))]
pub struct PowerScale;
#[derive(Clone, Copy, Debug)]
#[c... | true |
05d47fd77920488cd285a1801cf488ef785ac305 | Rust | Patryk27/avr-tester | /avr-tester/src/components/component_handle.rs | UTF-8 | 819 | 3.09375 | 3 | [
"MIT"
] | permissive | use super::*;
use std::{cell::RefCell, rc::Rc};
pub struct ComponentHandle {
state: Rc<RefCell<ComponentState>>,
}
impl ComponentHandle {
pub(crate) fn new(state: Rc<RefCell<ComponentState>>) -> Self {
Self { state }
}
/// Pauses component until [`Self::resume()`] is called.
pub fn pause(... | true |
c21f615422567336a30b30007ee077da0bf8095e | Rust | alexandrejanin/rust-chess | /src/game.rs | UTF-8 | 6,629 | 3.34375 | 3 | [] | no_license | use cuivre::{
graphics::sprites::{Sprite, SpriteSheet},
maths::Vector3f,
transform::Transform,
};
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum Team {
White,
Black,
}
impl Team {
fn piece(self, id: i32, x: usize, y: usize) -> Piece {
Piece {
team: self,
... | true |
05869e032c9e245d64a8b130d03e3bd7e7f5209a | Rust | 1148118271/redis_rs | /src/redis_instance.rs | UTF-8 | 1,870 | 3 | 3 | [] | no_license | use crate::tcp::Client;
use tokio::io;
use std::rc::Rc;
mod constant {
pub const CRLF: &'static str = "\r\n";
pub const LIST_SYMBOL: &'static str = "*";
pub const STR_SYMBOL: &'static str = "$";
}
pub struct RedisInstance(Client);
pub type Instance = RedisInstance;
impl RedisInstance {
pub fn ini... | true |
2ea243294bdaeeb5383be3225066a1de2fb6df86 | Rust | reiya-hanai/aoj-book-in-rust | /alds1_7_c_tree_walk/src/main.rs | UTF-8 | 4,809 | 2.8125 | 3 | [] | no_license | #![allow(unused_macros)]
// ----------------------------------------------------------------------------------------------------
// input macro by @tanakh https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
// ----------------------------------------------------------------------------------------------------
macro_ru... | true |
22696c136a405a519c00687596b519f41b58eb5d | Rust | ejfamanas/rust-training | /data_structures/enumerations/src/main.rs | UTF-8 | 562 | 3.546875 | 4 | [] | no_license | enum Color {
Red,
Green,
Blue,
RgbColor(u8, u8, u8), // WOW this is cool
CmykColor{cyan:u8, magenta: u8, yellow: u8, black:u8}
}
fn enums() {
let color:Color = Color::RgbColor(0,0,0);
match color {
Color::Red => println!("r"),
Color::Green => println!("g"),
Color::B... | true |
f075476c7d887ead494a90dd17d08195e982c2b7 | Rust | whoiscc/auto | /src/re.rs | UTF-8 | 4,420 | 2.953125 | 3 | [] | no_license | use crate::nfa::{NFAutoBlueprint, NFAutoBuilder};
use std::hash::Hash;
use std::mem;
enum RePriv<T> {
Plain(T),
ZeroOrMore(Box<RePriv<T>>),
Concat(Box<RePriv<T>>, Box<RePriv<T>>),
Either(Box<RePriv<T>>, Box<RePriv<T>>),
Wildcard,
}
pub struct Re<T>(RePriv<T>);
impl<T> RePriv<T>
where
T: Eq + ... | true |
22f249ab7c52262c72df14a42f4989083d7fe807 | Rust | growingspaghetti/my-thread-coroutine-nonblockingio-scrapbox | /rs-tokio/src/bin/main8.rs | UTF-8 | 797 | 2.96875 | 3 | [] | no_license | // https://docs.rs/tokio/0.2.11/tokio/time/fn.timeout.html
// https://docs.rs/tokio/0.2.11/src/tokio/time/delay.rs.html#81-99 impl Future for Delay
fn type_of<T>(_: T) -> &'static str {
std::any::type_name::<T>()
}
#[tokio::main]
async fn main() {
// tokio::time::delay::Delay
println!("{}", type_of(tokio:... | true |
17f0f5942ec69d2fb2f6fc2be78dbc0250a78935 | Rust | chromium/chromium | /third_party/rust/syn/v1/crate/src/parse_quote.rs | UTF-8 | 5,167 | 3.453125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"Apache-2.0",
"GPL-1.0-or-later",
"LGPL-2.0-or-later",
"BSD-3-Clause"
] | permissive | /// Quasi-quotation macro that accepts input like the [`quote!`] macro but uses
/// type inference to figure out a return type for those tokens.
///
/// [`quote!`]: https://docs.rs/quote/1.0/quote/index.html
///
/// The return type can be any syntax tree node that implements the [`Parse`]
/// trait.
///
/// [`Parse`]: ... | true |
691ec85a077529041df6295e21dc21828bade04f | Rust | danbugs/danlogs | /Rust/The Rust Programming Language - Tutorials/chapter15/rc-refcell/src/main.rs | UTF-8 | 592 | 2.875 | 3 | [] | no_license | #![allow(dead_code)]
use std::rc::{Rc, Weak};
use std::cell::RefCell;
#[derive(Debug)]
struct Node {
val: i32,
points_to: Option<Weak<RefCell<Node>>>,
}
fn main() {
let n2 = Rc::new(RefCell::new(Node { val: 2, points_to: None }));
let n1 = Rc::new(RefCell::new(Node { val: 1, points_to: Some(Rc::downg... | true |
4738cde2ba8f02ea86128c01fa4805676660c58f | Rust | r-novel/webrtc-1 | /dtls/src/cipher_suite/cipher_suite_tls_ecdhe_ecdsa_with_aes_128_gcm_sha256.rs | UTF-8 | 3,191 | 2.65625 | 3 | [
"MIT"
] | permissive | use super::*;
use crate::crypto::crypto_gcm::*;
use crate::prf::*;
//use std::sync::Arc;
//use tokio::sync::Mutex;
//use async_trait::async_trait;
#[derive(Clone)]
pub struct CipherSuiteTLSEcdheEcdsaWithAes128GcmSha256 {
gcm: Option<CryptoGcm>, //Arc<Mutex<Option<CryptoGcm>>>,
}
impl CipherSuiteTLSEcdheEcdsaWith... | true |
b7df2f370b1553c7f8e4bce73a9ec44336304a33 | Rust | ytyaru/Rust.While.20190601134837 | /src/main.rs | UTF-8 | 181 | 2.6875 | 3 | [
"CC0-1.0"
] | permissive | /*
* Rustでwhile。
* CreatedAt: 2019-06-01
*/
fn main() {
let mut count = 0;
while count < 10 {
println!("while count {}", count);
count += 1;
}
}
| true |
8c12bf42a8b7ccaa3224ce9f8b9f359395534629 | Rust | innerop/wireguard-p2p | /src/exchange/args.rs | UTF-8 | 1,765 | 2.78125 | 3 | [] | no_license | use clap::App;
use clap::Arg;
pub struct CmdExchangeArgs {
pub netns: Option<String>,
pub ifname: Option<String>,
pub verbose: bool,
pub dht_port: u16,
pub bootstrap_addrs: String,
}
impl CmdExchangeArgs {
pub fn parse() -> CmdExchangeArgs {
let m = App::new("wg-exchange")
... | true |
43e9470ad9375efd4f8ae4505149fb5b42e7e52d | Rust | ngynkvn/rustide | /src/layout.rs | UTF-8 | 6,486 | 3 | 3 | [] | no_license | use std::collections::HashMap;
use cassowary::strength::*;
use cassowary::WeightedRelation::*;
use cassowary::{Constraint, Solver, Variable};
use eframe::egui::Ui;
use eframe::egui::{self, Direction, Pos2};
#[derive(Debug)]
pub struct Rect {
x: f32,
y: f32,
w: f32,
h: f32,
}
impl Rect {
/// Retur... | true |
1c4c58c5d9d220a98db149d79890e7756eaa1b2a | Rust | dragon1061/MoonZoon | /crates/hsluv/src/lib.rs | UTF-8 | 1,644 | 2.84375 | 3 | [
"MIT"
] | permissive | use hsluv::hsluv_to_rgb;
#[cfg(feature = "hsluv_macro")]
pub use hsluv_macro::hsluv;
/// https://www.hsluv.org/
#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
pub struct HSLuv {
h: f64,
s: f64,
l: f64,
a: f64,
}
impl HSLuv {
pub fn hsl(h: impl Into<f64>, s: impl Into<f64>, l: impl Into<f64... | true |
ab616139d9c809427b57fd045d2825c054059797 | Rust | esmevane/zemeroth | /hate/src/scene/action/sleep.rs | UTF-8 | 513 | 2.84375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use time::Time;
use scene::Action;
#[derive(Debug)]
pub struct Sleep {
duration: Time,
time: Time,
}
impl Sleep {
pub fn new(duration: Time) -> Self {
Self {
duration: duration,
time: Time(0.0),
}
}
}
impl Action for Sleep {
fn duration(&self) -> Time {
... | true |
ed155998c0f4141203562e2e9a47ec60b5396618 | Rust | sbnair/dices | /game_server/src/ws.rs | UTF-8 | 4,135 | 2.65625 | 3 | [] | no_license | use std::{collections::HashMap, error::Error, io::Error as IoError, net::SocketAddr, sync::Arc};
use futures::SinkExt;
use tokio::stream::StreamExt;
use tokio::{
prelude::*,
sync::mpsc::{unbounded_channel, UnboundedSender},
sync::Mutex,
};
use async_tungstenite::tungstenite::protocol::Message;
use lazy_st... | true |
1cf5ee97c72a5b46fbd9812656cf75676c9672c6 | Rust | JRMurr/rust-back | /rback/src/game_input_frame.rs | UTF-8 | 1,016 | 3.171875 | 3 | [
"MIT"
] | permissive | use crate::{FrameSize, GameInput};
use std::fmt::Debug;
#[derive(Debug, Clone, PartialEq)]
// TODO: i think only prediction could have both of these be none
// so might be better if i make a special type for prediction
// so normal game input does not have to deal with unwraps
pub struct GameInputFrame<T: GameInput> {
... | true |
7475cf74ccb75cb1dc364a497f17f7284262b95c | Rust | liufoyang/rust_demo | /demobin/src/main.rs | UTF-8 | 3,867 | 3.53125 | 4 | [] | no_license |
use flycoin::fly_coin;
fn main() {
println!("Hello, world!");
let mut s = "aaaa";
s = "bbb";
let mut b = s.to_string();
b.push_str("cccc");
base_date_type();
own_ship();
base_own_and_reference();
mut_own_and_reference();
//fly_coin
}
fn base_date_type() {
let demo_str ... | true |
01ed008f7bd4616f9589bc431a0842041ca60034 | Rust | kitsuneninetails/rust-tutorials | /src/bin/tutorial10-threads.rs | UTF-8 | 985 | 3.109375 | 3 | [] | no_license | use std::io::{stdin, stdout, Write};
use std::sync::mpsc::{channel, Sender, Receiver};
use std::thread::spawn;
fn enter_val(chan: Sender<String>, rchan: Receiver<bool>) {
loop {
print!("In>");
stdout().flush().unwrap();
let mut instr = String::new();
stdin().read_line(&mut instr).un... | true |
7589a46cede7ede7006780a62c3ecc8234c5571a | Rust | WiebeCnossen/rust-kata | /src/kata21/tests.rs | UTF-8 | 2,605 | 3.015625 | 3 | [] | no_license | use std::fmt::Debug;
use super::list::List;
pub fn test_empty<T: PartialEq, L: List<T>>() {
let list = L::empty();
assert_eq!(0, list.collect().len());
}
pub fn test_one<T: PartialEq + Clone + Debug, L: List<T>>(v0: T) {
let b0 = v0.clone();
let list = L::empty().add(v0);
let v = list.collect();
... | true |
fc614a333a768af911aa34184c9c4a638680e1fb | Rust | marc47marc47/leetcode-cn | /132minCut/min_cut/src/lib.rs | UTF-8 | 1,618 | 2.9375 | 3 | [] | no_license | /*
* @Description: 132 min_cut
* @Version: 2.0
* @Author: kingeasternsun
* @Date: 2021-03-08 11:18:50
* @LastEditors: kingeasternsun
* @LastEditTime: 2021-03-08 11:38:36
* @FilePath: \132minCut\min_cut\src\lib.rs
*/
pub struct Solution;
impl Solution {
pub fn min_cut(s: String) -> i32 {
if s.len() ... | true |
412965b7dfaf27f17e7ad62bb4ebed5def3529ae | Rust | chrisrhayden/drift | /src/bin/driftcli.rs | UTF-8 | 1,988 | 2.84375 | 3 | [] | no_license | extern crate clap;
use std::error::Error;
use std::os::unix::net::UnixStream;
use std::io::prelude::*;
use clap::{App, Arg};
fn main() {
if let Err(err) = run() {
eprintln!("Error {}", err);
}
}
fn run() -> Result<(), Box<dyn Error>> {
let evt_str = get_args();
let mut stream = UnixStream::c... | true |
b3f3379292dfc4d15eb54f842a5e9b52f29c4910 | Rust | nguyenminhhieu12041996/casper-node | /types/src/named_key.rs | UTF-8 | 1,310 | 2.71875 | 3 | [
"Apache-2.0"
] | permissive | // TODO - remove once schemars stops causing warning.
#![allow(clippy::field_reassign_with_default)]
use alloc::{string::String, vec::Vec};
#[cfg(feature = "std")]
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use crate::bytesrepr::{self, FromBytes, ToBytes};
/// A named key.
#[derive(Clone, Eq, Pa... | true |
cfdccab12a77bad79b76a47349e9d1f709dbbf28 | Rust | vivint-smarthome/color-backtrace | /src/failure.rs | UTF-8 | 1,843 | 2.703125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! Temporary hack to allow printing of `failure::Backtrace` objects.
use crate::default_output_stream;
struct FakeBacktrace {
internal: FakeInternalBacktrace,
}
struct FakeInternalBacktrace {
backtrace: Option<MaybeResolved>,
}
struct MaybeResolved {
_resolved: std::sync::Mutex<bool>,
backtrace: st... | true |
68f0c2ca1ecb1db9aa7c6fc2f6efe336f0170532 | Rust | GuyL99/metropolis | /src/elements.rs | UTF-8 | 4,613 | 3.09375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::color::*;
use crate::canvas::*;
pub trait PageElement {
fn draw(self,canvas:&mut Canvas);
#[allow(non_snake_case)]
fn onClick(self,canvas:&Canvas)->bool;
#[allow(non_snake_case)]
fn onHover(self,canvas:&Canvas)->bool;
}
#[derive(Copy,Clone)]
pub enum Styles{
Normal,
RoundEdges,
... | true |
67be9903487f4e8ef07f9c01f63666522d30a7e6 | Rust | talebisinan/RustBook | /tuple_array.rs | UTF-8 | 422 | 3.09375 | 3 | [] | no_license | fn main() {
let tup: (i32, f64, u8) = (500, 5.4, 3);
let (x, y, z) = tup;
// println!("tup:{:#?}, x:{}, y:{}, z:{}", tup, x, y, z);
// println!("tuple => 0:{}, 1:{}, 2:{}", tup.0, tup.1, tup.2);
let foo = ["bar", "Baz"];
let a: [i32; 5] = [1, 2, 3, 4, 5];
let omg = [42; 10]; // 10 times 42!... | true |
97ba44460647e53cf9f02da5136303796f1f4dfc | Rust | AndikaRizary/juneau_wasm | /packages/juneau/src/parsing/jasm/test/assign.rs | UTF-8 | 637 | 2.546875 | 3 | [] | no_license | use juneau_core::{assert_eq_debug, assert_eq_object};
use crate::core::Id;
use crate::semantic::Variable;
use crate::semantic::jasm::JasmType::*;
use crate::semantic::jasm::render::render_jasm;
use crate::parsing::jasm::parse_jasm_statement;
use super::new_context;
#[test]
fn parse_jasm_assign() {
let source = "a... | true |
e50670deaa0806cfd09fc9395f52967ea423cbd6 | Rust | kerinin/hammer | /src/evicting_store/ghosted_list.rs | UTF-8 | 4,126 | 3.203125 | 3 | [] | no_license | use std::cmp;
use std::hash;
use std::clone;
use std::collections::{HashMap};
use evicting_store::entry::Entry;
use evicting_store::list::{List, Node, NodeLocation};
struct CachedNode<'a, T: 'a, V: 'a> {
prev: Option<&'a mut CachedNode<'a, T, V>>,
next: Option<&'a mut CachedNode<'a, T, V>>,
//entry: Entr... | true |
f56c7c73477249b4aaa22ce79bb9c5afeee301d6 | Rust | m-lima/advent-of-code-2020 | /src/bin/072/main.rs | UTF-8 | 2,186 | 3.171875 | 3 | [] | no_license | use lazy_static::lazy_static;
use regex::Regex;
use std::collections::HashMap;
const INPUT: &str = include_str!("input.txt");
struct Rules {
color_to_index: HashMap<String, usize>,
allowed_bags: Vec<Vec<(usize, usize)>>,
}
impl Rules {
fn new(known_bags: Vec<String>) -> Self {
let color_to_index:... | true |
029daaa904b4fc5ab6246878762d1714da8b95fd | Rust | sanpii/lxc-rs | /src/attach.rs | UTF-8 | 1,092 | 2.53125 | 3 | [
"MIT"
] | permissive | /** LXC attach function type. */
pub use lxc_sys::lxc_attach_exec_t as ExecFn;
/** LXC attach options for `lxc::Container::attach()`. */
pub use lxc_sys::lxc_attach_options_t as Options;
bitflags::bitflags! {
/** LXC environment policy. */
pub struct EnvPolicy: i32 {
/** Retain the environment */
... | true |
8b4705c316410288056f8fdfd72323b554b2040e | Rust | mapkts/byteseeker | /tests/seeker.rs | UTF-8 | 24,569 | 2.84375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use byteseeker::*;
use std::io::Cursor;
use std::iter;
const DEFAULT_CHUNK_SIZE: usize = 1024;
#[test]
fn test_invalid_seeking_bytes() {
let bytes: Vec<u8> = vec![0, 1, 2];
let mut cursor = Cursor::new(bytes);
let mut seeker = ByteSeeker::new(&mut cursor);
match seeker.seek(&[]) {
Ok(_) => ass... | true |
7c4054d53b0e199c333192dbd15f3d90997acae3 | Rust | aptend/leetcode-rua | /Rust/src/n1071_greatest_common_divisor_of_strings.rs | UTF-8 | 488 | 3.390625 | 3 | [] | no_license | pub fn gcd_of_strings(str1: String, str2: String) -> String {
if str1.clone() + &str2 != str2.clone() + &str1 {
"".to_owned()
} else {
let mut a = str1.len();
let mut b = str2.len();
while b > 0 {
let tmp = a % b;
a = b;
b = tmp;
}
... | true |
86bb66a0d49c78f1f49366c5f32d86528d2701ea | Rust | rust-crdt/rust-crdt | /test/vclock.rs | UTF-8 | 5,027 | 3.109375 | 3 | [
"Apache-2.0"
] | permissive | use crdts::*;
use std::cmp::Ordering;
quickcheck! {
fn prop_into_iter_produces_same_vclock(clock: VClock<u8>) -> bool {
clock == clock.clone().into_iter().collect()
}
fn prop_dots_are_commutative_in_from_iter(dots: Vec<Dot<u8>>) -> bool {
// TODO: is there a better way to check comutativi... | true |
0e848fbb77223b5c77812bf1e2a90cca50d07d0f | Rust | ajaysusarla/rfc822dtparser | /rfc822dtparser/src/parser.rs | UTF-8 | 272 | 2.828125 | 3 | [] | no_license | //
// Copyright 2017 (c) Partha Susarla
//
use std::str;
#[derive(Clone)]
pub struct InputStr<'i> {
chars: str::Chars<'i>,
}
impl<'i> InputStr<'i> {
pub fn new(inputstr: &'i str) -> Self {
let s = inputstr.trim();
InputStr { chars: s.chars() }
}
}
| true |
4ee358d0b33c785f04344520b9cefa14de90b3de | Rust | mklein994/weather-rs | /src/lib.rs | UTF-8 | 1,256 | 2.546875 | 3 | [] | no_license | #[macro_use]
extern crate clap;
extern crate darksky;
extern crate reqwest;
extern crate serde_json;
pub mod app;
use app::{Config, OutputStyle};
use darksky::models::Forecast;
use darksky::DarkskyReqwestRequester;
use reqwest::Client;
use std::error::Error;
pub fn run(matches: &clap::ArgMatches) -> Result<(), Box<E... | true |
fdfee3d26bf3eeba42f3bb169fc28b66a4ff1eb7 | Rust | Tarabyte/rust-101 | /threads_messaging/src/main.rs | UTF-8 | 1,816 | 3.421875 | 3 | [
"MIT"
] | permissive | use std::thread;
use std::time::Duration;
use std::sync::mpsc::{channel, Sender, Receiver};
fn main() {
test_threads_join(10);
test_message_passing();
test_passing_multiple_times();
test_multiple_senders();
}
fn test_multiple_senders() {
fn report(thread_number: u64, tx: &Sender<String>) {
... | true |
fd6000217bf0bdcb5efe1ab9368b90cad8cc327c | Rust | nvzqz/c-utf8-rs | /src/c_utf8_buf.rs | UTF-8 | 6,763 | 3.28125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::borrow::{Borrow, BorrowMut, ToOwned};
use std::fmt;
use std::iter::FromIterator;
use std::ops::{Deref, DerefMut};
use c_utf8::CUtf8;
use ext::Ext;
/// An owned, mutable UTF-8 encoded C string (akin to [`String`] or
/// [`PathBuf`]).
///
/// # Examples
///
/// This type retains certain behaviors that are expe... | true |
9856041c073255943883ac6d3370b6e8c914115f | Rust | alexander-smoktal/maul | /src/ast/rules.rs | UTF-8 | 13,803 | 2.859375 | 3 | [
"BSD-3-Clause",
"BSD-2-Clause"
] | permissive | #![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(clippy::all)]
#![cfg_attr(rustfmt, rustfmt_skip)]
use std::collections::VecDeque;
use crate::ast::parser;
use crate::ast::stack;
use crate::ast::expressions::*;
use crate::ast::lexer::tokens::Keyword;
const DEBUG: bool = false;
fn ignore(_: &mut stack::Stack) -> bool {
... | true |
59cfc4521ac76866ca92f6380d0ea18e4ea96daf | Rust | GabeDottl/hearttoken_solana_template | /src/instruction.rs | UTF-8 | 13,117 | 3 | 3 | [] | no_license | use crate::error::{VaultError, VaultError::InvalidInstruction};
use solana_program::program_error::ProgramError;
use solana_program::{
instruction::{AccountMeta, Instruction},
pubkey::Pubkey,
program_option::COption,
sysvar,
};
use std::convert::TryInto;
use std::mem::size_of;
pub enum VaultInstructio... | true |
9b4a42ec310dad52b4733e7d887a6fa564938c8e | Rust | ens-ds23/ensembl-client | /src/assets/browser/app/src/model/train/trainmanager.rs | UTF-8 | 10,666 | 2.828125 | 3 | [] | no_license | /* The trainmanager is responsible for creating and deleting TRAINS.
* A train represents all the leafs prepared at some scale.
*
* The COMPOSITOR updates the train manager as to the current stick,
* position, zoom, etc, for it to decide which trains are needed,
* and provides a tick for animations. This class pr... | true |
49d8a6f5797f2a9edcbbe8c8c66e8fa3e1af3d9c | Rust | elsuizo/abstreet | /ezgui/src/widgets/no_op.rs | UTF-8 | 2,260 | 2.859375 | 3 | [
"Apache-2.0"
] | permissive | use crate::layout::Widget;
use crate::svg;
use crate::{DrawBoth, EventCtx, GeomBatch, GfxCtx, RewriteColor, ScreenDims, ScreenPt, Text};
// Just draw something. A widget just so layouting works.
pub struct JustDraw {
draw: DrawBoth,
top_left: ScreenPt,
}
impl JustDraw {
pub fn wrap(draw: DrawBoth) -> Jus... | true |
6a1be17133b21233b7c7814430a2b92bb2cb55c9 | Rust | XciD/descriptor | /tests/table_test.rs | UTF-8 | 5,399 | 3.078125 | 3 | [
"Apache-2.0"
] | permissive | use descriptor::{table_describe_to_string, table_describe_with_header_to_string, Descriptor};
pub fn no_color_and_line_return(str: String) -> String {
format!(
"\n{}",
String::from_utf8(strip_ansi_escapes::strip(str).unwrap()).unwrap()
)
.to_string()
}
#[test]
fn test_table_descriptor() {
... | true |
e7e314be4f0b15cf7c99490047b766d972fa67bf | Rust | wgwoods/atsamd | /hal/src/samd11/sercom/pads.rs | UTF-8 | 1,384 | 2.59375 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::gpio::{self, IntoFunction, Port};
pub use crate::pad::PadPin;
// sercom0[0]: PA04:D PA06:C PA14:C
// sercom0[1]: PA05:D PA07:C PA15:C
// sercom0[2]: PA04:C PA06:D PA08:D PA10:C
// sercom0[3]: PA05:C PA07:D PA09:D PA11:C
pad!(Sercom0Pad0 {
Pa4(PfD),
Pa6(PfC),
Pa14(PfC),
}... | true |
630d79a762d17a7b883640249ffd36cb3c0ef94c | Rust | acruikshank/bellman-examples | /src/circle.rs | UTF-8 | 4,836 | 2.78125 | 3 | [] | no_license | #![allow(unused_imports)]
#![allow(unused_variables)]
extern crate bellman;
extern crate pairing;
extern crate rand;
// For randomness (during paramgen and proof generation)
use self::rand::{thread_rng, Rng};
// Bring in some tools for using pairing-friendly curves
use self::pairing::{
Engine,
Field,
Prim... | true |
00cad028d8aff68976fd7de322101e4ef0a2aef2 | Rust | bbvch/ESE2016-HorizontErweitern-CodeBeispiele | /folienbeispiele/folie018-lebenszeiten-von-variablen.rs | UTF-8 | 240 | 3.25 | 3 | [
"MIT"
] | permissive | use std::thread;
fn worker(val: &mut i32) {
println!("Working on {}", val);
*val = *val + 1;
}
fn main() {
let mut value = 1;
for i in 0..3 {
thread::spawn(|| {
worker(&mut value)
});
}
}
| true |
2dce390efbff4cc6455be5b590568d1707bff9b9 | Rust | isgasho/libunftp | /src/server/controlchan/commands/pasv.rs | UTF-8 | 4,272 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | //! The RFC 959 Passive (`PASV`) command
//
// This command requests the server-DTP to "listen" on a data
// port (which is not its default data port) and to wait for a
// connection rather than initiate one upon receipt of a
// transfer command. The response to this command includes the
// host and port address this ... | true |
a098f0851d4b4d4760fa40a1ecaca9cb06bd2b0d | Rust | xi-editor/xi-editor | /rust/experimental/lang/src/peg.rs | UTF-8 | 9,476 | 2.9375 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2017 The xi-editor Authors.
//
// 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 at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or ag... | true |
415225174d47070f32f8a85b4563b02687343b13 | Rust | fatoche/asciifier | /src/lib.rs | UTF-8 | 1,673 | 3.59375 | 4 | [
"Apache-2.0",
"MIT"
] | permissive | pub mod asciifier {
use std::collections::HashMap;
pub struct Asciifier {
character_map: HashMap<char, &'static str>,
}
impl Asciifier {
pub fn new() -> Asciifier {
let mut char_map = HashMap::with_capacity(20);
char_map.insert('ä', "ae");
char_map... | true |
5bf6ea34fe4c78e47d9f25b64225fe41c97554f5 | Rust | panicfrog/message-rust | /src/chat/model.rs | UTF-8 | 885 | 3 | 3 | [] | no_license | use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug)]
pub enum ChatMessageType {
// chat message
OneToOne(usize),
RoomMessage(String),
Broadcast,
// action
Join(String),
// message ack
Ack,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelC... | true |
92deca0def12deb5a73e8f88b2d05331d15811cb | Rust | arun11299/Rust-Practice | /parser.rs | UTF-8 | 723 | 3.578125 | 4 | [] | no_license | struct Context<'a>(&'a str);
/// Syntax for telling that lifetime of
/// Parser struct is longer than the lifetime
/// of context.
struct Parser<'c, 's : 'c> {
context: &'c Context<'s>,
}
impl<'c, 's> Parser<'c, 's> {
///
fn parse(&self) -> Result<(), &'s str>
{
Err(&self.context.0[1..])
}... | true |
9472488e0a05605c610c4b24c163ac274317122c | Rust | szymonwieloch/rust-dlopen | /examples/commons/mod.rs | UTF-8 | 1,366 | 2.515625 | 3 | [
"MIT"
] | permissive | extern crate dlopen;
extern crate libc;
extern crate regex;
use dlopen::utils::{PLATFORM_FILE_EXTENSION, PLATFORM_FILE_PREFIX};
use std::env;
use std::path::PathBuf;
use libc::c_int;
//Rust when building dependencies adds some weird numbers to file names
// find the file using this pattern:
//const FILE_PATTERN: &str ... | true |
eab8786b7ec70da65860e3ce667750700c02c208 | Rust | magurotuna/leetcode-rust | /src/bin/648.rs | UTF-8 | 1,045 | 3.421875 | 3 | [] | no_license | struct Solution;
impl Solution {
pub fn replace_words(dict: Vec<String>, sentence: String) -> String {
let mut ret = Vec::new();
let mut dict = dict;
dict.sort_by_key(|d| d.len());
'outer: for word in sentence.split(" ") {
for root in dict.iter() {
if wor... | true |
1c8f5a6b3086f17fb5ef4f9b001bf7efae831f22 | Rust | r4gus/sugar-ray | /src/examples/projectile.rs | UTF-8 | 1,310 | 3.015625 | 3 | [
"MIT"
] | permissive | use sugar_ray::math::{point::Point, vector::Vector};
use sugar_ray::canvas::{
*,
color::*,
};
use sugar_ray::ppm::*;
use std::io::prelude::*;
struct Projectile {
pub position: Point,
pub velocity: Vector,
}
struct Environment {
pub gravity: Vector,
pub wind: Vector,
}
fn tick<'a>(env:&Environ... | true |
b2bfe52b46d5e29a6deb4d0a863319c3651997a1 | Rust | ivan770/teloxide | /src/requests/all/set_chat_sticker_set.rs | UTF-8 | 1,795 | 3.140625 | 3 | [
"MIT"
] | permissive | use serde::Serialize;
use crate::{
net,
requests::{Request, ResponseResult},
types::{ChatId, True},
Bot,
};
/// Use this method to set a new group sticker set for a supergroup.
///
/// The bot must be an administrator in the chat for this to work and must have
/// the appropriate admin rights. Use the... | true |
8a3b62cd9e957c9d4623ef0368c257a865e1d5aa | Rust | thomaslienbacher/Moving-Tower | /src/ui.rs | UTF-8 | 4,581 | 3.015625 | 3 | [
"MIT"
] | permissive | use sfml::graphics::*;
use sfml::system::Vector2f;
use sfml::window::Event;
use sfml::window::mouse::Button;
pub struct UiButton<'a> {
shape: RectangleShape<'a>,
text: Text<'a>,
rect: FloatRect,
clicked: bool,
down: bool,
fill_color: Color,
border_color: Color,
}
const DOWN_SCALE: f32 = 0.... | true |
aeca335e372e29ce6fec09569ea657feae3492b7 | Rust | cloew/KaoBoy | /src/cpu/instructions/sources/addressed_by_short_source.rs | UTF-8 | 3,864 | 3.09375 | 3 | [] | no_license | use super::{ByteSource, ConstantShortSource, DoubleRegisterSource, ShortSource};
use super::super::utils::{PostOpFn, dec_double_register, inc_double_register};
use super::super::super::instruction_context::InstructionContext;
use super::super::super::registers::DoubleRegisterName;
use crate::boxed;
pub struct Ad... | true |
9d8ce068a4a460d59ef4df4d5a5d7baa0255c22d | Rust | KaitaoQiu/openlimits | /src/exchange/coinbase/model/book_record_l1.rs | UTF-8 | 499 | 2.71875 | 3 | [
"BSD-2-Clause"
] | permissive | use serde::Deserialize;
use serde::Serialize;
use rust_decimal::prelude::Decimal;
use super::BookLevel;
use super::shared::string_to_decimal;
/// This struct represents a level 1 book record
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct BookRecordL1 {
#[serde(with = "string_to_decimal")]
pub price... | true |
91e541b3d25600b281e42cd5f7e24a9f072496ab | Rust | itsaramcc/ray-tracer | /src/hittable/sphere.rs | UTF-8 | 1,015 | 3.125 | 3 | [] | no_license | use core::f64;
use super::*;
pub struct Sphere {
center: Point3,
radius: f64
}
pub fn sphere(center: Point3, radius: f64) -> Sphere {
Sphere { center, radius }
}
impl Hittable for Sphere {
fn hit(&self, ray: &Ray, t_min: f64, t_max: f64, rec: &mut HitRecord) -> bool {
let oc = ray.origin() - se... | true |
72f0404da8c2abc59031e27e16cbeb5517a67f6b | Rust | instrumentisto/cqrs-rs | /cqrs-codegen/tests/event_sourced.rs | UTF-8 | 2,403 | 2.84375 | 3 | [
"Apache-2.0"
] | permissive | #![allow(dead_code)]
use std::marker::PhantomData;
use cqrs::EventSourced as _;
use cqrs_codegen::{Aggregate, Event, EventSourced};
#[derive(Aggregate, Default)]
#[aggregate(type = "aggregate")]
struct Aggregate {
id: i32,
event1_applied: bool,
event2_applied: bool,
event3_applied: bool,
event4_a... | true |
a4ba50807a52d05b9933d2cfbd65383e096b6463 | Rust | Origen-SDK/o2 | /rust/origen/src/generator/processors/upcase_comments.rs | UTF-8 | 1,528 | 3.4375 | 3 | [
"MIT"
] | permissive | //! A very simple example processor which returns a new version of the
//! given AST with all comments changed to upper case.
use super::super::nodes::PAT;
use crate::Result;
use origen_metal::ast::*;
pub struct UpcaseComments {}
impl UpcaseComments {
#[allow(dead_code)]
pub fn run(node: &Node<PAT>) -> Resul... | true |
a1cb5663a47253e51e3e9b3a0f6d61fc983ef551 | Rust | Matthias247/futures-intrusive | /src/channel/error.rs | UTF-8 | 1,952 | 3.734375 | 4 | [
"Apache-2.0",
"MIT"
] | permissive | /// The error which is returned when sending a value into a channel fails.
///
/// The `send` operation can only fail if the channel has been closed, which
/// would prevent the other actors to ever retrieve the value.
///
/// The error recovers the value that has been sent.
#[derive(PartialEq, Debug)]
pub struct Chann... | true |
0e0bb54a55332e60639f284b95ffaef0b1c54673 | Rust | arve0/build-your-own-couchdb | /sakkosekk/src/tests.rs | UTF-8 | 2,439 | 3.171875 | 3 | [] | no_license | #[cfg(test)]
mod database {
use crate::*;
use rusqlite::Connection;
use std::fs::remove_file;
#[test]
fn creating_database_twice_should_not_fail() {
with("creating_twice.sqlite", |_| {
get_db_create_if_missing("creating_twice.sqlite");
});
}
#[test]
fn inser... | true |
b9a505239118bb432e2c8f4b556720b073867172 | Rust | maulikchevli/cns | /caesar-cipher-rs/main.rs | UTF-8 | 3,393 | 3.21875 | 3 | [] | no_license | use std::io;
use std::io::prelude::*;
mod caesar;
fn main() {
let mut choice = String::new();
loop {
println!("CHoice: \nencrypt, decrypt, brute force, frequency analysis, exit");
println!("Enter Choice: ");
io::stdin().read_line(&mut choice)
.expect("Failed to read line")... | true |
6c49581bc1ed96cc7f6693bdd6d6e04c1abc4590 | Rust | prataprc/gist | /rs/euler/src/problem0005.rs | UTF-8 | 864 | 3.390625 | 3 | [
"MIT"
] | permissive | use primes;
/// 2520 is the smallest number that can be divided by each of the numbers
/// from 1 to 10 without any remainder.
/// What is the smallest positive number that is evenly divisible by all
/// of the numbers from 1 to 20?
pub fn solve() {
let primes: Vec<u32> = primes::Primes::new(20).collect();
let... | true |
d0b4a601c1abb6109ba69026f1aea0f617de213a | Rust | keiono/egraph-rs | /crates/egraph/src/algorithm/connected_components.rs | UTF-8 | 1,605 | 2.96875 | 3 | [
"MIT"
] | permissive | use crate::Graph;
use std::collections::{HashMap, HashSet, VecDeque};
pub fn connected_components<D, G: Graph<D>>(graph: &G) -> HashMap<usize, usize> {
let mut components = HashMap::new();
let mut visited = HashSet::new();
let mut queue = VecDeque::new();
for u in graph.nodes() {
if visited.con... | true |
61e3030ee7baa698635f82842232ccd6417c7444 | Rust | flosmn/coding | /project_euler/problem_002/solution.rs | UTF-8 | 199 | 2.9375 | 3 | [] | no_license | fn main() {
let mut x0 = 1;
let mut x1 = 1;
let mut sum = 0;
while x1 < 4000000 {
if x1 % 2 == 0 {
sum += x1;
}
let x2 = x0 + x1;
x0 = x1;
x1 = x2;
}
println!("sum: {}", sum);
}
| true |
8249bd15cadb14c197002240a62771ca34387ed8 | Rust | rschifflin/rust-entity-component-system | /src/systems/color_system.rs | UTF-8 | 598 | 2.625 | 3 | [] | no_license | use pubsub::Pubsub;
use pubsub::Event;
use components::color_component::ColorComponent;
use ECS;
#[derive(Copy)]
pub struct ColorSystem;
impl ColorSystem {
pub fn subscribe(pubsub: &mut Pubsub<ECS, String, String>) {
pubsub.subscribe("component_color".to_string(), ColorSystem::add_listener);
}
fn add_liste... | true |
9e01f5799dfc0d5858c1d4164f604871723c7fe8 | Rust | hannahellis4242/sudoku_solver | /src/main.rs | UTF-8 | 6,414 | 2.71875 | 3 | [
"MIT"
] | permissive | extern crate futures;
extern crate hyper;
extern crate itertools;
#[macro_use]
extern crate serde_json;
extern crate valico;
use hyper::server::{Request, Response, Service};
use hyper::Method::Get;
use hyper::{Chunk, StatusCode};
use futures::future::{Future, FutureResult};
use futures::Stream;
mod sudoku;
mod json... | true |
e1dbc320ab9fd8db01c9eda5ac617795766f8aef | Rust | yaocanwei/n-sql | /src/lexer/char_locations.rs | UTF-8 | 1,515 | 2.53125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | // Copyright 2019 The n-sql Project Developers.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// ex... | true |
dfc232faffa81fb1c46dc4b2aa66d9b5215ddf84 | Rust | AdelaideAuto-IDLab/bTracked | /base_station/src/config/mod.rs | UTF-8 | 3,089 | 3.046875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | mod serial_config;
use std::path::PathBuf;
use serialport;
fn default_true() -> bool { true }
fn default_1() -> u64 { 1 }
fn default_100() -> u64 { 1 }
fn default_some_30() -> Option<u64> { Some(30) }
fn default_log() -> String { "warn".into() }
#[derive(Serialize, Deserialize)]
#[serde(rename_all = "lowercase", ta... | true |
dc6b173660a36d41dd02d9d637cb10820ec9f947 | Rust | tillrohrmann/rust-challenges | /aoc_2019_13/src/lib.rs | UTF-8 | 8,796 | 3.015625 | 3 | [
"Apache-2.0"
] | permissive | use aoc_2019_2::IntComputer;
use std::cell::RefCell;
use std::fmt::Formatter;
use std::io::{BufRead, BufReader, Error, ErrorKind, Stdout};
use std::rc::Rc;
use std::str::FromStr;
pub struct Pinball {
game_memory: Vec<i64>,
}
impl Pinball {
pub fn new(path: &str) -> Pinball {
let mut game_memory = aoc_... | true |
3a49b7aa5f68e8c6a62a63386546a69329e7cafe | Rust | eeverett6/route-rs | /src/utils/test/packet_generators.rs | UTF-8 | 2,790 | 3.09375 | 3 | [
"MIT"
] | permissive | use crate::api::ElementStream;
use futures::{stream, Async, Poll, Stream};
use std::time::Duration;
use tokio::timer::Interval;
// Immediately yields a collection of packets to be poll'd.
// Thin wrapper around iter_ok.
pub fn immediate_stream<I>(collection: I) -> ElementStream<I::Item>
where
I: IntoIterator,
... | true |
84cfe4efd33a61bcfce5cbc31aedce6b187fcd37 | Rust | liyuntao/adventofcode2018 | /examples/day20.rs | UTF-8 | 2,466 | 3.09375 | 3 | [] | no_license | use std::collections::HashMap;
use std::collections::VecDeque;
use std::fs::File;
use std::io::Read;
fn solution(input: String) {
let mut grid: HashMap<(i32, i32), usize> = HashMap::new();
let mut cur_pos: (i32, i32) = (0, 0);
grid.insert(cur_pos, 0);
let mut stack = VecDeque::new();
for c in input... | true |
173495243dcea23ead663ef8f1f622c7dc4a5555 | Rust | NickSchmitt/Exercism | /rust/nth-prime/src/lib.rs | UTF-8 | 919 | 3.5625 | 4 | [] | no_license | pub fn nth(n: usize) -> usize {
prime_sieve(n+1, n+2)
}
pub fn prime_sieve(target_prime: usize, max_number_to_check: usize) -> usize {
let mut prime_mask = vec![true; max_number_to_check];
prime_mask[0] = false;
prime_mask[1] = false;
let mut total_primes_found = 0;
for current_num in 2.... | true |
3cc047597402441074de4c51f7c814e5a97d59ce | Rust | rust3dr3d/rest_api_quickstart | /src/data.rs | UTF-8 | 1,952 | 3.0625 | 3 | [] | no_license | use serde::{Serialize, Deserialize};
use std::fs::{File, OpenOptions};
use rocket::response::NamedFile;
use std::io::prelude::*;
use std::str;
pub const _DB_PATH:&'static str = "messages_db.txt";
#[derive(Serialize, Deserialize, Debug)]
pub struct Message{
pub id: u8,
pub message:String,
pub from:String
}... | true |
915d1fb8adc466ac18d9e1e9c910f3794d73dac1 | Rust | tjnt/atcoder-rust | /src/accept/past201912_h.rs | UTF-8 | 2,381 | 2.828125 | 3 | [] | no_license | /* {{{ */
use std::io::*;
use std::str::FromStr;
struct Scanner<R: Read> {
reader: R,
}
impl<R: Read> Scanner<R> {
fn new(r: R) -> Scanner<R> {
Scanner { reader: r }
}
fn read<T: FromStr>(&mut self) -> T {
let token = self
.reader
.by_ref()
.bytes()
... | true |
a3ae2926394e3ea8780ae03bbcf7e436dec92489 | Rust | prescod/advent-of-code-2019 | /day04/day4b.rs | UTF-8 | 912 | 3.109375 | 3 | [] | no_license | use std::io;
extern crate regex;
use regex::Regex as Regex;
fn check(i: u32, re1: &Regex, re2: &Regex) -> bool{
let as_string = i.to_string();
let matched : bool = false;
for cap in re1.captures_iter(&as_string) {
for i in 1..10{
if let Some(val) = cap.get(i){
if val.as_... | true |
3679f4ff3dae96a16cca54fb79fc338666c6f819 | Rust | cohyou/epiqs | /src/parser/mod.rs | UTF-8 | 11,971 | 2.96875 | 3 | [
"MIT"
] | permissive | macro_rules! push {
($s:ident, $t:expr) => {{
// println!("parser push: {:?}", $t);
Ok($s.vm.borrow_mut().alloc($t))
}}
}
mod error;
use std::rc::Rc;
use std::cell::RefCell;
use core::*;
use lexer::*;
use self::error::Error;
use self::TokenState::*;
const UNIT_INDX: usize = 0;
const K: usize ... | true |
42c2347d0d0e1bdb8d2a3e7850a2163658a7cf05 | Rust | marti1125/rust-ejemplos | /funciones/src/main.rs | UTF-8 | 647 | 3.71875 | 4 | [
"MIT"
] | permissive | fn main() {
saludo("Mozilla".to_string());
println!("Suma: {:?}", sumar(100,898));
println!("Potencia: {:?}", potencia(5,5));
let total = sumar(100,898) + potencia(5,5);
println!("Total: {:?}", total);
}
fn saludo(name :String) {
println!("Hello, {:?}", name)
}
fn sumar(x :i32, y :i32) -> i32 ... | true |
e7d25e4fb64843197b99cfeeb6f6bcdfa528b1a6 | Rust | askoufis/advent-of-code-2020 | /src/day12.rs | UTF-8 | 6,480 | 3.40625 | 3 | [] | no_license | use std::num::ParseIntError;
use std::str::FromStr;
use crate::vec::Vec2;
const RIGHT_ROTATION_ORDER: [Direction; 4] =
[Direction::N, Direction::E, Direction::S, Direction::W];
const LEFT_ROTATION_ORDER: [Direction; 4] =
[Direction::N, Direction::W, Direction::S, Direction::E];
#[derive(Clone, Copy, Debug)]
... | true |
1362962dc35180887133c21f4cf4e7ba0755e6f5 | Rust | sagan-software/oak | /crates/oak/src/render.rs | UTF-8 | 10,338 | 2.734375 | 3 | [] | no_license | use crate::{
html::{Attribute, Children, Element, EventListener, EventToMessage, Html},
program::Program,
};
use itertools::{EitherOrBoth, Itertools};
use std::fmt::Debug;
use std::rc::Rc;
use wasm_bindgen::prelude::*;
use wasm_bindgen::JsCast;
pub struct Renderer<Model, Msg> {
program: Rc<Program<Model, M... | true |
98daeb4ad09fbe47547460753d3ee2557c91af08 | Rust | rekka/ndarray-npy | /src/lib.rs | UTF-8 | 3,563 | 3.140625 | 3 | [
"MIT"
] | permissive | //! A simple serialization of ndarray arrays of simple types (`f32`, `f64`) into
//! [NumPy](http://www.numpy.org/)'s [`.npy`
//! format](https://docs.scipy.org/doc/numpy/neps/npy-format.html).
//!
//! Files produced this way can be loaded with
//! [`numpy.load`](https://docs.scipy.org/doc/numpy-1.13.0/reference/genera... | true |
a139b33a69e8f4f93c02603ef245d95ff65fcef3 | Rust | plyhun/plygui | /api/src/callbacks.rs | UTF-8 | 2,752 | 2.6875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use crate::{controls, types::{adapter}};
pub use crate::inner::{
auto::OnFrame,
has_size::OnSize,
has_visibility::OnVisibility,
clickable::OnClick,
closeable::OnClose,
item_clickable::OnItemClick,
member::MemberBase,
};
use std::fmt::{Display, Formatter, Result as FmtResult};
use std::sync::... | true |
5f588224059b2eac14e389bec50030a9d57246cb | Rust | plyhun/plygui | /api/src/inner/closeable.rs | UTF-8 | 4,065 | 2.765625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use crate::callbacks::*;
use super::auto::{AsAny, HasInner, Abstract};
use super::member::{AMember, Member, MemberInner, MemberBase};
use super::application::Application;
define_abstract! {
Closeable : Member {
extends: {
'static + AsAny
},
outer: {
fn on_close(& mu... | true |
f176f21513ba694460e722cad1f219af2abb8a2a | Rust | afprusin/leetcode-rust | /src/bin/68_text_justification.rs | UTF-8 | 796 | 3.296875 | 3 | [] | no_license | pub struct Solution {}
impl Solution {
pub fn full_justify(words: Vec<String>, max_width: i32) -> Vec<String> {
let mut lines: Vec<Vec<&String>> = Vec::new();
let mut current_line = Vec::new();
let mut character_count = 0;
for word in &words {
if (character_count + word... | true |
6b294bc4ab7910c9dd74c2dc6e595addfa24b072 | Rust | FreeCX/advent-of-code | /2020/day04/src/part_one.rs | UTF-8 | 721 | 2.875 | 3 | [
"CC0-1.0"
] | permissive | use crate::id::Id;
pub fn is_valid_one(id: &Id) -> bool {
id.birth_year.is_some()
&& id.issue_year.is_some()
&& id.expiration_year.is_some()
&& id.height.is_some()
&& id.hair_color.is_some()
&& id.eye_color.is_some()
&& id.passport_id.is_some()
}
pub fn process(ids:... | true |
00b7a940b5d5524c1c248895d868d66ee67898ac | Rust | kpcyrd/cargo-deb | /src/debarchive.rs | UTF-8 | 1,787 | 2.6875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::error::CDResult;
use crate::manifest::Config;
use crate::pathbytes::*;
use ar::{Builder, Header};
use std::fs;
use std::fs::File;
use std::path::{Path, PathBuf};
pub struct DebArchive {
out_abspath: PathBuf,
prefix: PathBuf,
ar_builder: Builder<File>,
}
impl DebArchive {
pub fn new(config: ... | true |
ef64255d0fe908f02f09cd6386896a7000a0d307 | Rust | carl-erwin/unlimited | /src/lib.rs | UTF-8 | 390 | 2.625 | 3 | [
"MIT"
] | permissive | /// This module contains the server core
pub mod core;
/// This module contains the ui front-ends.<br/>
/// The current design uses Sender/Receiver to exchange data/state to the core
pub mod ui;
// TODO(ceg): pub mod misc
/// simple function to sort a (T, T) pair
pub fn sort_pair<T: PartialOrd>(t: (T, T)) -> (T, T) {... | true |
38e1a65e186cc04cdf8c31b495f874ec071f4f4c | Rust | jessicalally/rust-regex | /src/parser.rs | UTF-8 | 12,698 | 3.1875 | 3 | [] | no_license | use self::{Atom::*, ClassMember::*, Quantifier::*, Term::*};
use crate::lexer::{Lexemes, Lexemes::*};
use std::iter::Peekable;
use std::slice::Iter;
pub type Expr = Vec<Term>;
#[derive(Debug, PartialEq, Clone)]
pub enum Term {
TAtom(Atom),
TOp(Quantifier),
}
#[derive(Debug, PartialEq, Clone)]
pub enum Atom {... | true |
fced12806eebc04444760191087d615f840e5e36 | Rust | JamesMcGuigan/ecosystem-research | /rust/rust-crash-course/src/arrays.rs | UTF-8 | 1,421 | 3.515625 | 4 | [
"MIT"
] | permissive | use std::mem;
use std::mem::size_of_val;
pub fn run() {
// Arrays are stack allocated
let numbers: [i32; 5] = [1, 2, 3, 4, 5];
println!("numbers: {:?}", numbers);
println!("numbers[0]: {:?}", numbers[0]);
println!("&numbers: {:?}", &numbers);
println!("&numbers[1..3]: {:?}", &n... | true |
6f256879c0fc8e7f376f03388996f8e700f6ca2a | Rust | ivan-brko/can_over_zmq_broker | /src/main.rs | UTF-8 | 1,587 | 2.953125 | 3 | [] | no_license | extern crate zmq;
//TODO: move this function to it's own module
fn initialize_zmq() -> (zmq::Context, zmq::Socket, zmq::Socket) {
let context = zmq::Context::new();
let broadcaster = context.socket(zmq::PUB).unwrap(); //TODO: add error handling here!
assert!(broadcaster.bind("tcp://127.0.0.1:5558").is_ok()... | true |
0b35202e2ddb64c1b75ed1fc5e3f72a9ee8fa873 | Rust | digitalbitbox/bitbox02-firmware | /src/rust/vendor/bytes/src/lib.rs | UTF-8 | 3,536 | 2.875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | #![warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]
#![doc(test(
no_crate_inject,
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
))]
#![doc(html_root_url = "https://docs.rs/bytes/1.0.0")]
#![no_std]
//! Provides abstractions for working with bytes.
//!
//! The `b... | true |
ab6d481c52919fa26b1a51e83f735c5c17aaa285 | Rust | d3k4r/aqueren | /src/lib.rs | UTF-8 | 14,843 | 2.703125 | 3 | [
"MIT"
] | permissive | extern crate rustc_serialize;
mod game;
pub mod types;
pub mod server;
use game::*;
use types::*;
type BoardTiles = [[i32; COLS as usize]; ROWS as usize];
type PlayerTiles = [[(i32,i32); 6]; PLAYERS as usize];
#[test]
fn players_start_with_six_tiles() {
let game = new_game();
for player in game.players {
... | true |
6cfd1332ab03a183320744b25f324cccaa2fb700 | Rust | NatoliChris/rust-learn | /rust-by-example/modules.rs | UTF-8 | 491 | 3.390625 | 3 | [] | no_license | mod my_mod {
fn private_function() {
println!("Shh I'm private, only called inside `private_function()`");
}
pub fn pub_function() {
println!("Hi I'm a public function `my_mod::function()`");
}
pub fn call_priv() {
println!("I'm about to call private!!");
private_function();
}
pub mo... | true |
9fcd10fe25894d44161cc7586b8ac296663bf451 | Rust | Cerber-Ursi/auto_curry | /tests/smoke.rs | UTF-8 | 239 | 2.625 | 3 | [] | no_license | #![feature(unboxed_closures)]
#![feature(fn_traits)]
use auto_curry::auto_curry;
#[auto_curry]
fn test(arg1: u8, arg2: &str) -> String {
format!("{}-{}", arg1, arg2)
}
fn main() {
assert_eq!(test(0, "test"), test(0)("test"));
}
| true |
ea3487ec19e76c67b67d50e50f69244b85c2fdbd | Rust | kristianhasselknippe/shooter | /engine/src/game_state.rs | UTF-8 | 717 | 2.875 | 3 | [] | no_license | use super::glm::Vector2;
use entities::*;
#[derive(Debug)]
pub struct GameState {
ecs: EntityComponentStore,
name: String,
}
impl GameState {
pub fn new(name: &str) -> GameState {
GameState {
ecs: EntityComponentStore::new(),
name: name.to_string(),
}
}
pub... | true |
2bc22def857cf8fc6e1e16cf8b2ab8dc1cbeb5cc | Rust | vangroan/rlox | /rlox-core/tests/test_array_init.rs | UTF-8 | 403 | 2.90625 | 3 | [] | no_license | //! Macro tests cannot live in the special proc macro package.
use rlox_derive::array_init;
/// Importantly, this type does not implement `Clone` or `Copy`.
#[derive(Debug, PartialEq, Eq)]
struct Foo {
value: u32,
}
#[test]
fn test_array_init() {
let arr1 = array_init!(Foo, [Foo { value: 169_093_200 }; 16]);
... | true |
629e94e73073fb5a4b0f139b79538cc86227cdea | Rust | genos/online_problems | /exercism/rust/hello-world/tests/hello-world.rs | UTF-8 | 322 | 3.03125 | 3 | [
"MIT"
] | permissive | extern crate hello_world;
#[test]
fn test_no_name() {
assert_eq!("Hello, World!", hello_world::hello(None));
}
#[test]
fn test_sample_name() {
assert_eq!("Hello, Alice!", hello_world::hello(Some("Alice")));
}
#[test]
fn test_other_same_name() {
assert_eq!("Hello, Bob!", hello_world::hello(Some("Bob")));
... | true |
c3190daf36d6cf9e1d32e4010ac84f86d1e2abfa | Rust | vojtechkral/rust-c-import | /src/def.rs | UTF-8 | 1,727 | 2.515625 | 3 | [] | no_license | use syntax::codemap::{Span, Spanned};
use syntax::ast;
use syntax::ast::{Name, Ident, Expr, Item, Visibility};
use syntax::ext::base::ExtCtxt;
use syntax::ext::build::AstBuilder;
use syntax::ptr::P;
use rustc_serialize::json::{Json, Decoder};
use rustc_serialize::Decodable;
pub fn hack_vis(item: &mut P<Item>, vis: V... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.