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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
f2263d8293ee2c31953a73dc751a20ebc23a6227 | Rust | dfrankland/eyeliner | /src/lib.rs | UTF-8 | 2,186 | 3.40625 | 3 | [] | no_license | //! A CSS inliner for making emails.
mod eyeliner;
mod hash;
mod options;
mod rules;
mod settings;
pub mod traits;
use self::traits::*;
pub use self::{eyeliner::*, hash::*, options::*, rules::*, settings::*};
pub use servo_css_parser::{servo_config, embedder_traits as servo_embedder_traits};
/// Returns a string of ... | true |
478d8e88ef40422625afece67c956c1081f2ae6d | Rust | mkissarli/Leetcode | /top_interview_questions_easy/strings/valid_palindrome.rs | UTF-8 | 932 | 3.65625 | 4 | [] | no_license | /*******************************************************************************
Valid Palindrome
Given a string, determine if it is a palindrome, considering only alphanumeric
characters and ignoring cases.
Note:For the purpose of this problem, we define empty string as valid palindrome.
Example 1:
Input: "A man,... | true |
1afd1459d80e518f1892583693eb52112e7c09f3 | Rust | jaxwilko/paddle | /src/display/gpu/shader.rs | UTF-8 | 2,965 | 2.578125 | 3 | [] | no_license | use web_sys::{WebGlProgram, WebGlRenderingContext, WebGlShader};
use crate::{ErrorMessage, PaddleResult};
pub fn new_vertex_shader(gl: &WebGlRenderingContext) -> PaddleResult<WebGlShader> {
compile_shader(
&gl,
WebGlRenderingContext::VERTEX_SHADER,
DEFAULT_VERTEX_SHADER,
)
}
pub fn ne... | true |
4f2906103223dfbc345b4a77f035a78304438548 | Rust | JamesOwenHall/servdisc | /src/party_test.rs | UTF-8 | 3,023 | 2.953125 | 3 | [
"MIT"
] | permissive | use std::thread;
use std::time::Duration;
use config::Config;
use party::Party;
#[test]
fn single_node() {
let mut party = Party::from_config(&test_config()).unwrap();
party.join().unwrap();
let hosts = party.new_hosts().unwrap();
assert_eq!(hosts, vec!["node_1"]);
}
#[test]
fn three_nodes() {
... | true |
45431d9a446198efdcb3f4e6393f579fcdb05e92 | Rust | mclark4386/weldr | /tests/test-proxy.rs | UTF-8 | 6,352 | 2.65625 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | extern crate env_logger;
#[macro_use] extern crate log;
extern crate futures;
extern crate tokio_core;
extern crate hyper;
extern crate weldr;
extern crate reqwest;
use std::io::{Read, Write};
use std::net::{TcpStream, SocketAddr};
use std::sync::mpsc::channel;
use std::thread;
use std::time::Duration;
use hyper::{Ge... | true |
0dd19a18d2cfea7bb048e9b0c4214d9fac39a4a9 | Rust | raum-dellamorte/raumEnSysInfo | /src/shader/mod.rs | UTF-8 | 8,500 | 2.59375 | 3 | [] | no_license |
pub mod font;
pub use shader::font::gen_font_shader;
use gl::*;
use gl::types::{GLenum, GLuint, GLint, GLfloat, }; // GLchar, GLsizeiptr, GLboolean,
use std::ptr;
use std::str;
use std::str::from_utf8;
use std::ffi::CStr;
use std::ffi::CString;
use std::mem::transmute;
use std::fs::File;
use std::io::BufReader;
us... | true |
b1a2ca5d81cc60db1ccbe152d1cdc33dacf98c8b | Rust | m-mueller678/space_game | /server/src/game_pool/mod.rs | UTF-8 | 3,252 | 2.78125 | 3 | [] | no_license | mod game_container;
use std::sync::Arc;
use std::sync::mpsc::{Sender, Receiver, channel, RecvTimeoutError};
use std::sync::atomic::{AtomicUsize, Ordering};
use std::thread;
use time::{SteadyTime, Duration};
use mio::tcp::TcpStream;
use common::protocol::*;
use common::game::ship::BaseShipBuilder;
use self::game_contai... | true |
084508cdc9e7f994250162adf5b3c620c615c58a | Rust | rutgerclaes/2018-advent_of_code-rs | /src/day_1.rs | UTF-8 | 1,112 | 3.40625 | 3 | [] | no_license | use std::collections::HashSet;
use std::fs;
use std::io::Error;
pub fn part_1(deltas: &Vec<i32>) -> i32 {
deltas.iter().fold(0, |freq, delta| freq + delta)
}
pub fn part_2(deltas: &Vec<i32>) -> i32 {
let mut duplicates = deltas
.iter()
.cycle()
.scan((HashSet::new(), 0), |(acc, freq), delta| {
l... | true |
46275b83924f73451e1890fc3c0023b5b9c76c12 | Rust | tlowerison/tilings | /rust/server/models/src/account.rs | UTF-8 | 1,183 | 2.625 | 3 | [
"MIT"
] | permissive | use crate::from_data;
use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize, Serialize)]
pub struct ResetPasswordPost {
#[serde(rename = "passwordResetCode")]
pub password_reset_code: String,
pub password: String,
}
#[derive(Debug, Deserialize, Serialize)]
pub struct SignInPost {
pub email:... | true |
4541aab6ac0660b086e3129d279e30262efb0fb5 | Rust | KaiserKarel/prosit | /prost-build/src/lib.rs | UTF-8 | 37,606 | 3.203125 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #![doc(html_root_url = "https://docs.rs/prost-build/0.8.0")]
#![allow(clippy::option_as_ref_deref)]
//! `prost-build` compiles `.proto` files into Rust.
//!
//! `prost-build` is designed to be used for build-time code generation as part of a Cargo
//! build-script.
//!
//! ## Example
//!
//! Let's create a small crate... | true |
490ae1444051a6cde26067f49a347dffae2af60c | Rust | kaj/rsass | /rsass/tests/spec/core_functions/string/slice/start.rs | UTF-8 | 2,149 | 2.6875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! Tests auto-converted from "sass-spec/spec/core_functions/string/slice/start.hrx"
#[allow(unused)]
fn runner() -> crate::TestRunner {
super::runner().with_cwd("start")
}
mod negative {
#[allow(unused)]
use super::runner;
#[test]
fn t1() {
assert_eq!(
runner().ok("a {b: str-... | true |
6abfd10379d5acecf957af626bc21820a278a959 | Rust | AnderEnder/s3find-rs | /src/arg.rs | UTF-8 | 15,336 | 2.84375 | 3 | [
"BSD-2-Clause"
] | permissive | use glob::Pattern;
use regex::Regex;
use rusoto_core::Region;
use std::str::FromStr;
use structopt::clap::AppSettings;
use structopt::StructOpt;
use thiserror::Error;
/// Walk an Amazon S3 path hierarchy
#[derive(StructOpt, Debug, Clone)]
#[structopt(
name = "s3find",
global_settings(&[AppSettings::ColoredHelp, A... | true |
b8a0b3e587140606038059e7413683c3b4939344 | Rust | Pistahh/dua | /src/du.rs | UTF-8 | 2,213 | 3.0625 | 3 | [
"Apache-2.0"
] | permissive |
use std::fs::{read_dir, symlink_metadata};
use std::path::{PathBuf, Path};
use std::io;
use std::env;
use std::os::unix::fs::MetadataExt;
#[derive(Debug)]
pub enum EntryData {
File { size: u64 },
Directory { size: u64, children: Vec<Entry> },
OtherFs,
Error(io::Error),
Other,
}
#[derive(Debug)]
p... | true |
55bb297c1cfae0cf12b2d5e6a84251121b638ac7 | Rust | lein1013/wallet.rs | /src/error.rs | UTF-8 | 16,629 | 2.65625 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2020 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
use serde::ser::{SerializeStruct, Serializer};
use std::path::PathBuf;
/// Each of the account initialisation required fields.
#[derive(Debug)]
pub enum AccountInitialiseRequiredField {
/// `signer_type` field.
SignerType,
}
impl std::fm... | true |
370d46ec914e370302794bebc08997192e80641e | Rust | atNightly/MeiliDB | /meilidb-data/src/database/documents_index.rs | UTF-8 | 2,967 | 2.53125 | 3 | [
"MIT"
] | permissive | use std::convert::TryInto;
use meilidb_core::DocumentId;
use meilidb_schema::SchemaAttr;
use rocksdb::DBVector;
use crate::database::raw_index::InnerRawIndex;
use crate::document_attr_key::DocumentAttrKey;
#[derive(Clone)]
pub struct DocumentsIndex(pub(crate) InnerRawIndex);
impl DocumentsIndex {
pub fn documen... | true |
6f5e50a5044ff049642f57ace721d3c8723edbf3 | Rust | hyperium/hyper-old-types | /src/header/common/expires.rs | UTF-8 | 1,331 | 3.03125 | 3 | [
"MIT"
] | permissive | use header::HttpDate;
header! {
/// `Expires` header, defined in [RFC7234](http://tools.ietf.org/html/rfc7234#section-5.3)
///
/// The `Expires` header field gives the date/time after which the
/// response is considered stale.
///
/// The presence of an Expires field does not imply that the or... | true |
33f57a2f3f596bfa7b7322fa87a075420ca9a729 | Rust | isgasho/josekit-rs | /src/util.rs | UTF-8 | 2,884 | 2.578125 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | pub mod der;
pub mod hash_algorithm;
pub mod oid;
use anyhow::bail;
use once_cell::sync::Lazy;
use openssl::bn::BigNumRef;
use openssl::rand;
use regex::{self, bytes};
pub use crate::util::hash_algorithm::HashAlgorithm;
pub use HashAlgorithm::Sha1 as SHA_1;
pub use HashAlgorithm::Sha256 as SHA_256;
pub use HashAlgor... | true |
c43e1e104ffbaec0d1575db52586e537023908c1 | Rust | lightclient/bm | /src/proving.rs | UTF-8 | 6,106 | 2.84375 | 3 | [
"Apache-2.0"
] | permissive | use crate::{Backend, ReadBackend, WriteBackend, Construct, Value, ValueOf};
use core::hash::Hash;
use core::ops::Deref;
use core::fmt;
use alloc::boxed::Box;
#[cfg(feature = "std")]
use std::collections::{HashMap as Map, HashSet as Set};
#[cfg(not(feature = "std"))]
use alloc::collections::{BTreeMap as Map, BTreeSet as... | true |
6adbc870d6c1eb1140e23b279269bf18c684cf43 | Rust | tommywalkie/turn | /src/lib.rs | UTF-8 | 1,166 | 3.140625 | 3 | [
"MIT"
] | permissive | mod turnable;
pub use crate::turnable::Turnable;
mod vec;
pub use crate::vec::TurnableVec;
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
let a: Vec<u8> = vec![0, 1, 2, 3];
let b: Vec<f64> = vec![0.1, 1.1, 2.1, 3.1];
let c: Vec<f64> = vec![0.9, 1.9, 2.9, 3.9];
... | true |
761f0c3531bf261032b9fddb9ff6d002d269def2 | Rust | zhanlanlan/hello_rust | /src/lib/syncer.rs | UTF-8 | 1,462 | 2.5625 | 3 | [] | no_license | use chrono::prelude::*;
use log::info;
use notify::{watcher, DebouncedEvent, RecursiveMode, Watcher};
use std::fmt::Display;
use std::sync::mpsc::channel;
use std::time::Duration;
pub fn run() {
let (tx, rx) = channel();
let mut watcher_ = watcher(tx, Duration::from_millis(100)).unwrap();
watcher_.watch... | true |
0a09fdaa032e9fad9b73f4897f7fd438784bacdf | Rust | netromdk/carapace.rs | /src/command/popd_command.rs | UTF-8 | 723 | 3.140625 | 3 | [
"MIT"
] | permissive | use super::*;
use std::path::Path;
/// Popd command pops the top-most directory of the stack and changes CWD to it.
pub struct PopdCommand;
impl Command for PopdCommand {
fn execute(&mut self, prompt: &mut Prompt) -> Result<bool, i32> {
let path = prompt.context.borrow_mut().dir_stack.pop();
if l... | true |
8b71f53fed63f2f5ae904c06cb4478d49ab77771 | Rust | enso-org/enso | /lib/rust/parser/src/lib.rs | UTF-8 | 22,972 | 3.71875 | 4 | [
"AGPL-3.0-only",
"Apache-2.0",
"AGPL-3.0-or-later"
] | permissive | //! The Enso parser. Parsing is a multi-stage process:
//!
//! # Lexing.
//! First, the source code is feed to [`lexer::Lexer`], which consumes it and outputs a stream of
//! [`Token`]. Tokens are chunks of the input with a generic description attached, like "operator",
//! or "identifier".
//!
//! # Building macro reg... | true |
d0628fca9799f5eb683bc1417d57b7a1307c3b53 | Rust | Rayman/miran-rust | /src/main.rs | UTF-8 | 4,205 | 3.171875 | 3 | [] | no_license | use std::cmp::Ordering;
use std::collections::BinaryHeap;
use std::fmt;
#[derive(Clone)]
struct Stats<'a> {
character: &'a dyn Character,
hp: f64,
damage: f64,
attack_speed: f64,
}
trait Character {
fn name(&self) -> &str;
fn stats(&self) -> Stats;
}
#[derive(Debug)]
struct Monster<'a> {
... | true |
3934dfb0a56d6f0b324abd6e060303952c5fee3a | Rust | spaceships/combustion | /src/threadpool.rs | UTF-8 | 5,794 | 2.78125 | 3 | [
"Unlicense",
"LicenseRef-scancode-public-domain"
] | permissive | use crate::board::Board;
use crate::moves::Move;
use crate::transposition_table::TranspositionTable;
use crate::util::ChessError;
use rand::{self, Rng};
use std::mem;
use std::sync::mpsc::{channel, Receiver, Sender};
use std::sync::{Arc, Condvar, Mutex, RwLock};
use std::thread;
use std::time::Duration;
type Worker =... | true |
9cbe77a9a1b856675d105ec442efd22bdba5d8f8 | Rust | ytyaru/Rust.Project.Test.20190616150815 | /src/communicator/src/adder.rs | UTF-8 | 253 | 3.140625 | 3 | [
"CC0-1.0"
] | permissive | pub fn add_two(x: i32) -> i32 { x + 2 }
// 単体テスト
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_add_two() {
assert_eq!(add_two(0), 2);
assert_eq!(add_two(-1), 1);
assert_eq!(add_two(1), 3);
}
}
| true |
e68adab2102e763eb5b5325f62687fd4c41fbf40 | Rust | xurtis/autumn | /examples/sexpression.rs | UTF-8 | 4,467 | 3.03125 | 3 | [
"ISC"
] | permissive | //! Simple S-expression parser example
use autumn::prelude::*;
use std::fmt;
use std::io::{stdin, stdout, BufRead, BufReader, Write};
use std::str::FromStr;
type Error = Box<dyn ::std::error::Error>;
type Result<T> = ::std::result::Result<T, Error>;
fn main() -> Result<()> {
let mut stdin = BufReader::new(stdin... | true |
85c77659af8f87b1cb01769d6ef7deecfcc5dfc4 | Rust | aglarond/sstra | /src/bin/main.rs | UTF-8 | 2,150 | 2.703125 | 3 | [
"MIT"
] | permissive | use std::{process, thread, time};
use chrono::Utc;
use clap::{load_yaml, App};
use sstra::*;
static MOV_AVG_NUM_DAYS: i32 = 30;
#[actix_rt::main]
async fn main() {
let yaml = load_yaml!("cli.yaml");
let matches = App::from(yaml).get_matches();
let now = Utc::now().format("%Y-%m-%d").to_string();
le... | true |
65802f53c383f640ddb20f3a0e9f9c0fd92b5b49 | Rust | enso-org/enso | /build/ci_utils/src/actions/artifacts/download.rs | UTF-8 | 3,660 | 2.640625 | 3 | [
"AGPL-3.0-only",
"Apache-2.0",
"AGPL-3.0-or-later"
] | permissive | use crate::prelude::*;
use crate::actions::artifacts::models::ArtifactResponse;
use crate::actions::artifacts::models::ContainerEntry;
use crate::actions::artifacts::models::ItemType;
use crate::actions::artifacts::run_session::SessionClient;
use crate::actions::artifacts::API_VERSION;
use reqwest::header::HeaderMap;... | true |
01b74067b519ebd154b09d0a776948a4b6e96069 | Rust | jly36963/notes | /rs/utils/clap-notes/src/main.rs | UTF-8 | 5,421 | 3.28125 | 3 | [] | no_license | use clap::{Arg, Command, Parser};
fn main() {
print_section_header(String::from("basic derive"));
basic_derive();
print_section_header(String::from("basic builder"));
basic_builder();
print_section_header(String::from("basic builder (subcommands)"));
basic_builder_subcommands();
}
// ---
// ... | true |
964491d2356ba8b05e4cb61cb4da02ce20053bb2 | Rust | lawliet89/docker-image | /cli/src/main.rs | UTF-8 | 3,483 | 3.078125 | 3 | [
"Apache-2.0"
] | permissive | extern crate docker_image;
extern crate serde_json;
#[macro_use]
extern crate clap;
use std::io::{self, Write};
use clap::{Arg, App};
use docker_image::ImageName;
fn main() {
let args = make_parser().get_matches();
let images: Vec<ImageName> = args.values_of("image_names")
.expect("Missing values sho... | true |
63e90dac7b17177595fbf96c2e29f50a28321949 | Rust | lilith645/AcWars | /src/modules/kdtree.rs | UTF-8 | 5,599 | 2.640625 | 3 | [] | no_license | use maat_graphics::DrawCall;
use std::cmp;
use crate::cgmath::{Vector2, Vector4};
#[derive(Debug, Clone)]
pub struct Node {
location: Vector2<f32>,
l_child: Option<Box<Node>>,
r_child: Option<Box<Node>>,
min_width: Option<f32>,
max_width: Option<f32>,
min_height: Option<f32>,
max_height: Option<f32>,
}... | true |
d29fb4cb313368a71efcf6e55c00e7d2e1ce7007 | Rust | sugyan/leetcode | /problems/0150-evaluate-reverse-polish-notation/lib.rs | UTF-8 | 1,636 | 3.484375 | 3 | [] | no_license | pub struct Solution {}
impl Solution {
pub fn eval_rpn(tokens: Vec<String>) -> i32 {
let mut stack: Vec<i32> = Vec::new();
for token in tokens.iter() {
if let Ok(n) = token.parse() {
stack.push(n);
} else {
let rhs = stack.pop().unwrap();
... | true |
c1ef7873ce08126947dc7b1dd8a7e099bc4c118c | Rust | adolfredo96/rust-sandbox | /src/vars.rs | UTF-8 | 728 | 3.9375 | 4 | [] | no_license | //variables hold primitive data or references to data
//variables are immutable by default
//rust is a blocked scoped language
//the convention for naming variables is _ not camelCase
pub fn run() {
let name = "brad";
let mut age = 24; // mut indicates that the variable can be reassigned stands for mutable
... | true |
f2285bfe3a9f7f302477e2d679c39a8362a3ea32 | Rust | easbar/fast_paths | /src/fast_graph32.rs | UTF-8 | 8,116 | 2.84375 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | 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 ... | true |
b97c6dc12d13514318e3f38b76bcc6a5957eb0cb | Rust | erasmospunk/rust-daemon-runner | /src/utils.rs | UTF-8 | 1,000 | 2.890625 | 3 | [
"CC0-1.0"
] | permissive |
use std::net;
use rand::{thread_rng, Rng};
use regex::Regex;
pub trait RegexUtils: AsRef<str> {
/// Get the first group from the first capture of the regex.
fn rx_single<'a>(&self, s: &'a str) -> Option<&'a str> {
Regex::new(self.as_ref()).expect("invalid regex").captures(s).map(|c| {
c.get(1).unwrap().as_st... | true |
343f5efa8364af1884df35751741c2ccb4153d4a | Rust | matrix-org/matrix-hookshot | /src/format_util.rs | UTF-8 | 5,405 | 2.53125 | 3 | [
"Apache-2.0"
] | permissive | use crate::github::types::*;
use crate::jira;
use crate::jira::types::{JiraIssue, JiraIssueLight, JiraIssueMessageBody, JiraIssueSimpleItem};
use contrast;
use md5::{Digest, Md5};
use napi::bindgen_prelude::*;
use napi_derive::napi;
use rgb::RGB;
use ruma::events::room::message::sanitize::{
sanitize_html, HtmlSanit... | true |
8a94a100048cafeb556173dad64adbe98e79c539 | Rust | matthew-mcallister/playstation-emulator | /src/cpu/operations/ori.rs | UTF-8 | 981 | 3.21875 | 3 | [] | no_license | use crate::cpu::delay::Delay;
use crate::cpu::exception::Exception;
use crate::cpu::interconnect::Interconnect;
use crate::cpu::operations::Operation;
use crate::cpu::registers::Registers;
use crate::instruction::Instruction;
/// Bitwise Or Immediate
pub struct Ori {
instruction: Instruction
}
impl Ori {
pub ... | true |
f20d5abb7e8e262fa0439ed42af73df1e52fbaa4 | Rust | koute/pinky | /mos6502/src/virtual_mos6502.rs | UTF-8 | 38,693 | 2.703125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use self::Register8::*;
use self::Direction::*;
use core::mem::transmute;
use core::fmt;
use core::ops::Deref;
use emumisc::WrappingExtra;
pub type Address = u16;
#[derive(Copy, Clone, PartialEq)]
pub enum EmulationStatus {
Normal,
InfiniteLoop( Address )
}
#[derive(Copy, Clone, PartialEq)]
pub enum Emulat... | true |
7b65846f0346527ffea575f836d8ba66d812529f | Rust | SpBills/onetimepad-rust | /src/lib.rs | UTF-8 | 1,902 | 3.703125 | 4 | [] | no_license | pub mod one_time_pad {
use rand::{thread_rng, Rng};
#[derive(Debug, Clone)]
pub struct OneTimePad {
original: String,
padded: String,
}
impl OneTimePad {
pub fn new(original: String) -> OneTimePad {
return OneTimePad {
original,
p... | true |
4fd29677e52ca5a5ba8059eec6f29bb445552b47 | Rust | mitsuhiko/minijinja | /examples/render-value/src/main.rs | UTF-8 | 348 | 3.0625 | 3 | [
"Apache-2.0"
] | permissive | use minijinja::{context, Environment, Value};
fn main() {
let env = Environment::new();
// this just demonstrates that `context!` creates a `Value`
let ctx: Value = context! {
name => "Peter"
};
// Which can be directly passed to `render_str`.
println!("{}", env.render_str("Hello {{ n... | true |
9a65a30a15ef6ede2e6f9c7513f3e04965f2a05e | Rust | deadalusai/advent-of-code | /2015/day9/src/main.rs | UTF-8 | 3,757 | 3.390625 | 3 | [] | no_license | use std::env::args;
use std::fs::File;
use std::io::{ BufRead, BufReader };
use std::collections::HashMap;
fn open_file() -> File {
let filename = args().skip(1).next().expect("usage: day9 {input filename}");
File::open(filename).expect("Error opening input")
}
type KMs = u32;
#[derive(Debug)]
struct Distan... | true |
48f7fd76e4e6cfbb80d87182dd20a74edf67853f | Rust | nisarhassan12/materialize | /src/persist/src/indexed/columnar.rs | UTF-8 | 19,086 | 2.765625 | 3 | [
"Apache-2.0",
"BSD-2-Clause",
"CC0-1.0",
"BSD-3-Clause",
"MPL-2.0",
"0BSD",
"PostgreSQL",
"GPL-1.0-or-later",
"GPL-2.0-only",
"MIT",
"BUSL-1.1"
] | permissive | // Copyright Materialize, Inc. and contributors. All rights reserved.
//
// Use of this software is governed by the Business Source License
// included in the LICENSE file.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by ... | true |
e44b501ad93e282aa5e831bcb4abad69353b3638 | Rust | bspeice/capnp_cookbook_1 | /src/main.rs | UTF-8 | 2,268 | 3.484375 | 3 | [] | no_license | // Note that we use `capnp` here, NOT `capnpc`
extern crate capnp;
// We create a module here to define how we are to access the code
// being included.
pub mod point_capnp {
// The environment variable OUT_DIR is set by Cargo, and
// is the location of all the code that was built as part
// of the codegen... | true |
def88eb9c2f293e674775737f362e8e93d76ca28 | Rust | lineCode/Oxygengine | /oxygengine-composite-renderer/src/component.rs | UTF-8 | 1,953 | 2.953125 | 3 | [
"MIT"
] | permissive | use crate::{
composite_renderer::Renderable,
math::{Scalar, Vec2},
};
use core::ecs::{Component, VecStorage};
#[derive(Debug, Clone)]
pub struct CompositeRenderable(pub Renderable<'static>);
impl Component for CompositeRenderable {
type Storage = VecStorage<Self>;
}
impl From<Renderable<'static>> for Com... | true |
6e833b90defc964810899b744c73e5c972cc89d0 | Rust | acvcmaster/rust-rag | /src/packets/util.rs | UTF-8 | 2,495 | 3.046875 | 3 | [] | no_license | use std::{mem::size_of, net::Ipv4Addr, str::from_utf8};
use super::definition::PacketError;
pub fn from_bytes<T>(bytes: &[u8]) -> T
where
T: Default + Copy,
{
unsafe {
let packet_bytes = &bytes[0..size_of::<T>()];
let pointer: *const u8 = packet_bytes.as_ptr();
match pointer.cast::<T>... | true |
77fd82b8db865577763761e9942c8a6a4a275423 | Rust | bcho04/spectrogram-3d | /src/lib.rs | UTF-8 | 1,805 | 3 | 3 | [] | no_license | #[macro_use]
extern crate stdweb;
use num::Complex;
use stdweb::js_export;
use stdweb::Array;
use stdweb::web::TypedArray;
fn dft(signal: Vec<i16>) -> Vec<Complex<f64>> {
use std::f64::consts::PI;
let N = signal.len();
let mut output: Vec<Complex<f64>> = vec![];
for k in 0..N/2 {
let sum = ... | true |
2ea70e8c31dc3307682c1832c619dc06fc83dfbb | Rust | scturtle/fun.rs | /exercism/minesweeper.rs | UTF-8 | 958 | 2.9375 | 3 | [] | no_license |
pub fn annotate(board: &[&str]) -> Vec<String> {
let n = board.len() as i8;
if n == 0 { return Vec::new() }
let m = board[0].len() as i8;
board.iter().enumerate().map(|(x, r)|{
r.chars().enumerate().map(|(y, c)|{
if c != ' ' { c } else {
let mut count = 0;
... | true |
a6b8a9f11d84663202aa0a28d5f202e2ac3f7009 | Rust | ChaosStudyGroup/const-str | /const-str/src/verify_regex.rs | UTF-8 | 666 | 3.140625 | 3 | [
"MIT"
] | permissive | /// Returns a compile-time verified regex string literal.
///
/// # Examples
///
/// ```
/// use regex::Regex;
/// let re = const_str::verified_regex!(r"^\d{4}-\d{2}-\d{2}$");
/// assert!(Regex::new(re).is_ok());
/// ```
///
#[macro_export]
macro_rules! verified_regex {
($re:literal) => {
$crate::__imp::ver... | true |
4208e22d9c8a377ea34277e0134e50e263714416 | Rust | jypkkjj/rustrade | /src/model/candle.rs | UTF-8 | 1,526 | 2.828125 | 3 | [] | no_license | use super::open_close::OpenClose;
use crate::candles_utils::{str_to_datetime, time_to_str};
use chrono::{DateTime, Utc};
use ifmt::iwrite;
use rust_decimal::Decimal;
use std::fmt::Display;
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub struct Candle {
pub open_time: DateTime<Utc>,
pub close_time: ... | true |
a7aad7fcf8672e21608863d5de3a6f10b9766248 | Rust | akubera/rust-news | /build.rs | UTF-8 | 1,452 | 2.71875 | 3 | [] | no_license | //
// build.rs
//
use std::{env, fs, path::Path, fs::File, io::Write};
use slideby::SlideShow;
use failure::Error;
fn main() -> Result<(), Error>
{
build_slides()?;
Ok(())
}
fn build_slides() -> Result<(), Error>
{
let out_dir = env::var("OUT_DIR").unwrap();
let mut slideshows = vec![];
for entry in f... | true |
71302a9af18a6e3cfbf73fde0ccdab0ba6e0f3b4 | Rust | iCodeIN/zbus | /zbus/src/connection_builder.rs | UTF-8 | 9,535 | 2.890625 | 3 | [
"MIT"
] | permissive | use async_io::Async;
use async_lock::RwLock;
use static_assertions::assert_impl_all;
use std::{
collections::{HashMap, HashSet},
convert::TryInto,
os::unix::net::UnixStream,
sync::Arc,
};
use zvariant::ObjectPath;
use crate::{
address::{self, Address},
names::{InterfaceName, WellKnownName},
... | true |
932d43233337188d5fa0600ebbc7b70f55b6d452 | Rust | yingliufengpeng/rust_language | /ch04_effective_rust/src/section08_choosing_your_guarantees.rs | UTF-8 | 7,315 | 3.53125 | 4 | [] | no_license |
//!
//! Basic pinter types
//! # Box<T>
//! # &T and &mut T
//! # *const T and *mut T
//! There are C-like raw pointers with no lifetime or ownership attached to them.
//! # Rc<T>
//! ## Guarantess
//! The main guarantee provided here is that the data will not be destroyed u... | true |
b606e16690db9a62bb8826e53fc1108a087b1234 | Rust | conduit-rust/conduit | /examples/basic/src/main.rs | UTF-8 | 821 | 2.625 | 3 | [
"MIT"
] | permissive | use civet::{Config, Server};
use conduit::{Body, HttpResult, RequestExt, Response};
use conduit_router::{RequestParams, RouteBuilder};
use std::sync::mpsc::channel;
fn name(req: &mut dyn RequestExt) -> HttpResult {
let name = req.params().find("name").unwrap();
let bytes = format!("Hello {}!", name).into_bytes... | true |
daca941945934af992e9740c8f398b660fc507c1 | Rust | kei1107/algorithm | /for_rust/tools/UnionFind.rs | UTF-8 | 3,872 | 2.6875 | 3 | [] | no_license | #![allow(unused_mut, non_snake_case,unused_imports)]
use std::iter;
use std::cmp::{max, min, Ordering};
use std::mem::{swap};
use std::collections::{HashMap,BTreeMap,HashSet,BTreeSet,BinaryHeap,VecDeque};
use std::iter::FromIterator;
// 高速 EOF要
//macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.... | true |
5226c9318f7617ad5a622f4ac07a509980f999fb | Rust | devil-k/gluesql | /src/data/value/mod.rs | UTF-8 | 26,904 | 2.703125 | 3 | [
"Apache-2.0"
] | permissive | use {
super::{Interval, StringExt},
crate::{ast::DataType, result::Result},
chrono::{NaiveDate, NaiveDateTime, NaiveTime},
core::ops::Sub,
serde::{Deserialize, Serialize},
std::{cmp::Ordering, collections::HashMap, fmt::Debug},
};
mod big_edian;
mod date;
mod error;
mod group_key;
mod into;
mod... | true |
21e8e044f0fae32918abc12a16a4c702f4bb65d0 | Rust | DrStiev/rs-handlegraph2 | /src/mutablehandlegraph.rs | UTF-8 | 4,757 | 3.265625 | 3 | [
"MIT"
] | permissive | use crate::handle::{Edge, Handle, NodeId};
use crate::handlegraph::{HandleGraph, HandleGraphRef};
pub trait SubtractiveHandleGraph {
/// Function that remove a node and all its occurrencies
/// # Example
/// ```ignore
/// // Nodes: 11, 12, 13
/// // Edges: 11 -> 12, 11 -> 13, 12 -> 13
///
/... | true |
54f6eb8c7893028d974e77d16a8dc555d70c020c | Rust | iqlusioninc/abscissa | /core/src/error/macros.rs | UTF-8 | 2,154 | 3.75 | 4 | [
"Apache-2.0"
] | permissive | //! Error-handling macros for the `abscissa` framework
//!
//! This crate defines two error handling macros designed to produce formatted
//! error messages from error kind enums that implement the `Fail` trait:
//!
//! * `err!(kind, description)` creates a new `Error<Kind>` with the given
//! description. If additio... | true |
574b95eb2e209c8e74e9beea011900d98239a0d1 | Rust | rustysec/parselnk-rs | /src/link_info.rs | UTF-8 | 13,704 | 3.015625 | 3 | [] | no_license | //! Definitions for the
//! [LinkInfo](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-shllink/6813269d-0cc8-4be2-933f-e96e8e3412dc)
//! type.
//!
use super::Result;
use crate::{error::LinkInfoError, header::ShellLinkHeader, LinkFlags};
use bitflags::bitflags;
use byteorder::{ReadBytesExt, LE};
use std... | true |
05034e6920a28acfe548cba5cfd95877b734ff32 | Rust | pma-developer/Rogame | /src/common/settings.rs | UTF-8 | 534 | 2.8125 | 3 | [] | no_license | use serde::{Serialize, Deserialize};
use std::fs;
#[derive(Serialize, Deserialize, Debug)]
pub struct Settings {
resolution: (i32, i32)
}
impl Settings {
pub fn from_file(path : String) -> Self {
let json = fs::read_to_string(path).expect("Cant read json from file");
Settings::from_json(json)... | true |
acb1cc0f39b63e85431166d706adf076bacb5ad2 | Rust | Techno-coder/oracus | /src/span.rs | UTF-8 | 1,924 | 3 | 3 | [
"MIT"
] | permissive | use std::collections::BTreeMap;
pub type S<T> = Spanned<T>;
#[derive(Debug, Copy, Clone)]
pub struct Span(pub usize, pub usize);
impl Span {
pub fn extend(self, Span(_, byte_end): Span) -> Self {
let Span(byte_start, span_byte_end) = self;
assert!(span_byte_end <= byte_end);
Span(byte_start, byte_end)
}
}
#... | true |
5b364b2a8afa1fd99eb4ba3e3d59131a21d2d68b | Rust | deciduously/bfrs | /src/parser.rs | UTF-8 | 2,064 | 3.359375 | 3 | [
"MIT"
] | permissive | use lexer::{Token, Tokens};
#[derive(Debug, PartialEq)]
pub enum Op {
Increment(i32),
Shift(isize),
Loop(Box<[Op]>),
Print,
Input,
Dump,
}
impl Op {
// TODO Result
pub fn from_token(token: Token) -> Op {
use self::Op::*;
match token {
Token::Increment => In... | true |
3047c51ccceb16ec72c0c43dc45d3bb364ee4789 | Rust | sidju/drim | /src/handlers/login.rs | UTF-8 | 4,780 | 2.65625 | 3 | [] | no_license | use super::*;
pub fn routes(state: crate::State)
-> impl Filter<Extract = impl Reply, Error = Rejection> + Clone
{
let login_get_path = warp::get()
.map_async(login_get);
let login_post_path = warp::post()
.and(with_var(state.hasher.clone()))
.and(with_var(state.dbpool.clone()))
.and(warp::body:... | true |
6dfd82127183c81094caf7d099ac6fe1e4465221 | Rust | gnuvince/aoc2020 | /src/day15.rs | UTF-8 | 960 | 3.109375 | 3 | [] | no_license | use std::io;
fn parts(turns: usize, nums: &Vec<i32>) -> usize {
let mut cache: Vec<i32> = vec![-1; turns];
for i in 0..nums.len() - 1 {
cache[nums[i] as usize] = (i+1) as i32;
}
let mut curr: usize = nums[nums.len() - 1] as usize;
for t in nums.len()..turns {
match cache[curr] {
... | true |
8db2562fe70302a50d921a1f579b78d5035e461e | Rust | J-AugustoManzano/livro_Rust | /ExerciciosAprendizagem/Cap09/c09ex13/src/main.rs | UTF-8 | 407 | 2.609375 | 3 | [] | no_license | extern crate chrono;
use chrono::prelude::*;
use std::io;
use std::io::prelude::*;
fn main() {
let horautc: DateTime<Utc> = Utc::now();
let horalocal: DateTime<Local> = Local::now();
println!("{}", horautc);
println!("{}", horalocal);
println!();
print!("Tecle <Enter> para encerrar..... | true |
873036a646dc902271e4b53e0fd017f3d7d7aea2 | Rust | fruit-in/exercism-solution | /rust/pig-latin/src/lib.rs | UTF-8 | 1,044 | 3.40625 | 3 | [
"MIT"
] | permissive | use regex::Regex;
pub fn translate(input: &str) -> String {
input
.split_ascii_whitespace()
.map(|word| translate_single_word(word))
.collect::<Vec<_>>()
.join(" ")
}
pub fn translate_single_word(word: &str) -> String {
let rule1 = Regex::new(r"^([aiueo]|xr|yt)+").unwrap();
... | true |
b4e8e7e42de8d7ee75ccd4a36180a68e2a456146 | Rust | Pawel82S/text_adv | /src/ui.rs | UTF-8 | 910 | 2.53125 | 3 | [] | no_license | mod event_window;
mod simple_player_scr;
mod text_scr;
use crate::tiles;
use console_engine::{pixel, screen::Screen};
pub use event_window::EventWindow;
pub use simple_player_scr::SimplePlayerScr;
pub use text_scr::TextScr;
pub struct Size {
pub width: u32,
pub height: u32,
}
impl Size {
pub fn new(width... | true |
606a18a91582dd22e5d4a4d44a6675b02abcd97f | Rust | Enet4/dicom-rs | /pixeldata/src/encapsulation.rs | UTF-8 | 2,913 | 3.53125 | 4 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | //! DICOM Pixel encapsulation
//!
//! This module implements encapsulation for pixel data.
use dicom_core::value::fragments::Fragments;
use dicom_core::value::Value;
use std::vec;
/// Encapsulate the pixel data of a list of frames.
///
/// Check [Fragments] in case more control over the processing is required.
///
///... | true |
a219d4111a14917b74da48ad7bc380bb3262c9f6 | Rust | mgx0612/lottox | /src/lotto5/star5/star5_group_20.rs | UTF-8 | 1,298 | 3.171875 | 3 | [
"MIT"
] | permissive | use common::sum::{Sum, sum2};
use common::result::Outcome;
use lotto5;
pub struct Star5Group20 {
lists: Vec<Vec<u8>>,
total: usize,
}
impl Sum for Star5Group20 {
fn sum(&self) -> usize {
self.total
}
}
impl Star5Group20 {
pub fn init(lists: Vec<Vec<u8>>) -> Option<Star5Group20> {
... | true |
19fc72cf2371b5ffff08e06cc79b8994f9cd0786 | Rust | jsmall53/lineup_builder_rs | /builder/src/player_pool.rs | UTF-8 | 3,753 | 3.125 | 3 | [] | no_license | use std::collections::{ HashMap };
use std::collections::hash_map::Iter;
use crate::common::{ Player };
#[derive(Debug, Clone, Default)]
pub struct PlayerPool {
player_map: HashMap<u64, Player>,
name_map: HashMap<String, Vec<u64>>,
}
// TODO: contains a lot of cloning, figure out a better model to avoid exces... | true |
8a9afe16b151ec25e2b803e3757663630df7ac3a | Rust | vl4dimir/polumenta-rs | /src/main.rs | UTF-8 | 1,159 | 3.59375 | 4 | [] | no_license | extern crate rand;
use rand::Rng;
fn main() {
let elements0 = ["Б", "В", "Г", "Д", "Ђ", "Ж", "З", "Ј", "К", "Л", "Љ", "М", "Н", "Њ", "П", "Р",
"С", "Т", "Ћ", "Ф", "Х", "Ц", "Ч", "Џ", "Ш", "Б", "В", "Г", "Д", "Ђ", "Ж", "З",
"Ј", "К", "Л", "Љ", "М", "Н", "Њ", "П", "Р", "С", "Т", "Ћ", "Ф", "Х", "Ц", ... | true |
e442f4128da0bf92e63dc77e6b6006f8df55647f | Rust | Rexagon/exchange-aggregator | /src/prelude.rs | UTF-8 | 1,264 | 3.4375 | 3 | [
"Apache-2.0"
] | permissive | use hashbrown::HashMap;
#[derive(Debug, Serialize)]
pub struct Ticker {
pub ask: Option<String>,
pub bid: Option<String>,
pub last: Option<String>,
}
#[derive(Debug, Deserialize, Clone)]
pub struct CurrencyPair {
pub base: String,
pub quote: String,
}
impl ToString for CurrencyPair {
fn to_st... | true |
329b004d714a444aa3131c08d677fba5aed532d7 | Rust | royswale/leetcode | /src/bin/merge-sorted-array.rs | UTF-8 | 727 | 2.796875 | 3 | [
"MIT"
] | permissive | fn main() {}
struct Solution;
impl Solution {
pub fn merge(nums1: &mut Vec<i32>, m: i32, nums2: &mut Vec<i32>, n: i32) {
let (mut m, mut n) = (m - 1, n - 1);
for i in (0..nums1.len()).rev() {
if m < 0 {
nums1[i] = nums2[n as usize];
n -= 1;
}... | true |
70eef29244da6944548d86f8b2a273cb5625c7b4 | Rust | mithunkumarc/rustExamples | /projects/techniques/src/lib.rs | UTF-8 | 2,474 | 3.859375 | 4 | [] | no_license |
pub mod utilities {
// &Foo is a reference
// &Foo is not possible to be invalid or Null
// pub fn f(ptr: Option(&Foo)) {
// // either None or Something
// match ptr {
// Some(ptr) => ptr.g(),
// None => {}
// }
// }
// Result object wraps the value object... | true |
533583dcc09f67272e13db67deb593ce8465042e | Rust | qinxiaoguang/rs-lc | /src/solution/l148.rs | UTF-8 | 3,578 | 3.421875 | 3 | [] | no_license | use super::{ListNode, TreeNode};
pub struct Solution {}
/*
* @lc app=leetcode.cn id=148 lang=rust
*
* [148] 排序链表
*
* https://leetcode-cn.com/problems/sort-list/description/
*
* algorithms
* Medium (64.14%)
* Likes: 612
* Dislikes: 0
* Total Accepted: 71.9K
* Total Submissions: 108.9K
* Testcase Exam... | true |
924be7f46b3cfdf5245f452cc06b02a7b9baad11 | Rust | daumkuchen/study-nannou | /Playground/_sketch_01/src/main.rs | UTF-8 | 1,221 | 2.96875 | 3 | [] | no_license | use nannou::prelude::*;
fn main() {
nannou::app(model)
.update(update)
.run();
}
struct Model {
time: f32
}
fn model(app: &App) -> Model {
app.new_window()
.with_title("title")
.with_dimensions(512, 512)
.event(event)
.view(view)
.build()
... | true |
7baf8ccea24eef911c4f5dc14dc5f57220a821db | Rust | Purdue-SoCET/AFTx06-Rust-Libraries | /src/apb/pwm.rs | UTF-8 | 4,466 | 2.859375 | 3 | [] | no_license | use crate::common;
use volatile_register::{RW};
// PWM Construction Check
pub static mut PWM_CONSTRUCTED: bool = false;
// PWM Constants
pub const PWM: u32 = 0x80010000;
pub const PWM_PERIOD: u32 = PWM + 0x00;
pub const PWM_DUTY: u32 = PWM + 0x04;
pub const PWM_CON... | true |
bc9a07df0dec54f9bd9ac2ff18c8d84ea555df0d | Rust | marshalshi/caldav-client-rust | /src/dav_client.rs | UTF-8 | 1,802 | 2.515625 | 3 | [] | no_license | use minidom::Element;
use reqwest::header::CONTENT_TYPE;
use reqwest::{Client, Method, Result};
use url::Url;
use crate::principal::Principal;
use crate::settings;
use crate::utils::find_elem;
static DAVCLIENT_BODY: &str = r#"
<d:propfind xmlns:d="DAV:">
<d:prop>
<d:current-user-principal />
... | true |
29055d35b68c0c0b327e73cce95235aa3d4ceac2 | Rust | m1el/advent-of-code | /2018/d14_it.rs | UTF-8 | 1,598 | 3.359375 | 3 | [
"MIT"
] | permissive | struct RecipeIter {
items: Vec<u8>,
p1: usize,
p2: usize,
pos: usize,
}
impl RecipeIter {
fn new() -> RecipeIter {
RecipeIter {
items: vec![3, 7],
p1: 0,
p2: 1,
pos: 0,
}
}
}
impl Iterator for RecipeIter {
t... | true |
5918e081b7ac26f6632d739dbb3b997206b32e14 | Rust | zaynetro/mkslides | /src/main.rs | UTF-8 | 1,495 | 2.796875 | 3 | [
"MIT"
] | permissive | // TODO: open questions
// * How can we add presentation notes?
use std::fs::File;
use std::io::prelude::*;
use std::io::BufReader;
use std::path::Path;
use orgize::Org;
mod error;
mod handler;
use error::SlidesError;
use handler::SlidesHtmlHandler;
const STYLES: &'static str = include_str!("../assets/styles.css")... | true |
05cbe6a5f841c92f85830b05dc663832e8fd5482 | Rust | slackmagic/void-varint | /src/varint64.rs | UTF-8 | 1,119 | 3.0625 | 3 | [] | no_license | use crate::Varint;
impl Varint for u64 {
fn read_varint(bytes: &[u8]) -> Option<(u64, usize)> {
type ReturnType = u64;
let mut ret = 0 as ReturnType;
let mut shift = 0;
let nb_bytes_to_read = Self::msb_detect(&bytes);
for byte in bytes[0..nb_bytes_to_read].iter() {
... | true |
45f6fccbdede16a7b48568209b64f691274ad277 | Rust | rusticata/asn1-rs | /tests/run-pass/der_sequence_optional.rs | UTF-8 | 1,663 | 3.15625 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use asn1_rs::*;
use hex_literal::hex;
// XXX limitation:
// when OPTIONAL only (and not tagged), parser is eager:
// if there are several values of the same type, the first one
// goes to the OPTIONAL value (and will fail if the next value is not present and mandatory)
#[derive(Debug, PartialEq, DerSequence)]
/... | true |
ca15108e856ed975b56909444b0a62d79a7ac35f | Rust | tokio-rs/tracing | /examples/examples/fmt-custom-field.rs | UTF-8 | 1,657 | 3.609375 | 4 | [
"MIT"
] | permissive | //! This example demonstrates overriding the way `tracing-subscriber`'s
//! `FmtSubscriber` formats fields on spans and events, using a closure.
//!
//! We'll create a custom format that prints key-value pairs separated by
//! colons rather than equals signs, and separates fields with commas.
//!
//! For an event like
... | true |
73aa4a7cbd855d4914a57f2f94a5e9d1f2dcd823 | Rust | TroyNeubauer/aoc2020 | /src/day15/a.rs | UTF-8 | 1,996 | 3.203125 | 3 | [] | no_license | use std::collections::HashMap;
use std::io::Read;
#[test]
fn test4() {
assert_eq!(execute(vec!(0, 3, 6), 4), 0);
}
#[test]
fn test5() {
assert_eq!(execute(vec!(0, 3, 6), 5), 3);
}
#[test]
fn test6() {
assert_eq!(execute(vec!(0, 3, 6), 6), 3);
}
#[test]
fn test7() {
assert_eq!(execute(vec!(0, 3, ... | true |
ab49e96a9ba369ab72a767a06baf5412b1f53a05 | Rust | ykafia/AnLys | /src/backend/base_arrays/array_traits.rs | UTF-8 | 2,579 | 2.703125 | 3 | [] | no_license | use super::*;
use num::{Float,Integer};
// pub trait ToGenerics {
// fn to_generic(&self) -> GenericNumArray;
// }
// impl ToGenerics for I32Array{
// fn to_generic(&self) -> GenericNumArray {
// GenericNumArray::I32(self.clone())
// }
// }
// impl ToGenerics for F32Array{
// fn to_generic(&se... | true |
febd59723ff93a449d6c34e6a795e5886bf04f4e | Rust | baconator/advent-of-code-2017 | /src/day3.rs | UTF-8 | 2,325 | 3.1875 | 3 | [] | no_license | use std::collections::HashMap;
use std::cmp;
const DIRECTIONS: [(i32, i32); 4] = [(1, 0), (0, 1), (-1, 0), (0, -1)];
const NEIGHBOURS: [(i32, i32); 8] = [(1, 0), (0, 1), (-1, 0), (0, -1), (-1, 1), (1, 1), (-1, -1), (1, -1)];
struct SpiralIterator {
state: u32,
count: u32,
row: u32,
position: (i32, i32)
}
impl I... | true |
583f164c86cc848d312050232ed1b26372d3342b | Rust | TheDan64/advent_of_code | /src/day7.rs | UTF-8 | 2,973 | 3.265625 | 3 | [] | no_license | use std::collections::HashMap;
use std::path::{Path, PathBuf};
use aoc_runner_derive::aoc;
enum Cmd<'s> {
Cd(&'s str),
Ls,
}
enum Line<'s> {
Cmd(Cmd<'s>),
Dir(&'s str),
File(&'s str, u32),
}
struct Directory<'s> {
dirs: Vec<&'s str>,
files: Vec<(&'s str, u32)>,
}
fn filesystem<'s>(input... | true |
3d7aca4de44b211867366de32c6f56855bd66510 | Rust | wgwoods/atsamd | /pac/atsamd51j19a/src/sercom0/spi/length.rs | UTF-8 | 2,001 | 2.609375 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #[doc = "Reader of register LENGTH"]
pub type R = crate::R<u16, super::LENGTH>;
#[doc = "Writer for register LENGTH"]
pub type W = crate::W<u16, super::LENGTH>;
#[doc = "Register LENGTH `reset()`'s with value 0"]
impl crate::ResetValue for super::LENGTH {
type Type = u16;
#[inline(always)]
fn reset_value() ... | true |
4312641f1d55958b479cef4d15b6cde5247fed93 | Rust | mzmttks/learning_rust | /chap02-17/src/main.rs | UTF-8 | 483 | 2.921875 | 3 | [
"MIT"
] | permissive | use std::fs::File;
use std::io::prelude::*;
fn main() {
let mut handle = File::open("../hightemp.txt").unwrap();
let mut content = String::new();
handle.read_to_string(&mut content).unwrap();
let mut uniques = Vec::new();
for line in content.trim().split("\n") {
let first: &str = line.spli... | true |
8d3aa816da6139f2564a3eb7b8412af124ad9a7b | Rust | icub3d/puzzles | /leetcode/reverse-linked-list/src/lib.rs | UTF-8 | 1,162 | 3.8125 | 4 | [
"MIT"
] | permissive | #[derive(PartialEq, Eq, Clone, Debug)]
pub struct ListNode {
pub val: i32,
pub next: Option<Box<ListNode>>,
}
impl ListNode {
pub fn from(vals: &[i32]) -> Option<Box<ListNode>> {
if vals.len() < 1 {
None
} else {
Some(Box::new(ListNode {
val: vals[0],... | true |
933d8a28adf8f9110b212c83fab3fac26c7f0f7e | Rust | jobdeng/rucene | /src/core/util/byte_slice_reader.rs | UTF-8 | 4,948 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2019 Zhizhesihai (Beijing) Technology Limited.
//
// 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 a... | true |
dd2806e23d0345af0e4f954f54bd96517b20ee7d | Rust | 0ncorhynchus/tweet.rs | /src/main.rs | UTF-8 | 3,952 | 2.96875 | 3 | [
"MIT"
] | permissive | use percent_encoding::{utf8_percent_encode, AsciiSet, NON_ALPHANUMERIC};
use rand::distributions::Alphanumeric;
use rand::{thread_rng, Rng};
use reqwest::header;
use serde::Deserialize;
use std::collections::HashMap;
use std::time::{SystemTime, SystemTimeError};
use url::Url;
const UPDATE_URL: &'static str = "https://... | true |
72b60d84c91ab886514d3d9ca9a810dc6b04f1cd | Rust | Lighty0410/srt-rs | /srt-tokio/tests/accesscontrol.rs | UTF-8 | 4,016 | 2.609375 | 3 | [
"Apache-2.0"
] | permissive | use bytes::Bytes;
use futures::{channel::oneshot, future::join_all, stream, FutureExt, SinkExt, StreamExt};
use log::info;
use srt_protocol::{
accesscontrol::{
AcceptParameters, AccessControlList, StandardAccessControlEntry, StreamAcceptor,
},
packet::{RejectReason, ServerRejectReason},
};
use srt_t... | true |
d10aa3cc2b0f74f01b0954633ee8f8b98c9624c2 | Rust | ashwins93/rusty-knowledge | /intro/functions.rs | UTF-8 | 320 | 3.8125 | 4 | [] | no_license | fn add(a: u64, b: u64) -> u64 {
a + b
}
fn increase_by(mut val: u32, how_much: u32) {
val += how_much;
println!("You made {} points", val);
}
fn main() {
let a: u64 = 17;
let b = 3;
let result = add(a, b);
println!("Result {}", result);
let score = 2048;
increase_by(score, 30);
}
| true |
1a57072bed55c396b081687906564c2f49236507 | Rust | dennisss/dacha | /pkg/graphics/src/raster/canvas_render_loop.rs | UTF-8 | 3,316 | 2.609375 | 3 | [
"Apache-2.0"
] | permissive | use alloc::rc::Rc;
use common::errors::*;
use glfw::WindowEvent;
use math::matrix::{Vector2f, Vector2i, Vector3f};
use crate::canvas::Canvas;
use crate::opengl::app::Application;
use crate::opengl::polygon::Polygon;
use crate::opengl::shader::*;
use crate::opengl::texture::Texture;
use crate::opengl::window::Window;
... | true |
5e50b2f5b4a522eba833abd72303edf45800e7a7 | Rust | belltoy/flv_codec | /src/video.rs | UTF-8 | 2,419 | 2.875 | 3 | [
"MIT"
] | permissive | use bytecodec::{ErrorKind, Result};
/// Video codec identifier.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum CodecId {
/// JPEG (currently unused)
Jpeg = 1,
/// Sorenson H.263
H263 = 2,
/// Screen Video
ScreenVideo = 3,
/// On2 VP6
Vp6 = 4,
/// On2 VP6 with alpha ... | true |
423abb9333b3f2dc56c0a25a593e19f01f21a357 | Rust | notify-rs/notify | /examples/monitor_raw.rs | UTF-8 | 1,115 | 2.75 | 3 | [
"CC0-1.0",
"MIT",
"Apache-2.0",
"LicenseRef-scancode-public-domain"
] | permissive | use notify::{Config, RecommendedWatcher, RecursiveMode, Watcher};
use std::path::Path;
fn main() {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();
let path = std::env::args()
.nth(1)
.expect("Argument 1 needs to be a path");
log::info!("Watching... | true |
9af3f1e2f803e7d2740040784a59b3f184a56d55 | Rust | ferambot/slc | /src/compiler.rs | UTF-8 | 3,233 | 2.5625 | 3 | [] | no_license | // Copyright (c) 2015, Sam Payson
//
// 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, copy, modify, merge, publish, dis... | true |
8b9b31cd2c71b13804ff042bdb5e07ccd7098146 | Rust | atoav/bender-job | /src/job.rs | UTF-8 | 26,890 | 2.921875 | 3 | [
"MIT"
] | permissive | //! The job is the core data structure holding all information, including paths, \
//! job history, job status, tasks, etc. For details check the Job Struct.
use ::*;
use std::path::Path;
use atomicwrites::{AtomicFile, AllowOverwrite};
use std::io::Write;
#[cfg(unix)]
use std::os::unix::fs::PermissionsExt;
// ======... | true |
940379662fbc83bfe892f8c538a2ec389670bced | Rust | crosstyan/mican | /src/commands/other.rs | UTF-8 | 713 | 2.765625 | 3 | [
"MIT"
] | permissive | use token::{CommandData, Input, Output};
use std::process::{Command, Stdio};
pub fn run(cmd: CommandData) -> Result<(), String> {
let mut output = match Command::new(&cmd.program)
.args(&cmd.options)
.stdin(match cmd.input.unwrap() {
Input::Stdin(_) => Stdio::inherit(),
Inp... | true |
90da88392e11732e389d31b3ce8ad04634d6ba62 | Rust | bumblepie/advent-of-code-2018 | /day-4/part-2/src/main.rs | UTF-8 | 2,074 | 2.859375 | 3 | [] | no_license | extern crate chrono;
extern crate lazy_static;
extern crate regex;
extern crate itertools;
use std::env;
use std::fs::File;
use std::io::prelude::*;
use std::io::BufReader;
use std::process;
mod lib;
fn main() -> Result<(), Box<std::error::Error>> {
let args: Vec<String> = env::args().collect();
let filename... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.