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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
b6914daec863b205423fc382741fb6ee1b3eb248 | Rust | Cronnay/adventofcode2020 | /src/day1/main.rs | UTF-8 | 1,476 | 3.609375 | 4 | [] | no_license | use std::env;
fn main() {
let mut file: String = String::new();
for args in env::args() {
file = args;
}
let contents = std::fs::read_to_string(file).expect("Could not load file");
let mut all_inputs: Vec<i32> = Vec::new();
for line in contents.lines() {
if let Ok(parsed) = lin... | true |
a902a3fd9098ba7f8b99d42fac9e6bfd19063571 | Rust | Schr3da/wasm-map-generator-demo | /src/renderer/top_down_utils.rs | UTF-8 | 4,370 | 2.5625 | 3 | [
"Apache-2.0"
] | permissive | use sdl2::render::{Canvas, RenderTarget, BlendMode, TextureCreator, Texture};
use sdl2::rect::{Rect};
use sdl2::video::{WindowContext};
use light::circle::{Circle};
use light::intensity::{calculate_light_intensity};
use scenes::game::{Game};
use scenes::layer::{Renderable};
use constants::{window, tile, player};
use en... | true |
8fa67bb42472df6daa87f5f915d6b4479ae7710a | Rust | rpjohnst/dejavu | /gml/src/vm/code.rs | UTF-8 | 4,879 | 3.0625 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-free-unknown"
] | permissive | use std::{u8, mem, fmt};
use crate::symbol::Symbol;
use crate::vm;
pub struct Function {
pub params: u32,
pub locals: u32,
pub symbols: Vec<Symbol>,
pub constants: Vec<vm::Value>,
pub instructions: Vec<Inst>,
}
impl Function {
pub fn new() -> Function {
Function {
params: ... | true |
611158888466959b493e5d7d8e05f12d5ef7dc40 | Rust | kroeckx/ruma | /crates/ruma-client-api/src/r0/device/get_device.rs | UTF-8 | 1,060 | 2.90625 | 3 | [
"MIT"
] | permissive | //! [GET /_matrix/client/r0/devices/{deviceId}](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-devices-deviceid)
use ruma_api::ruma_api;
use ruma_identifiers::DeviceId;
use super::Device;
ruma_api! {
metadata: {
description: "Get a device for authenticated user.",
method: ... | true |
eb74f2726e5b295a2326e11b478c666d3bbf7948 | Rust | derekdreery/str_windows-rs | /src/lib.rs | UTF-8 | 2,087 | 3.984375 | 4 | [
"MIT",
"Apache-2.0"
] | permissive |
/// Returns substrings of length `size`, similar to `slice::windows`.
///
/// # Examples
///
/// ```
/// use str_windows::str_windows;
///
/// let input = "s ππ";
/// let mut iter = str_windows(input, 3);
/// assert_eq!(iter.next(), Some("s π"));
/// assert_eq!(iter.next(), Some(" ππ"));
/// assert!(iter.next().... | true |
60358201fb896d3094593cb7bf6d75cca66b819e | Rust | alfredtso/ostep-code | /intro/intro/src/lib.rs | UTF-8 | 864 | 3.09375 | 3 | [] | no_license | use std::sync::Arc;
use std::sync::Mutex;
use std::thread::sleep;
use std::time::Duration;
use std::process;
use std::thread;
/// Use sleep
pub fn spin(t: u64) {
sleep(Duration::new(t, 0));
}
pub fn mem(t: &u32) {
let pid = process::id();
println!("{} value of p: {}", pid, &t);
}
pub fn mythreads(l: u32)... | true |
56663b8d31977c7e6d731bdaa933e46e7970768a | Rust | njeisecke/umya-spreadsheet | /src/structs/drawing/charts/page_margins.rs | UTF-8 | 2,412 | 2.6875 | 3 | [
"MIT"
] | permissive | // c:pageMargins
use writer::driver::*;
use reader::driver::*;
use quick_xml::Reader;
use quick_xml::events::{BytesStart};
use quick_xml::Writer;
use std::io::Cursor;
#[derive(Default, Debug)]
pub struct PageMargins {
bottom: String,
left: String,
right: String,
top: String,
header: String,
foo... | true |
26fa42ad9eb23ee36aad95cfb80a5fdd20411861 | Rust | joshuabenuck/tarnish | /src/util.rs | UTF-8 | 1,327 | 3.234375 | 3 | [
"MIT"
] | permissive | use std::path::{PathBuf};
use std::fs::{File};
use std::io::{Read, Write, Error};
use url::{Url, ParseError};
pub fn create_file(name: PathBuf, contents: &str) -> Result<(), Error> {
println!("Creating file: {}", name.display());
File::create(name)?
.write(contents.as_bytes())?;
Ok(())
}
pub fn co... | true |
e5490ed1198de125cdcad4a55f987eff52ce8271 | Rust | heepster/key-configurator | /src/kb_in.rs | UTF-8 | 2,649 | 3.0625 | 3 | [] | no_license | use std::{fs::{self,File}, io::Error};
use evdev_rs::{Device, InputEvent, enums::{EV_KEY, EventCode, EventType}};
use evdev_rs::ReadFlag;
pub struct KeyboardInput {
device: Box<Device>
}
#[derive(PartialEq, Debug, Clone, Copy)]
pub enum KeyValue {
On,
Off,
Hold
}
type KeyCode = EV_KEY;
#[derive(Part... | true |
20119805975ddcf1f1e00a5e242de920091826fa | Rust | FauxFaux/wcwidth.rs | /tests/lib.rs | UTF-8 | 1,057 | 2.9375 | 3 | [
"MIT"
] | permissive | extern crate wcwidth;
const N: Option<u8> = None;
const S0: Option<u8> = Some(0);
const S1: Option<u8> = Some(1);
const S2: Option<u8> = Some(2);
const STRING_TESTS: &[(&str, &[Option<u8>], Option<usize>)] = &[
("γ³γ³γγγ, γ»γ«γ€!", &[S2, S2, S2, S2, S2, S1, S1, S2, S2, S2, S1], Some(19)),
("abc\x00def", &[S1, S1, ... | true |
9b8e803eb5bbbbe3631615a6f5e60594211274c5 | Rust | PickledChair/RustyMonkey | /src/parser/parser_test.rs | UTF-8 | 39,301 | 3.0625 | 3 | [
"MIT"
] | permissive | use crate::{ast::*, lexer::*};
use super::*;
use std::env;
#[test]
fn test_let_statements() {
let tests = [
("let x = 5;", Expected::Str("x".to_string()), Expected::Int64(5)),
("let y = true;", Expected::Str("y".to_string()), Expected::Bool(true)),
("let foobar = y;", Expected::Str("foobar... | true |
1a5ae5270729430b238c1d9619e45058e16c88b8 | Rust | casperin/algorithms_rust | /src/graph/kruskal.rs | UTF-8 | 3,443 | 3.59375 | 4 | [] | no_license | use super::weighted_graph::WeightedGraph;
use std::collections::HashMap;
impl WeightedGraph {
/// Implementation of [Kruskal's
/// algorithm](https://en.m.wikipedia.org/wiki/Kruskal%27s_algorithm) for finding a minimum
/// spanning tree (MST) in a undirected weighted graph.
///
/// ```
/// let ... | true |
26ef077359aa41e58005fdc29e1e188d5b3dfffc | Rust | erenoku/Figment | /src/util.rs | UTF-8 | 10,784 | 3.25 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! Useful functions and macros for writing figments.
//!
//! # `map!` macro
//!
//! The `map!` macro constructs a [`Map`](crate::value::Map) from key-value
//! pairs and is particularly useful during testing:
//!
//! ```rust
//! use figment::util::map;
//!
//! let map = map! {
//! "name" => "Bob",
//! "age" =>... | true |
bcea7cbbe237fd0072ee06bb1a6ff4880ede781b | Rust | Byron/gitoxide | /gix-hashtable/src/lib.rs | UTF-8 | 3,690 | 3.015625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! Customized `HashMap` and Hasher implementation optimized for using `ObjectId`s as keys.
//!
//! The crate mirrors `std::collections` in layout for familiarity.
#![deny(missing_docs, rust_2018_idioms)]
#![forbid(unsafe_code)]
use gix_hash::ObjectId;
pub use hashbrown::{hash_map, hash_set, raw, Equivalent};
/// thr... | true |
41890faaa476e5191ebcfba8cf5ab02210599017 | Rust | Oskang09/obsidian | /src/context.rs | UTF-8 | 12,420 | 2.96875 | 3 | [
"MIT"
] | permissive | use futures::{Future, Stream};
use serde::de::DeserializeOwned;
use url::form_urlencoded;
use std::borrow::Cow;
use std::collections::HashMap;
use std::convert::From;
use std::str::FromStr;
use crate::router::from_cow_map;
use crate::ObsidianError;
use crate::{header::HeaderValue, Body, HeaderMap, Method, Request, Ur... | true |
21509ba0aa5944a5d92ded594e1eef19f5e93770 | Rust | luke-titley/imgui-docking-rs | /src/context.rs | UTF-8 | 17,577 | 2.796875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use parking_lot::ReentrantMutex;
use std::cell::RefCell;
use std::ffi::CStr;
use std::ops::Drop;
use std::path::PathBuf;
use std::ptr;
use std::rc::Rc;
use crate::clipboard::{ClipboardBackend, ClipboardContext};
use crate::fonts::atlas::{FontAtlas, FontAtlasRefMut, FontId, SharedFontAtlas};
use crate::io::Io;
use crat... | true |
9af70a8390506dd25d69773b11eee81b3b5cdb4d | Rust | Goodjooy/QQBotMsgTemplateEngine | /src/anaylze/syntax/expr/caculate.rs | UTF-8 | 5,647 | 2.90625 | 3 | [] | no_license | use crate::anaylze::{
lexical::expr::{ExprIter, ExprLexical},
syntax::{LoadErr, LoadStatus, SyntaxLoadNext},
PreviewIter, SignTableHandle,
};
use super::{nil_sign, Caculate, Item, SubCaculate};
impl<'a, S> SyntaxLoadNext<'a, ExprIter<'a, S>, ExprLexical> for SubCaculate
where
S: SignTableHandle,
{
... | true |
47f05c5b3915d4790a21abdcb99359f31085547a | Rust | bandprotocol/bandchain | /obi/obi-rs/obi/src/schema.rs | UTF-8 | 5,716 | 3.484375 | 3 | [
"Apache-2.0"
] | permissive | //! The important components are: `OBISchema` trait, `Definition` and `Declaration` types
//! * `OBISchema` trait allows any type that implements it to be self-descriptive, i.e. generate it's own schema;
//! * `Declaration` is used to describe the type identifier, e.g. `[u64]`;
//! * `Definition` is used to describe th... | true |
37f92bafe9aea882a759ffefb714d7bfcdd1d6f4 | Rust | jemstep/captain-git-hook | /src/gpg.rs | UTF-8 | 3,307 | 2.78125 | 3 | [
"Apache-2.0"
] | permissive | use crate::error::CapnError;
use crate::keyring::Keyring;
use std::collections::HashSet;
use std::error::Error;
use std::process::*;
use std::time::Instant;
use log::*;
use rayon::prelude::*;
pub trait Gpg {
fn receive_keys(
&self,
keyring: &mut Keyring,
emails: &HashSet<&str>,
) -> Re... | true |
3cf4dcebf4dc618b5bfa81930a50cd67f3b5a3e9 | Rust | YZITE/futures | /crates/codec/src/codec/limit.rs | UTF-8 | 4,993 | 3.078125 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #![allow(missing_docs)]
use super::{Decoder, Encoder, EncoderError};
use bytes::{Buf, BytesMut};
pub trait SkipAheadHandler: Sized + std::fmt::Debug {
/// This method skips chunks of content until the beginning
/// of the next message is found.
/// `Self` may contain additional state, like the an amount
... | true |
d89d92c1ca8b8456eb0d32bc59c0383e19b7e0a9 | Rust | arnohub/vertex | /src/transforms/mod.rs | UTF-8 | 2,629 | 2.984375 | 3 | [
"Apache-2.0"
] | permissive | #[cfg(feature = "transforms-add_fields")]
mod add_fields;
#[cfg(feature = "transforms-add_tags")]
mod add_tags;
mod ansii_striper;
mod aggregate;
#[cfg(feature = "transforms-cardinality")]
mod cardinality;
mod filter;
mod geoip;
mod grok_parser;
mod jsmn_parser;
mod json_parser;
mod logfmt_parser;
mod rename_fields;
... | true |
b09caabc9f9176a8d13e4c976b8735f1f1ea6862 | Rust | jix/partial_ref | /partial_ref/src/macros.rs | UTF-8 | 6,518 | 2.953125 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | /// Declares a [`Part`].
///
/// Defines an empty struct type and derives all necessary instances to use it as a marker type for
/// parts.
///
/// This macro can define [`AbstractPart`]s using `part!(PartName);` or `part!(pub PartName);` and
/// [`Field`] parts using `part!(PartName: FieldType);` or `part!(pub PartNam... | true |
2947b385dd42228d68554449f3119aec1aa9290c | Rust | lassade/toctoc | /src/json/number.rs | UTF-8 | 229 | 2.953125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | /// A JSON number represented by some Rust primitive.
#[derive(Clone, Debug, PartialEq)]
pub enum Number {
U64(u64),
I64(i64),
F32(f32), // * MOD: Single precision to avoid casting between f32 and f64
F64(f64),
}
| true |
efaaa44464faf2f77e5968e53e9da9d0bb4cdb5d | Rust | aaharu/gifken | /crate/src/lib.rs | UTF-8 | 3,132 | 2.625 | 3 | [
"MIT"
] | permissive | mod utils;
use image::codecs::gif::{GifDecoder, GifEncoder, Repeat};
use image::{AnimationDecoder, Frame, ImageError};
use js_sys::{Array, Error, Uint8Array};
use std::vec::Vec;
use wasm_bindgen::prelude::*;
// #[wasm_bindgen]
// extern "C" {
// // Access console.log() from the wasm module
// #[wasm_bindgen(j... | true |
8e3b57a6ac5be30f10afd6699e2a32bc48a6ae56 | Rust | fplust/rlox | /src/environment.rs | UTF-8 | 4,178 | 3.234375 | 3 | [] | no_license | use crate::interpreter::{RTResult, RuntimeException};
use crate::object::Object;
use crate::token::Token;
use std::collections::HashMap;
// use std::borrow::{Borrow, BorrowMut};
use gc::{Gc, GcCell};
use gc_derive::{Finalize, Trace};
use std::ops::Deref;
#[derive(Trace, Finalize, Debug)]
pub struct Env {
enclosing... | true |
8a5fae99bc5a4a5dad9c9734af8b4ce17c5cb28a | Rust | fesm0750/advent_of_code_2020 | /src/helpers/base2d.rs | UTF-8 | 1,005 | 3.828125 | 4 | [] | no_license | use std::{
convert::{TryFrom, TryInto},
error::Error,
};
/// Helper struct for representing 2d values, i.e: coordinates, indexes, etc.
#[derive(Copy, Clone, Debug)]
pub struct Base2d<U> {
pub x: U,
pub y: U,
}
impl<U> Base2d<U>
where
U: Copy,
{
/// Constructs a new Base2d
pub fn new(x: U, ... | true |
920901b30535388c4f5623ebe15d106954dc3316 | Rust | simonbuchan/rust-jwt | /src/legacy/claims.rs | UTF-8 | 1,938 | 3.0625 | 3 | [
"MIT"
] | permissive | use serde_json::Value as Json;
use std::collections::BTreeMap;
#[deprecated(note = "Please use jwt::Claims instead")]
#[derive(Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct Claims {
#[serde(flatten)]
pub reg: Registered,
#[serde(flatten)]
pub private: BTreeMap<String, Json>,
}
#[depre... | true |
e21eabfd21581f816ef0e5edf21e21329a53d884 | Rust | muchobien/porkbun-rs | /src/porkbun.rs | UTF-8 | 5,090 | 2.796875 | 3 | [
"MIT"
] | permissive | use crate::{api, auth::Auth};
use async_trait::async_trait;
use bytes::Bytes;
use http::Response as HttpResponse;
use log::{debug, error};
use reqwest::{blocking::Client, Client as AsyncClient};
use serde_json::{Map, Value};
use std::{
convert::TryInto,
fmt::{self, Debug},
};
use thiserror::Error;
use url::Url;... | true |
5a5b1e6403be139efdfcec22cbed9021cbbe2534 | Rust | s3bk/weakset | /src/weakset.rs | UTF-8 | 7,040 | 3.671875 | 4 | [] | no_license | /*
π WeakSet π
requirements:
- owned storage
- iteration over the items
- immediate deltion of dropped items
optional:
- fast iteration
- continuous memory
observations:
- the set owns the values, so they cannot be inserted in another set
- the references need to reference the set in or... | true |
625e83d4744a27056e7bde83273da5c4f13649e8 | Rust | Builditluc/blue-db | /src/bin/write_entry.rs | UTF-8 | 736 | 3.171875 | 3 | [] | no_license | use blue_db::Blue;
use std::io::{stdin, Read};
fn main() {
let blue = Blue::new();
println!("Please enter the title of the new entry");
let mut title = String::new();
stdin().read_line(&mut title).unwrap();
let title = &title[..(title.len() - 1)];
println!("Ok! Now write {} (Press CTRL+D when ... | true |
b8ba7d8f7b6d69d12c3a240849a3ada87f14dc2a | Rust | xDarksome/lg-webos-client | /src/command/mod.rs | UTF-8 | 7,382 | 2.671875 | 3 | [
"MIT"
] | permissive | use serde::Serialize;
use serde_json::{json, Value};
#[derive(Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CommandRequest {
id: u8,
r#type: String,
uri: String,
payload: Option<Value>,
}
pub enum Command {
CreateToast(String),
OpenBrowser(String),
TurnOff,
SetChannel(Strin... | true |
a094f0bf229851c4d6dfdc5942303ab4161a1fde | Rust | nk-designz/kyward.rs | /kyward-ui/src/pages/door.rs | UTF-8 | 20,513 | 2.78125 | 3 | [] | no_license | use super::super::models::door::Door;
use super::super::utils::new_hero;
use serde_json::json;
use ybc::TileCtx::{Child, Parent};
use yew::format::{Json, Nothing};
use yew::prelude::*;
use yew::services::console::ConsoleService;
use yew::services::fetch::FetchService;
use yew::services::fetch::{FetchTask, Request, Resp... | true |
bf6b10485c5d712c8d6b12b52b7605dd08cae041 | Rust | stefane81/rust-book | /ch07/use_keyword_74/src/lib.rs | UTF-8 | 471 | 2.859375 | 3 | [] | no_license | use std::fmt::Result;
use std::io::Result as IoResult;
fn function1() -> Result {
Ok(())
}
fn function2() -> IoResult<()> {
Ok(())
}
mod front_of_house {
pub mod hosting {
pub fn add_to_waitlist() {}
}
}
// static path
// use crate::front_of_house::hosting;
// relative path
use self::front_... | true |
207416ba2aac6f1e78efa6a2a1725d99cffc0f5b | Rust | Matrix-Zhang/tokio_kcp | /src/stream.rs | UTF-8 | 6,942 | 2.671875 | 3 | [
"MIT"
] | permissive | use std::{
fmt::{self, Debug},
io::{self, ErrorKind},
net::{IpAddr, SocketAddr},
pin::Pin,
sync::Arc,
task::{Context, Poll},
};
use futures::{future, ready};
use kcp::{Error as KcpError, KcpResult};
use log::trace;
use tokio::{
io::{AsyncRead, AsyncWrite, ReadBuf},
net::UdpSocket,
};
u... | true |
3599d7ac991e5860061f6a281b89767bdfba1498 | Rust | emabee/rust-hdbconnect | /hdbconnect_impl/src/protocol/parts/write_lob_reply.rs | UTF-8 | 1,160 | 2.515625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use crate::HdbResult;
#[cfg(feature = "sync")]
use byteorder::{LittleEndian, ReadBytesExt};
#[derive(Debug)]
pub struct WriteLobReply {
locator_ids: Vec<u64>,
}
impl WriteLobReply {
pub fn into_locator_ids(self) -> Vec<u64> {
self.locator_ids
}
}
impl WriteLobReply {
#[cfg(feature = "sync")]
... | true |
76903af5bc88a507216e484eb7023b1403efa0d6 | Rust | sajuthankappan/urlshortener-rs | /src/services/url_manager.rs | UTF-8 | 812 | 2.8125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use urlshortener_core::models;
use urlshortener_core::errors;
use urlshortener_data::repository::UrlRepository;
pub struct UrlManager;
impl UrlManager {
pub fn new() -> UrlManager {
UrlManager
}
pub fn find_one(&self, alias: String) -> Option<models::Url> {
UrlRepository::new().find_one(a... | true |
672546d0af9d817609831eefa1da83617b807e5b | Rust | shabadrohithans/algorithm-playground | /old/rust-exercises/dummyclient/src/mockstream.rs | UTF-8 | 1,247 | 3.40625 | 3 | [
"MIT"
] | permissive | #[derive(Debug, Clone)]
pub struct MockStream {
pub message: Vec<u8>,
pub current: usize,
}
impl MockStream {
pub fn new(m: &str) -> Self {
MockStream { message: m.to_string().into_bytes(), current: 0 }
}
pub fn next(&mut self) -> u8 {
if self.current < self.message.len() {
... | true |
d3b60573b555ebc6312f11fa2e56a86d6fee439a | Rust | Jacobious52/AdventOfCode2020 | /src/bin/day06.rs | UTF-8 | 1,632 | 3.09375 | 3 | [] | no_license | use advent_of_code_2020::advent::util;
use std::collections::HashSet;
fn main() {
color_backtrace::install();
let input = include_str!("../../inputs/6.1.txt");
let groups: Vec<_> = input.split("\n\n").collect();
println!("part01: {}", part01(&groups));
println!("part02: {}", part02(&groups));
}
f... | true |
5ce8600fa2be6782ac5d6abfb2421f1398e75bc0 | Rust | pocket7878/zen | /zenhub-api/src/issue_repository.rs | UTF-8 | 3,615 | 2.84375 | 3 | [] | no_license | extern crate serde_json;
use crate::client::Client;
use serde::Deserialize;
use serde_json::Value;
use std::error::Error;
use std::fmt;
pub struct IssueRepository {
api_token: String,
}
#[derive(Debug, Deserialize)]
pub struct Event {
user_id: i32,
#[serde(rename = "type")]
event_type: EventType,
... | true |
eb9425952dd10dcb3abc33f2ad7e36c601cc8734 | Rust | Sintrastes/pure-prolog-rs | /src/tree.rs | UTF-8 | 2,435 | 3.28125 | 3 | [
"MIT"
] | permissive |
use std::iter::*;
use derive_more::{Display};
#[derive(Display)]
pub enum Tree<B, A> {
Node(A),
#[display(fmt = "Branch({})", _0)]
Branch(B, Box<dyn Iterator<Item = Tree<B,A>>>),
}
#[derive(Clone)]
pub enum MyIterator<A> {
Done,
Continue(Chain<Once<A>, Box<MyIterator<A>>>)
}
impl <A> Iterator fo... | true |
5d45dd8b86ab128632ea810b633793ab0c3b403d | Rust | vertexclique/amadeus | /amadeus-core/src/into_dist_iter/collections.rs | UTF-8 | 6,417 | 2.53125 | 3 | [
"Apache-2.0"
] | permissive | use owned_chars::{OwnedChars as IntoChars, OwnedCharsExt};
use std::{
collections::{
binary_heap, btree_map, btree_set, hash_map, hash_set, linked_list, vec_deque, BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque
}, hash::{BuildHasher, Hash}, iter, option, result, slice, str, vec
};
use super... | true |
bcb1dda0aa65ac6e1c06dae8004bd68232dfc18f | Rust | EzgiS/rust-ncc | /rust-ncc-main/src/math/geometry.rs | UTF-8 | 25,081 | 2.671875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | // Copyright Β© 2020 Brian Merchant.
//
// 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
// except accordi... | true |
56300a7abf705357d0c82cbce6a9e81ee49639b4 | Rust | pourplusquoi/learn-rust | /leetcode/1366.rs | UTF-8 | 741 | 3.078125 | 3 | [] | no_license | use std::collections::HashMap;
impl Solution {
pub fn rank_teams(votes: Vec<String>) -> String {
let n = votes[0].len();
let mut map = HashMap::new();
for vote in votes.iter() {
for (i, team) in vote.chars().enumerate() {
let vec = map.entry(team).or_insert(vec![0; n]);
vec[i] += 1;... | true |
17d0b3adbe80d7e88ccc6c9b882e476463ae38cc | Rust | shalzz/exercism | /rust/triangle/src/lib.rs | UTF-8 | 1,050 | 3.703125 | 4 | [] | no_license | use std::cmp::Ordering;
#[derive(PartialEq)]
pub enum Triangle {
Equilateral,
Scalene,
Isosceles,
}
impl Triangle {
pub fn build<T>(mut sides: [T; 3]) -> Option<Triangle>
where
T: PartialOrd + Copy + Default + std::ops::Add<Output = T>,
{
sides.sort_by(|a, b| a.partial_cmp(b).u... | true |
ff1c0c271583f36037179c1f1968db9e244828b9 | Rust | kirbycool/rust-monkey | /src/parser/parser.rs | UTF-8 | 26,028 | 3.421875 | 3 | [
"MIT"
] | permissive | use crate::parser::ast::{Expr, Precedence, Program, Stmt};
use crate::parser::token::Token;
use crate::parser::Lexer;
use std::iter::Peekable;
use std::str;
type ParseResult<T> = Result<T, String>;
fn token_error(actual: Option<&Token>, expected: &str) -> String {
match actual {
Some(token) => format!(
... | true |
7a82e58441fb56bf696d670aea149aec84f61ae3 | Rust | seanwallawalla-forks/nushell | /crates/nu-command/src/commands/dataframe/series/value_counts.rs | UTF-8 | 1,318 | 2.78125 | 3 | [
"MIT"
] | permissive | use crate::prelude::*;
use nu_engine::WholeStreamCommand;
use nu_errors::ShellError;
use nu_protocol::{
dataframe::{NuDataFrame, NuSeries},
Signature,
};
use crate::commands::dataframe::utils::parse_polars_error;
pub struct DataFrame;
impl WholeStreamCommand for DataFrame {
fn name(&self) -> &str {
... | true |
91886b400d6acec6db001378f1da8ec12ddc6c9d | Rust | steamroller-airmash/airmash-server | /server/src/resource/game_config.rs | UTF-8 | 1,919 | 3.09375 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | /// Flags to enable and/or disable engine features.
///
/// By default these configs are set as would be needed for an FFA gamemode.
#[derive(Clone, Debug)]
pub struct GameConfig {
/// Whether or not to enable the default respawn logic.
///
/// If this is set to true then, by default, once a player dies then they... | true |
63291f28bd2bb0568d831e4b34a0ce405e0c744d | Rust | i5possible/datum | /dc_compiler/src/neat/symbol_table.rs | UTF-8 | 2,075 | 3.40625 | 3 | [
"MIT"
] | permissive | use core::fmt;
use indexmap::map::IndexMap;
#[derive(Clone, Copy, PartialEq)]
pub enum SymbolTableType {
Module,
// same to class symbol
Struct,
Function,
Variable,
BuiltinType,
}
impl fmt::Display for SymbolTableType {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match ... | true |
f0db3109d9bc03759b29e025ef204de902747267 | Rust | averycrespi/yolk | /src/bin/yolkc.rs | UTF-8 | 1,323 | 2.640625 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #[macro_use]
extern crate clap;
use clap::{App, Arg};
use yolk::{YolkProgram, YololProgram};
use std::convert::TryInto;
use std::fs;
fn main() {
let matches = App::new("yolkc")
.version(crate_version!())
.author("Avery Crespi <averycrespi@gmail.com>")
.about("Transpiler for the Yolk lang... | true |
a08b8f5317edd1bf685f65f78d2727992d996cbe | Rust | media-io/srt-media | /src/source/filters/parameters/region_of_interest.rs | UTF-8 | 8,002 | 3.359375 | 3 | [
"MIT"
] | permissive | use super::VideoCrop;
#[cfg(all(feature = "python"))]
use dict_derive::{FromPyObject, IntoPyObject};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Deserialize, JsonSchema, PartialEq, Serialize)]
#[cfg_attr(feature = "python", derive(FromPyObject, IntoPyObject))]
pub struct Regio... | true |
9f696ab435078d592c978d0d5a1622dcf050bd6b | Rust | woshilapin/minidom_writer | /src/writer.rs | UTF-8 | 5,228 | 3.296875 | 3 | [
"MIT"
] | permissive | //! Writer to serialize an [`Element`] (its name, attributes and children).
//!
//! [`Element`]: ../minidom/element/struct.Element.html
use crate::Error;
use minidom::{Element, Node};
use quick_xml::{
events::{BytesDecl, BytesEnd, BytesStart, BytesText, Event},
Writer,
};
use std::io::Write;
const XML_VERSION:... | true |
382fecbedc3b612d63fdee80555e6f0d0f82a587 | Rust | amilajack/hero-studio | /app-server/src/midi/portmidi.rs | UTF-8 | 4,350 | 2.515625 | 3 | [
"MIT"
] | permissive | use log::{debug};
use std::collections::HashSet;
use std::iter::FromIterator;
use std::rc::Rc;
use std::sync::{Arc, RwLock};
use portmidi::{PortMidi, DeviceInfo, OutputPort, MidiEvent, MidiMessage};
use super::{MidiDestination, MidiDriver, MidiDriverId, MidiEndpoint, MidiError, MidiResult};
use hero_studio_core::mid... | true |
7e6890f3e38870d50c18ba3ec3d0af584a7ee071 | Rust | martinaAgata/21C1-Rust-eze | /src/commands/pubsub/subscribe_cl.rs | UTF-8 | 1,105 | 2.546875 | 3 | [] | no_license | use crate::messages::redis_messages;
use crate::{
commands::Runnable,
native_types::{ErrorStruct, RBulkString, RedisType},
};
use crate::{
native_types::error_severity::ErrorSeverity,
tcp_protocol::server_redis_attributes::ServerRedisAttributes,
};
/// Add the given channels to the channels register.
/... | true |
a2b64df0f462730dfdf6f3efec39dc1acdeeaf5a | Rust | monkeylyf/interviewjam | /arr/leetcode_third_maximum_number.rs | UTF-8 | 1,823 | 3.734375 | 4 | [] | no_license | /**
* Given a non-empty array of integers, return the third maximum number in this
* array. If it does not exist, return the maximum number. The time complexity
* must be in O(n).
*
* Example 1:
* Input: [3, 2, 1]
*
* Output: 1
*
* Explanation: The third maximum is 1.
* Example 2:
* Input: [1, 2]
*
* Outp... | true |
01fc68849e145c8653007d51dea822ccf702d7ad | Rust | garyGLgan/g8os | /src/memory/paging/g8_page_table.rs | UTF-8 | 4,702 | 2.578125 | 3 | [
"MIT"
] | permissive | use crate::kernel_const::{
PAGE_TABLE_END, PAGE_TABLE_P2, PAGE_TABLE_P3, PAGE_TABLE_P4, PAGE_TABLE_START,
};
use lazy_static::lazy_static;
use spin::Mutex;
use x86_64::structures::paging::{
mapper::{FlagUpdateError, MapToError, MapperFlush, PhysToVirt, TranslateError, UnmapError},
page_table::PageTableFlags... | true |
5c0c194ac5cddd370bad2c8b9d3040d0a910dbd1 | Rust | Shyamp99/Ping-in-Rust | /src/main.rs | UTF-8 | 2,639 | 2.765625 | 3 | [] | no_license | #![allow(warnings)]
mod lib;
use dns_lookup;
use rand;
// use std::io;
use std::net;
use std::io;
use std::io::Error;
use std::net::*;
use std::net::IpAddr;
use std::net::IpAddr::{V4, V6};
use std::net::{Ipv4Addr, Ipv6Addr};
use dns_lookup::lookup_host;
use std::sync::{Arc, Mutex, RwLock};
fn get_ip_addr(input: Str... | true |
898d6bf5cea4c71eacc3af45fd63f5b223c00698 | Rust | dialtone/protostore2 | /src/toc.rs | UTF-8 | 4,609 | 2.84375 | 3 | [
"MIT"
] | permissive | use std::fs::File;
use std::io;
use std::mem::transmute;
use std::path::{Path, PathBuf};
use std::slice::from_raw_parts;
use memmap;
#[derive(Debug)]
pub struct TableOfContents {
uuids: Vec<[u8; 16]>,
offsets: Vec<u64>,
lens: Vec<u16>,
_files: Vec<memmap::Mmap>,
}
impl TableOfContents {
pub fn fr... | true |
b5f0a9df1057aa57c4440fd51569e7cd87d21631 | Rust | lucifer1004/AtCoder | /abc147/src/bin/b.rs | UTF-8 | 265 | 2.71875 | 3 | [] | no_license | use proconio::input;
use proconio::marker::Chars;
fn main() {
input! {
s: Chars,
}
let n = s.len();
let mut ans = 0;
for i in 0..n / 2 {
if s[i] != s[n - 1 - i] {
ans += 1;
}
}
println!("{}", ans);
}
| true |
f8400951048035436229f9b2120971137c7a423e | Rust | Globidev/advent-of-code | /2018/rust/src/day16.rs | UTF-8 | 8,745 | 2.578125 | 3 | [] | no_license | const RAW_INPUT: &[u8] = include_bytes!("../../inputs/day16.txt");
pub fn day16() -> (usize, u16) {
let (samples, instrs) = parse_input(RAW_INPUT);
(part1(&samples), part2(&samples, &instrs))
}
pub fn part1(samples: &[InstructionSample]) -> usize {
samples.iter()
.filter(|sample| valid_op_codes_f... | true |
87bc15533bfcc51e6a89ee57693428aade76d37e | Rust | rogercyyu/rustybeer | /rustybeer-util/src/conversions.rs | UTF-8 | 11,537 | 3.28125 | 3 | [
"MIT"
] | permissive | use regex::Regex;
use std::num::ParseFloatError;
use measurements::{Mass, Temperature, Volume};
/// Used to build new measurements::Temperature structs.
///
/// To be removed if the dependency some time allows creating measurement units from
/// strings.
pub struct TemperatureBuilder;
impl TemperatureBuilder {
/... | true |
ec3fc165c537baf23e07a0fbc5782d679048a4e4 | Rust | nksaraf/prisma-engines | /migration-engine/connectors/sql-migration-connector/src/sql_schema_differ/differ_database.rs | UTF-8 | 4,273 | 2.734375 | 3 | [
"Apache-2.0"
] | permissive | use crate::{flavour::SqlFlavour, pair::Pair};
use sql_schema_describer::{ColumnId, SqlSchema, TableId};
use std::{
borrow::Cow,
collections::{BTreeMap, HashMap},
ops::Bound,
};
pub(crate) struct DifferDatabase<'a> {
/// Table name -> table indexes.
tables: HashMap<Cow<'a, str>, Pair<Option<TableId>... | true |
e89d766791b99dc8ab9f1a3fbe7a3bc4ccbda388 | Rust | christ776/Rust-Z80 | /src/pacman/pacman.rs | UTF-8 | 8,666 | 2.640625 | 3 | [] | no_license | use std::{time::Duration};
use Z80::{HEIGHT, WIDTH, memory::BoardMemory, memory::Memory, z80};
use crate::{CPU_CLOCK, Direction, Emulator, Machine, gfx_decoder::TileDecoder, utils::rom_loader::RomLoader};
impl Emulator for Machine {
fn new() -> Self {
Self {
memory: BoardMemory::new(),
... | true |
e58eaafb506561f955a85517c45fcabf860f07aa | Rust | qeedquan/challenges | /codeforces/980A-links-and-pearls.rs | UTF-8 | 1,619 | 3.65625 | 4 | [
"MIT"
] | permissive | /*
A necklace can be described as a string of links ('-') and pearls ('o'), with the last link or pearl connected to the first one.
You can remove a link or a pearl and insert it between two other existing links or pearls (or between a link and a pearl) on the necklace. This process can be repeated as many times as y... | true |
dc7ecfa14ef81c87c422f5b11058c9a157105a0d | Rust | polyhorn/polyhorn | /crates/polyhorn-core/src/compositor.rs | UTF-8 | 3,650 | 3.125 | 3 | [
"MIT"
] | permissive | use std::cell::RefCell;
use std::collections::HashMap;
use super::{Container, Platform};
/// A command that can be send from any thread and will be executed on the
/// main thread.
pub enum Command<P>
where
P: Platform + ?Sized,
{
/// Initializes the container that corresponds to the second container ID
/... | true |
2da4fd29f6483275aa4a2f374b79c25764d45b78 | Rust | wolf4ood/gremlin-rs | /gremlin-client/src/structure/vertex_property.rs | UTF-8 | 2,392 | 3.0625 | 3 | [
"Apache-2.0"
] | permissive | use crate::structure::{GValue, Property, GID};
use crate::{GremlinError, GremlinResult};
use crate::conversion::{BorrowFromGValue, FromGValue};
#[derive(Debug, PartialEq, Clone)]
pub enum GProperty {
VertexProperty(VertexProperty),
Property(Property),
}
impl GProperty {
pub fn value(&self) -> &GValue {
... | true |
7e58d74226331eb031852f686bdde7a1568c6ba1 | Rust | benjamin-travis-summers/toys | /pkg/lab1010-1-rs/src/main.rs | UTF-8 | 681 | 2.640625 | 3 | [] | no_license | #[macro_use] extern crate text_io;
use std::io::Write;
use std::io::stdout;
fn main() {
print!("Enter a year: ");
stdout().flush().unwrap();
let year: i32 = read!();
let c = year / 100;
let n = year - 19 * ( year / 19 );
let k = ( c - 17 ) / 25;
let mut i = c - c / 4 - ( c - k ) / 3 + 19 * n + 15;
... | true |
7dddb6f42ebc2741c607cdc3a6cd2edc03d2ba47 | Rust | Roba1993/rune | /crates/rune/src/compiling/v1/assemble/expr_vec.rs | UTF-8 | 896 | 2.515625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use crate::compiling::v1::assemble::prelude::*;
/// Compile a literal vector.
impl Assemble for ast::ExprVec {
fn assemble(&self, c: &mut Compiler<'_>, needs: Needs) -> CompileResult<Asm> {
let span = self.span();
log::trace!("ExprVec => {:?}", c.source.source(span));
let count = self.item... | true |
4571921589c77400a29ba36dfe32e8074f445bc0 | Rust | Devolutions/devolutions-gateway | /crates/proxy-tester/src/main.rs | UTF-8 | 7,443 | 2.796875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use proxy_socks::Socks5Stream;
use std::{env, io};
use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt};
use tokio::net::TcpStream;
const GOOGLE_ADDR: &str = "www.google.com:80";
const USAGE: &str = "[--mode <TEST_MODE>] [--addr <PROXY_ADDR>] [--user <USERNAME>,<PASSWORD>]";
fn main() {
let args: V... | true |
186f67c16ef2dc4d39afbac0620ba26974192c76 | Rust | PSeitz/tantivy | /columnar/src/column_index/optional_index/set_block/sparse.rs | UTF-8 | 2,867 | 3.015625 | 3 | [
"MIT"
] | permissive | use crate::column_index::optional_index::{SelectCursor, Set, SetCodec};
pub struct SparseBlockCodec;
impl SetCodec for SparseBlockCodec {
type Item = u16;
type Reader<'a> = SparseBlock<'a>;
fn serialize(
els: impl Iterator<Item = u16>,
mut wrt: impl std::io::Write,
) -> std::io::Resul... | true |
b472acc23bc2886703e026b0fabaf582195cc929 | Rust | jacquetc/orbtk | /orbtk_core/src/widget_base/state.rs | UTF-8 | 4,076 | 3.34375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use crate::widget_base::{Context, MessageReader, Registry};
use std::any::Any;
pub trait AsAny: Any {
fn as_any(&self) -> &dyn Any;
fn as_any_mut(&mut self) -> &mut dyn Any;
}
/// Used to define a state of a [`widget`].
///
/// The state holds the logic of a widget which makes it interactive.
/// The state o... | true |
13a357143d1537df18d5bf8f6e8276c13e3eb6cb | Rust | seppo0010/shardhashmap-rs | /src/hasher.rs | UTF-8 | 982 | 2.75 | 3 | [] | no_license | use std::hash::Hasher;
use std::u32;
use md5::Context;
pub struct Md5Hasher {
context: Context,
}
impl Md5Hasher {
pub fn new() -> Self {
Md5Hasher { context: Context::new() }
}
}
impl Hasher for Md5Hasher {
fn finish(&self) -> u64 {
let r = self.context.compute();
let p1 = (... | true |
47e58baaa3bc14c9b921fb45f288fb930b12d874 | Rust | meh/rust-picto | /examples/draw.rs | UTF-8 | 2,004 | 2.625 | 3 | [
"WTFPL"
] | permissive | // DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
// Version 2, December 2004
//
// Copyleft (β) meh. <meh@schizofreni.co> | http://meh.schizofreni.co
//
// Everyone is permitted to copy and distribute verbatim or modified
// copies of this license document, and changing it is allowed as long... | true |
a7e0dd208206bd664e8738fbde0193ea83d6d581 | Rust | basu-dev/Diving-To-Rust | /src/ownerandburrow.rs | UTF-8 | 641 | 4.15625 | 4 | [] | no_license | pub fn run(){
//Case 1. values to variables are fixed size and stored in stack.
//Its valid
let a=3;
let b=a;
println!("a: {},b: {}",a,b);
let mut x=3;
let y=x;
x=5;
println!("x:{} , y:{}",x,y);
//Case 2:For string literals or str, It is valid as it is stored in program bytes b... | true |
669903c6f3fa16b9beeddeabe702b515332701e0 | Rust | packnback/packnback | /rust/chunking/src/fixed_size.rs | UTF-8 | 3,498 | 3.34375 | 3 | [] | no_license | pub struct FixedSizeChunker {
reserve_sz: usize,
data_sz: usize,
cur_vec: Vec<u8>,
}
fn read_exact_or_eof(r: &mut std::io::Read, buf: &mut [u8]) -> Result<usize, std::io::Error> {
let mut buf = buf;
let mut n: usize = 0;
loop {
match r.read(buf)? {
0 => return Ok(n),
... | true |
4a9f0072283a733edf5c6b24c726751687c6a111 | Rust | yoshuawuyts/fd-lock | /src/sys/windows/utils.rs | UTF-8 | 936 | 2.71875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::io;
use std::mem;
use windows_sys::Win32::Foundation::BOOL;
use windows_sys::Win32::System::IO::OVERLAPPED;
/// A wrapper around `OVERLAPPED` to provide "rustic" accessors and
/// initializers.
pub(crate) struct Overlapped(OVERLAPPED);
impl Overlapped {
/// Creates a new zeroed out instance of an overla... | true |
438746f0c8db83b3b48357221ced19bb11986488 | Rust | tstellanova/cobs.rs | /src/lib.rs | UTF-8 | 6,297 | 3.53125 | 4 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #![cfg_attr(not(feature = "use_std"), no_std)]
/// Encodes the `source` buffer into the `dest` buffer.
///
/// This function uses the typical sentinel value of 0. It returns the number of bytes
/// written to in the `dest` buffer.
///
/// # Panics
///
/// This function will panic if the `dest` buffer is not large enou... | true |
4c1eb6c0eff1c0fa29033aff73dd1d0ccc7e81aa | Rust | RickHuisman/green | /src/compiler/local.rs | UTF-8 | 390 | 2.890625 | 3 | [] | no_license | #[derive(Debug, Clone)]
pub struct Local {
name: String,
depth: isize,
}
impl Local {
pub fn new(name: String, depth: isize) -> Self {
Local { name, depth }
}
pub fn name(&self) -> &String {
&self.name
}
pub fn depth(&self) -> &isize {
&self.depth
}
pub fn... | true |
25647dec6c883fbe893718f82fb9bcd7cc4880f5 | Rust | Bombfuse/emerald | /emerald/src/colors.rs | UTF-8 | 1,420 | 3.28125 | 3 | [
"MIT"
] | permissive | use serde::{Deserialize, Serialize};
#[derive(Copy, Clone, Debug, Deserialize, Serialize)]
pub struct Color {
pub r: u8,
pub g: u8,
pub b: u8,
pub a: u8,
}
impl Color {
pub fn new(r: u8, g: u8, b: u8, a: u8) -> Self {
Color { r, g, b, a }
}
pub fn to_percentage(&self) -> (f32, f32,... | true |
4d3a02c8bcc30fd34e135fb23f67f078e2039c89 | Rust | jameslittle230/stork-rewrite | /src/searcher/mod.rs | UTF-8 | 999 | 2.609375 | 3 | [
"Apache-2.0"
] | permissive | use crate::index_versions::v2;
use crate::Fields;
use crate::IndexFromFile;
use serde::Serialize;
use crate::index_analyzer::get_index_version;
#[derive(Serialize, Debug)]
pub struct SearchOutput {
pub results: Vec<OutputResult>,
pub total_hit_count: usize,
}
#[derive(Serialize, Clone, Debug)]
pub struct Outp... | true |
95d9a7b91e9c908caf2db75882b896da5915059f | Rust | OmegaJak/duck_game_analyzer | /src/file_reader.rs | UTF-8 | 1,112 | 3.125 | 3 | [] | no_license | use std::{error::Error, fs, path::Path};
use chrono::NaiveDateTime;
use fs::DirEntry;
pub fn get_album_files(folder_path: &str) -> Result<Vec<DirEntry>, Box<dyn Error>> {
let album_folder = Path::new(folder_path);
let entries = fs::read_dir(album_folder)?;
let entries = entries.map(|e| e.unwrap()).co... | true |
bf9ee8d3db1681d88c4d9aa5731b55fc6383e9fe | Rust | Cyborus04/more_nums | /src/int/leb128/leb_u64.rs | UTF-8 | 3,094 | 3 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | #[derive(Copy, Clone, Default, Debug, PartialEq, Eq)]
/// A LEB128 encoded 64-bit unsigned integer.
pub struct LebU64 {
inner: [u8; 10],
}
const MASK: u8 = 0b1000_0000;
const NOT_MASK: u8 = !MASK;
impl LebU64 {
pub fn new(mut value: u64) -> LebU64 {
// Adapted from Wikipedia's example pseudo-code
... | true |
3fbdbcb27cf2099d7c3ec407c0650d7f633f7227 | Rust | GaloisInc/mir-verifier | /lib/libcore/hash/mod.rs | UTF-8 | 20,581 | 4 | 4 | [] | permissive | //! Generic hashing support.
//!
//! This module provides a generic way to compute the hash of a value. The
//! simplest way to make a type hashable is to use `#[derive(Hash)]`:
//!
//! # Examples
//!
//! ```rust
//! use std::collections::hash_map::DefaultHasher;
//! use std::hash::{Hash, Hasher};
//!
//! #[derive(Hash... | true |
15d83068a62ba74e30370f78c301f788f4a7015b | Rust | zhxu73/jx2json-rs | /tests/test_parser.rs | UTF-8 | 8,592 | 2.6875 | 3 | [
"MIT"
] | permissive | extern crate jx2json;
use jx2json::parser;
use jx2json::{ast::AstNode, jx_token::Token};
#[test]
fn parse_empty_workflow1() {
let input = vec![Token::LBRAC, Token::RBRAC];
let result = match parser::parse_tokens(input) {
Ok(result) => result,
Err(err) => panic!("{}", err),
};
if let Ast... | true |
afbb8dbd40b69ce6942e1b0c90a2f42463fbd643 | Rust | redstrike/paddlers-browser-game | /paddlers-frontend/src/resolution.rs | UTF-8 | 1,315 | 3.09375 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use paddlers_shared_lib::game_mechanics::town::{TOWN_X, TOWN_Y};
use strum_macros::EnumIter;
#[derive(EnumIter, Debug, Clone, Copy, PartialEq, Eq)]
pub enum ScreenResolution {
Low,
Mid,
High,
}
impl ScreenResolution {
/// Total window dimensions (ratio is always 16:9)
pub fn pixels(&self) -> (f32,... | true |
059a9832474671eadbe792669f597738d508e47e | Rust | winksaville/fuchsia | /third_party/rust_crates/vendor/pretty_assertions/examples/standard_assertion.rs | UTF-8 | 444 | 3.703125 | 4 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"BSD-3-Clause"
] | permissive | fn main() {
#[derive(Debug, PartialEq)]
struct Foo {
lorem: &'static str,
ipsum: u32,
dolor: Result<String, String>,
}
let x = Some(Foo {
lorem: "Hello World!",
ipsum: 42,
dolor: Ok("hey".to_string()),
});
let y = Some(Foo {
... | true |
63e0ac99aa526413348236b53b33cbab609c4d21 | Rust | ganlvtech/rust-simple-udp-logger | /src/main.rs | UTF-8 | 1,445 | 2.921875 | 3 | [] | no_license | use std::fs::OpenOptions;
use std::io::Write;
use std::net::UdpSocket;
use std::time::SystemTime;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
struct LogRow {
file_name: String,
message: String,
}
fn main() -> std::io::Result<()> {
let socket = UdpSocket::bind("0.0.0.0:9999")?;
... | true |
359be9bcfa5eb1e9fbd6253ebc796c18ad215757 | Rust | Clemalfroy/RustBasics | /lyrics/src/main.rs | UTF-8 | 1,026 | 3.234375 | 3 | [] | no_license | fn main() {
let days = ["first", "second", "third", "fourth", "fifth", "sixth",
"seventh", "eighth", "ninth", "tenth", "eleventh", "twelfth"];
let lyrics = [
"a partridge in a pear tree",
"Two turtle doves",
"Three French hens",
"Four calling birds",
"Five golden ... | true |
252c8e18c7cec0af0477493839836429556d85af | Rust | HerringtonDarkholme/leetcode | /src/32_longest_valid_parentheses.rs | UTF-8 | 1,185 | 3.1875 | 3 | [] | no_license | impl Solution {
pub fn longest_valid_parentheses(s: String) -> i32 {
longest(s)
}
}
fn longest(s: String) -> i32 {
let mut stack = vec![];
let mut left = 0;
let mut current = 0;
let mut max = 0;
for c in s.bytes() {
if c == b'(' {
if current == 0 {
... | true |
b86d950696ae5e0ddd274b07ae2acabf971e3497 | Rust | wa7sa34cx/near-cli-rs | /src/commands/add_command/stake_proposal/transactions_signing/mod.rs | UTF-8 | 6,988 | 2.609375 | 3 | [] | no_license | use dialoguer::Input;
#[derive(Debug, Clone, clap::Clap)]
pub enum CliTransactionsSigning {
/// Enter an public key
TransactionsSigningPublicKey(CliTransactionsSigningAction),
}
#[derive(Debug, Clone)]
pub enum TransactionsSigning {
TransactionsSigningPublicKey(TransactionsSigningAction),
}
impl CliTrans... | true |
670cd8ce303c55431cbd545201dde598a990870b | Rust | saidaspen/aoc2019 | /rust/aoc09/src/main.rs | UTF-8 | 4,012 | 3.234375 | 3 | [
"MIT"
] | permissive | use std::cmp;
use std::collections::HashMap;
use std::io;
use std::io::Read;
#[derive(Debug, PartialEq, Eq)]
enum Status {
Runnable,
Waiting,
Halted,
}
fn main() {
let mut input = String::new();
match io::stdin().read_to_string(&mut input) {
Ok(val) => val,
Err(_) => panic!("Unable... | true |
5cb59dec61494c02fe23098a23a5ac2c70846fc6 | Rust | leeola/fixity | /src/core/primitive/prollylist.rs | UTF-8 | 2,209 | 3.078125 | 3 | [
"MIT"
] | permissive | pub mod refimpl;
use crate::{
core::deser::{Deser, Error as DeserError, Serialize},
value::{Addr, Value},
};
/// An alias to a [`Node`] with owned parameters.
pub type NodeOwned = Node<Value, Addr>;
/// A node within a [Prolly List](crate::primitive::prollylist).
#[cfg_attr(feature = "serde", derive(serde::Seri... | true |
a453c26bc83c9ca8fc94d63f71cc7db86380fa21 | Rust | scott113341/advent_of_code_2020 | /day_03/src/data.rs | UTF-8 | 2,305 | 3.90625 | 4 | [] | no_license | use std::str::FromStr;
#[derive(Eq, PartialEq, Debug)]
pub enum Node {
Tree,
Open,
}
pub type Row = Vec<Node>;
pub type Rows = Vec<Row>;
pub struct Map {
pub rows: Rows,
}
impl Map {
pub fn count_trees(&self, dx: usize, dy: usize) -> usize {
let mut tree_count = 0;
let mut x = 0;
... | true |
1b89c9ff0a0457aab4ff01f446a3235f890ea1a1 | Rust | tshepang/polonius | /src/facts.rs | UTF-8 | 836 | 2.5625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use polonius_engine;
pub(crate) type AllFacts = polonius_engine::AllFacts<Region, Loan, Point, Variable>;
macro_rules! index_type {
($t:ident) => {
#[derive(Ord, PartialOrd, Eq, PartialEq, Clone, Copy, Debug, Hash)]
pub(crate) struct $t {
index: u32,
}
impl From<usize>... | true |
88c8d61b5170a1e775b85ea36a2a7db7ca3b24fb | Rust | megamsys/megam_api.rs | /src/megam_api/api.rs | UTF-8 | 4,376 | 2.609375 | 3 | [
"Apache-2.0"
] | permissive | use curl;
use curl::http;
use curl::http::handle::Method::{Post, Get};
use curl::http::handle::{Method, Request};
use rustc_serialize::json;
use std::result;
use std::{str};
use rustc_serialize::base64::{STANDARD, ToBase64};
use crypto::digest::Digest;
use crypto::md5::Md5;
use crypto::sha1::Sha1;
use crypto::hmac::Hma... | true |
27b11ebb622164d3946b6b79c117e8c3109b95bd | Rust | comp590-19s/590-material | /lecture/10-box-enum/08_traverse_enum/src/main.rs | UTF-8 | 832 | 3.53125 | 4 | [] | no_license | #[derive(Debug)]
enum NGram {
Node { data: char, next: Box<NGram> },
End,
}
use self::NGram::{End, Node};
fn main() {
let b = Node {
data: 'b',
next: Box::new(End),
};
let a = Node {
data: 'a',
next: Box::new(b),
};
println!("iterative: {}", traverse(&a));
... | true |
cf1d38192091058db4c2e2a3a68a94e2b515ca6f | Rust | Dooskington/LD46-Lighthouse-Keeper | /gfx-lib/src/texture.rs | UTF-8 | 265 | 3.140625 | 3 | [
"Zlib"
] | permissive | pub struct Texture {
id: u16,
w: u32,
h: u32,
pixels: Vec<u8>,
}
impl Texture {
pub fn new(id: u16, w: u32, h: u32, pixels: Vec<u8>) -> Texture {
Texture { id, w, h, pixels }
}
pub fn id(&self) -> u16 {
self.id
}
}
| true |
df491bf91ab1f1f745f17364ea72c0a2da850b1c | Rust | xvrqt/echo | /src/context/home.rs | UTF-8 | 1,475 | 2.765625 | 3 | [] | no_license | /* This is the context used to generate index.html */
/* Standard Library */
use std::fs;
use std::path::Path;
use std::error::Error;
/* Third Party Libraries */
use serde::Serialize;
use rusqlite::Connection;
use user_error::UserError;
/* Crate Modules */
use crate::db;
use crate::web::templates;
use crate::post::E... | true |
a4e0895e41c424b1876d62c6d4d189a3c980bd03 | Rust | Arunscape/ECE421 | /assignments/assignment4/linked_list_question2.rar/src/main.rs | UTF-8 | 4,821 | 3.90625 | 4 | [] | no_license | use im::list::{cons, List};
use std::fmt;
// makes testing more expressive
// allows the creation of a linked list
// ex: linkedlist!{1=>2=>3=>4=>5}
#[macro_export]
macro_rules! linkedlist {
( $x:expr ) => {
LinkedList::new($x)
};
( $head:expr $( => $rest:expr )* ) => {
linkedlist!($($rest)... | true |
50d04871c6067962404b885a369a84daef6de6b5 | Rust | xortle/nux | /src/disk/duct_util.rs | UTF-8 | 2,630 | 2.96875 | 3 | [] | no_license | use std::error::Error;
use std::ffi::{OsStr, OsString};
pub struct Cmd {
program: OsString,
args: Vec<OsString>,
}
impl Cmd {
pub fn new<S: AsRef<OsStr>>(program: S) -> Cmd {
Cmd {
program: program.as_ref().to_os_string(),
args: vec![],
}
}
pub fn arg<S: As... | true |
3dc78dd6c255286f2a8cac61b7050f6e32e98039 | Rust | Ujoa/Multicore_Project | /src/algorithms/lockvector/src/lib.rs | UTF-8 | 2,034 | 3.40625 | 3 | [
"MIT"
] | permissive | use std::sync::Mutex;
use std::sync::atomic::AtomicUsize;
use std::ops::{Add, AddAssign};
#[derive(Debug)]
pub struct LockVector<T: Copy + Eq + Add + AddAssign> {
pub list: Mutex<Vec<T>>,
size: AtomicUsize,
}
impl <T> LockVector<T>
where
T: Copy + Eq + Add + AddAssign
{
pub fn new(size: usize) -> Sel... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.