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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
e5683e91e0df0eb6af80d39b3af85777e1eff839 | Rust | thodges314/Rust | /projects/chapter6/plus_one_option_t/src/main.rs | UTF-8 | 566 | 3.78125 | 4 | [] | no_license | fn plus_one(x: Option<i32>)-> Option<i32> {
match x {
Some(i) => Some(i + 1),
None => None,
}
}
fn print_limited_values(x: Option<i32>) {
match x {
Some(1) => println!("one"),
Some(5) => println!("five"),
Some(6) => println!("six"),
None => println!("none"),
_ => println!("other"),
}
}
fn main() {
... | true |
7aafe09106bea3beecdc491912479ea3222094d4 | Rust | Javran/exercism-solutions | /rust/pascals-triangle/src/lib.rs | UTF-8 | 586 | 3.265625 | 3 | [
"Apache-2.0"
] | permissive | pub struct PascalsTriangle(u32);
fn next_layer(xs: &[u32]) -> Vec<u32> {
let mut ys: Vec<u32> = vec![0; xs.len() + 1];
ys[..xs.len()].copy_from_slice(xs);
for i in 0..xs.len() {
ys[i + 1] += xs[i];
}
ys
}
impl PascalsTriangle {
pub fn new(row_count: u32) -> Self {
PascalsTriang... | true |
85f61f55d6904371531594a32322c9a26d82fe00 | Rust | vi/websocat | /src/lib.rs | UTF-8 | 6,913 | 2.609375 | 3 | [
"MIT"
] | permissive | //! Note: library usage is not semver/API-stable
//!
//! Type evolution of a websocat run:
//!
//! 1. `&str` - string as passed to command line. When it meets the list of `SpecifierClass`es, there appears:
//! 2. `SpecifierStack` - specifier class, final string argument and vector of overlays.
//! 3. `Specifier` - more... | true |
9ae50ac77945f3092fc1d5d863c4be5bd7b4efd0 | Rust | maxdeviant/saigon | /src/saigon_plugin_cat_fact/src/lib.rs | UTF-8 | 1,060 | 2.6875 | 3 | [
"MIT"
] | permissive | use saigon_core::content::Content;
use saigon_core::{Command, HelpText, Plugin, PluginResponse, PluginResult};
use serde::Deserialize;
pub struct CatFact;
#[derive(Deserialize)]
struct CatFactJson {
pub fact: String,
pub length: i32,
}
impl Plugin for CatFact {
fn name(&self) -> String {
env!("CA... | true |
679298f8334084543425a9b75d7c873769d0c5bf | Rust | code-relay-io/viuer | /src/printer/block.rs | UTF-8 | 10,305 | 2.734375 | 3 | [] | no_license | use crate::error::{ViuError, ViuResult};
use crate::printer::Printer;
use crate::Config;
use ansi_colours::ansi256_from_rgb;
use image::{DynamicImage, GenericImageView, Rgba};
use std::io::Write;
use termcolor::{Buffer, BufferWriter, Color, ColorChoice, ColorSpec, WriteColor};
use crossterm::cursor::{MoveRight, MoveT... | true |
891fa5e08b358b1cbbb929c4aef4c3c2e7932182 | Rust | nlfiedler/fastcdc-rs | /src/v2020/async_stream_cdc.rs | UTF-8 | 12,068 | 2.921875 | 3 | [
"MIT"
] | permissive | //
// Copyright (c) 2023 Nathan Fiedler
//
use super::*;
#[cfg(all(feature = "futures", not(feature = "tokio")))]
use futures::{
io::{AsyncRead, AsyncReadExt},
stream::Stream,
};
#[cfg(all(feature = "tokio", not(feature = "futures")))]
use tokio_stream::Stream;
#[cfg(all(feature = "tokio", not(feature = "fu... | true |
5d09e278f09292a463c4750ce8d12c3fffce6e1d | Rust | eightbitraptor/dsp-with-rust | /src/main.rs | UTF-8 | 1,955 | 2.984375 | 3 | [] | no_license | extern crate hound;
extern crate gnuplot;
use std::f32::consts::PI;
use std::i16;
use hound::*;
use gnuplot::*;
fn draw_plot<K, T, S>(xs: T, ys: S, name: &str)
where K: DataType,
T: Iterator<Item=K>,
S: Iterator<Item=K>
{
let mut fg = Figure::new();
fg.set_terminal("png", name);
fg... | true |
4905b3786e6531391482e9b754644075907e3aaa | Rust | 7db9a/scabere | /eosio-rust/examples/addressbook/src/lib.rs | UTF-8 | 2,689 | 2.890625 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use eosio::*;
use eosio_cdt::*;
eosio_cdt::abi!(add, update, erase, like, likezip);
#[eosio::table("address")]
struct Address {
#[eosio(primary_key)]
account: AccountName,
first_name: String,
last_name: String,
street: String,
city: String,
state: String,
#[eosio(secondary_key)]
zi... | true |
49753313ee0d1300d5be02eb678e780a7594641a | Rust | ROWZZY/nURRL-reCRYPT-SERV | /src/lib.rs | UTF-8 | 10,292 | 2.828125 | 3 | [] | no_license | use recrypt::prelude::*;
use recrypt::api::*;
use wasm_bindgen::prelude::*;
use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize, Debug)]
struct Identity {
public_key_x: Vec<u8>,
public_key_y: Vec<u8>,
private_key: Vec<u8>,
signing_key_pair: Vec<u8>
}
#[derive(Serialize, Deserialize, D... | true |
17da19972e92a3aaf8742b07b20875797497b654 | Rust | gtk-rs/gir | /src/analysis/c_type.rs | UTF-8 | 2,452 | 3.109375 | 3 | [
"MIT"
] | permissive | use log::trace;
use crate::{env::Env, library::TypeId};
pub fn rustify_pointers(c_type: &str) -> (String, String) {
let mut input = c_type.trim();
let leading_const = input.starts_with("const ");
if leading_const {
input = &input[6..];
}
let end = [
input.find(" const"),
in... | true |
1fe6999bd8493af558aea78cad7498112e3678a4 | Rust | oxidecomputer/miniz | /src/lib.rs | UTF-8 | 22,341 | 3.46875 | 3 | [] | no_license | /// Tiny in-memory implementation of the Zanzibar data model
///
/// See [`MiniZ`] for basic usage information.
///
/// A few notes:
///
/// * We use the term "relationship" where Zanzibar uses the term "relation" to
/// avoid confusion with the database term "relation".
/*
* TODO:
*
* Things to implement:
* - lo... | true |
ef3a37c4098497a68868f668ad46d6ed1e18a8b9 | Rust | mersinvald/tdjson-rs | /src/lib.rs | UTF-8 | 4,059 | 2.578125 | 3 | [
"MIT"
] | permissive | extern crate tdjson_sys;
use tdjson_sys::*;
use std::os::raw::{
c_void,
c_char,
};
use std::ffi::{
CString,
CStr,
};
use std::time::Duration;
use std::ops::Drop;
use std::sync::Arc;
pub fn set_log_file(path: &str) -> Result<i32, std::ffi::NulError> {
let cpath = CString::new(path)?;
unsafe... | true |
7b16304ce7a5aa2880a079113257dd12982a0817 | Rust | mreboland/rustResultTypeErrors | /src/main.rs | UTF-8 | 2,986 | 3.859375 | 4 | [] | no_license | fn main() {
// USE THE RESULT TYPE TO HANDLE ERRORS
// Rust provides the Result<T, E> enum for returning and propagating errors. By convention, the Ok(T) variant represents a success and contains a value, and the variant Err(E) represents and error and contains an error value.
// The Result<T, E> enum is ... | true |
aa799d1c7f0164bfc8681dd5b928ad7ff0e11233 | Rust | szlend/enum_dispatch | /benches/common_structs/mod.rs | UTF-8 | 560 | 2.59375 | 3 | [
"MIT"
] | permissive | use enum_derive::{EnumInnerAsTrait, EnumFromInner, enum_derive_util};
use custom_derive::custom_derive;
use enum_dispatch::enum_dispatch;
mod zero;
pub use self::zero::Zero;
mod one;
pub use self::one::One;
#[enum_dispatch]
pub trait ReturnsValue {
fn return_value(&self) -> usize;
}
#[enum_dispatch(ReturnsValue... | true |
b1215684a27475a6c5c21f8214804da17ef41d81 | Rust | ardite/ardite-core | /src/value.rs | UTF-8 | 10,913 | 3.453125 | 3 | [
"MIT"
] | permissive | //! Types representing for data which will be retrieved from the driver.
//! Currently this data is expected to look like a JSON object but this may be
//! changed in the future. Driver authors must cast the data they retrieve from
//! the driver to these types.
use linear_map::LinearMap;
use serde::ser::{Serialize, S... | true |
2f18eb53f88a4bdd5b2e6ec3af1c78641689eafa | Rust | jbeja/iota | /src/iota/modes/mod.rs | UTF-8 | 688 | 2.65625 | 3 | [
"MIT"
] | permissive | pub use super::keyboard::Key;
pub use super::keymap::KeyMap;
pub use super::editor::Command;
pub use super::keymap::KeyMapState;
pub use super::buffer::Direction;
pub use super::buffer::WordEdgeMatch;
pub use super::overlay::{Overlay, OverlayType, OverlayEvent};
pub use self::standard::StandardMode;
pub use self::norm... | true |
bbccdf924d984d37977fc04b5114cfb3501a3afe | Rust | main--/stereo | /src/metadata/image.rs | UTF-8 | 2,946 | 2.890625 | 3 | [] | no_license | use std::ptr;
use std::marker::PhantomData;
use std::ffi::CString;
use std::ops::Range;
use runtime::Mono;
use super::*;
use native;
/// TODO
///
/// Images are reference-counted. Cloning them is cheap.
/// The actual image is only unloaded once the last reference dies.
pub struct Image<'mono> {
mono: PhantomData... | true |
277272405ddce558ea8534b7f865453e4e68e848 | Rust | MrGmo/rustlings | /macros/macros1.rs | UTF-8 | 172 | 2.625 | 3 | [] | no_license | // Calling a macro so don't forget the ! on my_macro
macro_rules! my_macro {
() => {
println!("Check out my macro!");
};
}
fn main() {
my_macro!();
}
| true |
423a394a5153a254821318c6df5d84ef1dfe36bf | Rust | GaloisInc/mir-verifier | /lib/libcore/tests/cell.rs | UTF-8 | 8,688 | 3.34375 | 3 | [] | permissive | use core::cell::*;
use core::default::Default;
use std::mem::drop;
#[test]
fn smoketest_cell() {
let x = Cell::new(10);
assert_eq!(x, Cell::new(10));
assert_eq!(x.get(), 10);
x.set(20);
assert_eq!(x, Cell::new(20));
assert_eq!(x.get(), 20);
let y = Cell::new((30, 40));
assert_eq!(y, Ce... | true |
86eeff1f51ba339f66a2a4c0779273b95fcc7148 | Rust | selendra/contract-registry | /token_lock/lib.rs | UTF-8 | 3,356 | 2.9375 | 3 | [] | no_license | #![cfg_attr(not(feature = "std"), no_std)]
use ink_lang as ink;
pub mod error;
#[ink::contract]
mod token_lock {
use super::*;
use error::*;
use ink_storage::{ collections::HashMap as StorageHashMap, Lazy };
#[ink(storage)]
pub struct TokenLock {
lst_account: StorageHashMap<AccountId, bo... | true |
8677191ae53cef7d7b64ccb071bf37a2f6f8baf2 | Rust | jrforrest/sysunit-rust | /src/execution/target/ssh/auth.rs | UTF-8 | 1,879 | 2.828125 | 3 | [] | no_license | use crate::ui::prompt_ssh_password;
use url::Url;
use ssh2::Session;
use log::info;
use crate::error::{Error, BoxedResult};
pub fn auth(session: &mut Session, url: &Url) -> Result<(), Error> {
let username = match url.username() {
"" => return Err(
Error::new(format!("Target `{:?}` must specif... | true |
9c99a35b2036df06448dd7459691103058a4d249 | Rust | Mythridor/yare-rust | /src/bindings/console.rs | UTF-8 | 546 | 2.703125 | 3 | [] | no_license | #[cfg(not(feature = "headless"))]
use std::os::raw::c_char;
#[cfg(not(feature = "headless"))]
#[link(wasm_import_module = "console")]
extern "C" {
/// Call `console.log`. This is shows in the console window above your code
/// and is very useful for debugging.
///
/// ### Usage
/// ```
/// use ... | true |
84328adf2962e76272c203ad5497df25ed83666a | Rust | mmstick/advent-of-code-solutions | /06/second/grid.rs | UTF-8 | 1,220 | 3.34375 | 3 | [
"MIT"
] | permissive | pub struct Grid {
pub grid: [[usize;1000];1000]
}
impl Grid {
/// +1 brightness to all lights from x,y through x,y in the grid.
pub fn turn_on(&mut self, start: [usize;2], stop: [usize;2]) {
for x in start[0]..stop[0]+1 {
for y in start[1]..stop[1]+1 {
self.grid[x][y] +=... | true |
0134699fd824d1f439f7aec01aec1cac0c017c03 | Rust | awakecoding/webrtc-sctp | /src/util/serial.rs | UTF-8 | 11,823 | 3.640625 | 4 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Provide traits and structs to abstract RFC 1982 serial number arithmetic. This is use, for
//! example, to compare transmission sequence numbers (TSNs).
use std::cmp::Ordering;
use std::fmt::{self, Debug, Display, Formatter, LowerHex, UpperHex};
use std::hash::{Hash, Hasher};
use std::ops::{Add, AddAssign, Sub, S... | true |
b3a3694090d1cc3c9ffccd70e37f64e3a6907a87 | Rust | wdv4758h/scgc | /examples/example1.rs | UTF-8 | 725 | 2.609375 | 3 | [] | no_license | #[macro_use]
extern crate scgc;
#[macro_use]
extern crate log;
extern crate env_logger;
fn main() {
env_logger::init().unwrap();
let mut gc = scgc::Gc::new(20480);
let x = true;
gc.stack_begin(&x);
let data1: &mut [u8; 1024] = malloc!(gc, 4096);
data1[0] = 42;
debug!("pointer on stack {... | true |
79a65f36d2ba4d920dafaaeb6b2063d0886006c9 | Rust | ia7ck/competitive-programming | /AtCoder/past202212-open/src/bin/n/main.rs | UTF-8 | 4,056 | 2.609375 | 3 | [] | no_license | use std::{collections::BTreeMap, ops::Range};
use proconio::{input, marker::Usize1};
trait Seq {
type Output;
fn len(&self) -> usize;
fn push_front(&mut self, i: usize);
fn push_back(&mut self, i: usize);
fn pop_front(&mut self, i: usize);
fn pop_back(&mut self, i: usize);
fn output(&self... | true |
11bceb0c350d0a5d5c6866ef9ecaa4e33b4ca5b0 | Rust | wbjohnston/gameboy | /src/cartridge.rs | UTF-8 | 1,193 | 2.9375 | 3 | [] | no_license | use {
crate::util::*,
};
#[derive(Clone)]
pub enum Cartridge {
RomOnly(Box<[u8; Self::ROM_ONLY_SIZE]>),
MBC1 {},
MBC2 {},
MBC3 {},
MBC5 {},
Rumble {},
HuC1 {},
}
impl Cartridge {
const ROM_ONLY_SIZE: usize = 0xFFFF;
const NO_RAM_READ_VALUE: u8 = 0xFF;
pub fn maybe_from_bytes(bytes: &[u8]) -> Op... | true |
5d66ca2e8d6c34dea74499c858f0b90344409f67 | Rust | facebook/hhvm | /hphp/hack/src/hackc/emitter/label_rewriter.rs | UTF-8 | 12,889 | 2.5625 | 3 | [
"PHP-3.01",
"Zend-2.0",
"MIT"
] | permissive | // Copyright (c) Facebook, Inc. and its affiliates.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the "hack" directory of this source tree.
use env::emitter::Emitter;
use env::LabelGen;
use hash::HashMap;
use hash::HashSet;
use hhbc::Instruct;
use hhbc::Label;
use hhbc::Opcod... | true |
53f93d622048dbf3dd11dedf94daa71f6e361069 | Rust | stackcats/leetcode | /algorithms/medium/find_and_replace_pattern.rs | UTF-8 | 922 | 3.109375 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
fn check_pattern(word: &[u8], pattern: &[u8]) -> bool {
let mut forward = HashMap::new();
let mut backward = HashMap::new();
for i in 0..word.len() {
let v = backward.entry(pattern[i]).or_insert(word[i]);
if *v != word[i] {
return false;
}
... | true |
97d4b7396f380b8e6f44909c4fda523074b5195c | Rust | SokichiFujita/raytracer | /src/computation.rs | UTF-8 | 921 | 2.859375 | 3 | [
"MIT"
] | permissive | use crate::shape::Shape;
use na::Vector4;
#[derive(Clone, Debug)]
pub struct Computations {
pub t: f32,
pub shape: Shape,
pub point: Vector4<f32>,
pub under_point: Vector4<f32>,
pub over_point: Vector4<f32>,
pub eyev: Vector4<f32>,
pub normalv: Vector4<f32>,
pub inside: bool,
pub re... | true |
431c7eabe72af5ca4a94fd241095b46e579b8fa1 | Rust | dpinart-uxland/stock-tracking-cli | /src/main.rs | UTF-8 | 1,604 | 2.6875 | 3 | [] | no_license | mod symbol;
extern crate yahoo_finance_api;
extern crate clap;
extern crate chrono;
extern crate crossbeam;
use clap::{App, Arg};
use chrono::prelude::*;
use crossbeam::channel::{unbounded};
use crate::symbol::{Range, TickerInfo};
fn main() {
let args = App::new("Stock Tracking cli")
.about("A tool to... | true |
55a49d8a6633556153b4998f0ae93162bb9e4706 | Rust | DuncanHills/sled | /src/io/log/segment_accountant.rs | UTF-8 | 33,252 | 3.015625 | 3 | [
"Apache-2.0"
] | permissive | //! The `SegmentAccountant` is an allocator for equally-
//! sized chunks of the underlying storage file (segments).
//!
//! It must maintain these critical safety properties:
//!
//! A. We must not overwrite existing segments when they
//! contain the most-recent stable state for a page.
//! B. We must not overwrit... | true |
07036d29334530424317b3903aa202c723a2b618 | Rust | jtescher/ruma | /ruma-client-api/src/r0/message/create_message_event.rs | UTF-8 | 1,514 | 2.828125 | 3 | [
"MIT"
] | permissive | //! [PUT /_matrix/client/r0/rooms/{roomId}/send/{eventType}/{txnId}](https://matrix.org/docs/spec/client_server/r0.6.1#put-matrix-client-r0-rooms-roomid-send-eventtype-txnid)
use ruma_api::ruma_api;
use ruma_events::EventType;
use ruma_identifiers::{EventId, RoomId};
use serde_json::value::RawValue as RawJsonValue;
r... | true |
6bb549c02406fbdbbf2fdbd3a5e1c4979ece7130 | Rust | jordipainan/rust-libp2p | /core/src/nodes/handled_node.rs | UTF-8 | 27,667 | 2.5625 | 3 | [
"MIT"
] | permissive | // Copyright 2018 Parity Technologies (UK) Ltd.
//
// 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, mer... | true |
41154d7c8923610d1da6076db78242e4c7504123 | Rust | dmrolfs/actix-raft-scaffold | /tmp/api.cluster.rs | UTF-8 | 37,679 | 2.921875 | 3 | [
"MIT"
] | permissive | #[derive(Clone, PartialEq, ::prost::Message)]
pub struct Failure {
#[prost(string, tag = "1")]
pub description: std::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct NodeId {
#[prost(uint64, tag = "1")]
pub id: u64,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Nod... | true |
096f25b2cb72f0d0e75a640dce1d1c56fb5f2009 | Rust | GrahamDennis/exercism | /rust/luhn/src/lib.rs | UTF-8 | 789 | 3.671875 | 4 | [] | no_license | /// Check a Luhn checksum.
pub fn is_valid(code: &str) -> bool {
if !valid_chars(code) {
return false;
}
let checksum: u32 = code
.chars()
.flat_map(|c| c.to_digit(10))
.rev()
.enumerate()
.map(|(i, v)| digit_checksum(i, v))
.sum();
checksum % 10... | true |
7b188c1bde794066341abdf97aad533f2d5942c2 | Rust | kdy1/rust-static-map | /src/lib.rs | UTF-8 | 1,376 | 3.34375 | 3 | [
"MIT"
] | permissive | //!
//! # Usage
//!
//!```rust
//!
//! use st_map::StaticMap;
//!
//! #[derive(Debug, PartialEq, Default, StaticMap)]
//! struct BrowserData<T: Default> {
//! chrome: T,
//! safari: T,
//! android: T,
//! }
//!
//! {
//! // .iter(), .iter_mut(), .into_iter()
//! let mut data = BrowserData {
//! c... | true |
41fe927e6a8eab7c689bf9a728f16419af64c51e | Rust | DmitryTravyan/mastermind-rust | /src/main.rs | UTF-8 | 9,162 | 3.34375 | 3 | [] | no_license | use rand::Rng;
use std::{fmt, fmt::{Formatter}};
use ansi_term::Color;
#[derive(Debug, PartialEq, Clone, Copy)]
enum Variants {
Red,
Purple,
Yellow,
Grey,
Blue,
Cyan,
Orange,
White,
Empty,
}
impl fmt::Display for Variants {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
... | true |
bf5846914b36d8c9f9dedb98a9f5b55165b0ba3a | Rust | munckymagik/redis-clone | /src/request.rs | UTF-8 | 3,384 | 3.296875 | 3 | [] | no_license | use crate::{
errors::{Error, Result},
protocol,
};
use byte_string::{ByteStr, ByteString};
use std::convert::{TryFrom, TryInto};
use std::marker::Unpin;
use tokio::io::AsyncBufRead;
pub async fn parse(stream: &mut (impl AsyncBufRead + Unpin + Send)) -> Result<Request> {
let query = protocol::decode(stream)... | true |
ac39cf5674351bc49d8eb5b03334dd60e59d883e | Rust | jaywalia/rust_by_example | /src/rbe_4_variables.rs | UTF-8 | 737 | 3.1875 | 3 | [] | no_license | pub fn _test_variables(){
let _an_int = 1u32;
let _a_bool = true;
let _unit = ();
let _copy_int = _an_int;
println!("int: {:?}", _copy_int);
let _set_in_my_ways = 99;
let mut _go_with_the_flow = 120;
_go_with_the_flow = 130;
println!("before: {}",_go_with_the_flow);
{
... | true |
a4a6be93b5b2fa92f7b95fb1e230a97c94cdb0ba | Rust | Xannden/aoc2020 | /src/days/day15.rs | UTF-8 | 1,546 | 3.53125 | 4 | [] | no_license | use std::{collections::HashMap, fs::File, io::Read};
pub fn run() {
let mut file = File::open("input/day15.txt").unwrap();
let mut data = String::new();
file.read_to_string(&mut data).unwrap();
let data = parse(data);
// println!("{:?}", data);
part1(data.clone());
part2(data);
}
#[de... | true |
f87835098b04f100063d91980560504d86108fb2 | Rust | Thaddeus19/rust-programming | /grep/src/lib.rs | UTF-8 | 342 | 2.671875 | 3 | [] | no_license | use std::io::{self, BufRead};
use std::io::prelude::*;
use std::fs::File;
use std::path::PathBuf;
pub fn grep_fn<R: BufRead>(target: &str, reader: R) -> io::Result<()> {
for line_result in reader.lines() {
let line = line_result?;
if line.contains(target) {
println!("{}", line);
... | true |
184cea18d083aefbecd88ef16f8bedae6d71aa3c | Rust | bing050802/leetcode-rust-repo | /830/main.rs | UTF-8 | 488 | 2.546875 | 3 | [] | no_license | impl Solution {
pub fn large_group_positions(s: String) -> Vec<Vec<i32>> {
let mut result: Vec<Vec<i32>> = Vec::new();
let mut i = 0;
let n = s.len();
let s = s.chars().collect::<Vec<char>>();
for j in 0..n {
if j == n - 1 || s[j] != s[j + 1] {
if ... | true |
03bd15a4183c7890cad7e8e364730009816cb4ec | Rust | nibin/grpc-rust | /src/futures_misc/future_to_stream_once.rs | UTF-8 | 1,273 | 3.046875 | 3 | [
"MIT"
] | permissive | use futures::Future;
use futures::Poll;
use futures::Async;
use futures::stream::Stream;
enum FutureToStreamState<F> {
Future(F),
Eof,
Done,
}
pub struct FutureToStreamOnce<F> {
future: FutureToStreamState<F>,
}
/// Convert a future into single element stream
pub fn future_to_stream_once<F : Future>... | true |
2dcb9172da46459fca07f95ab8ca64b7abbc9c5a | Rust | noahbkim/htor | /src/parser/indentation.rs | UTF-8 | 2,835 | 3.53125 | 4 | [] | no_license | use crate::error::AnonymousEvaluationError;
pub enum Indentation {
Spaces(usize),
Tabs,
}
pub struct ParserIndentation {
indentation: Option<Indentation>,
}
fn count_at_start(
expected: char,
disallowed: char,
line: &String,
) -> Result<usize, AnonymousEvaluationError> {
let mut result: u... | true |
2d962743a4b4e1a59423c40b0359e1e3768ed8e9 | Rust | fossabot/alpha_vantage | /src/stock_time.rs | UTF-8 | 18,434 | 3.234375 | 3 | [
"MIT"
] | permissive | //! Module for stock time series
//!
//! This suite of APIs provide realtime and historical global equity data in 4
//! different temporal resolutions: (1) daily, (2) weekly, (3) monthly, and (4)
//! intraday. Daily, weekly, and monthly time series contain 20+ years of
//! historical data
//!
//! You can read about [St... | true |
8d962631ae64456c14a889903fc6b788ef6405a3 | Rust | roy-ganz/toql | /src/lib.rs | UTF-8 | 4,116 | 2.5625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! # Toql - A friendly and productive ORM
//!
//!
//! [Beginner Guide](https://roy-ganz.github.io/toql), [API documentation](https://docs.rs/toql/0.3/toql/)
//!
//! Toql is an ORM for async databases that features
//! - Translation between Rust structs and database tables.
//! - Can load and modify nested structs.
//!... | true |
990faa1251345be677515586d59e812742ad0ec7 | Rust | borela-forks/libsyntax2 | /src/parser/grammar/type_params.rs | UTF-8 | 1,925 | 2.765625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use super::*;
pub(super) fn list(p: &mut Parser) {
if !p.at(L_ANGLE) {
return;
}
let m = p.start();
p.bump();
while !p.at(EOF) && !p.at(R_ANGLE) {
match p.current() {
LIFETIME => lifetime_param(p),
IDENT => type_param(p),
_ => p.err_and_bump("exp... | true |
140b7dc6369458aa97f58df2113e075eaeac5c94 | Rust | msimms/LibMath | /rust/src/vector.rs | UTF-8 | 3,028 | 3.046875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | // MIT License
//
// Copyright © 2018 Michael J Simms. All rights reserved.
//
// 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... | true |
38c4875be774db38fd38e5041322202e1556d4c1 | Rust | adrianlemess/rust-playground | /sum_values/src/main.rs | UTF-8 | 613 | 3.53125 | 4 | [] | no_license | use std::io;
fn main() {
println!("Sum values!");
let mut input_a = String::new();
let mut input_b = String::new();
println!("Enter the first value: ");
io::stdin().read_line(&mut input_a)
.expect("failed to read line");
println!("Enter the second value: ");
io::stdin().read_lin... | true |
37e3f8337fd3ea2c45f0b49453de28f39df05ea3 | Rust | zsiciarz/nats-playground | /rust/src/main.rs | UTF-8 | 502 | 2.859375 | 3 | [
"MIT"
] | permissive | use std::io::prelude::*;
use std::net::TcpStream;
fn main() {
let mut sock = TcpStream::connect("127.0.0.1:4222").unwrap();
let mut buf = [0; 1024];
loop {
let len = sock.read(&mut buf).unwrap();
if len == 0 {
break;
}
let s = std::str::from_utf8(&buf[..len]).unw... | true |
8ff8544d6fe77638b82a0993cffd059ff6e7dffc | Rust | xunilrj/case | /src/lib.rs | UTF-8 | 6,597 | 3.859375 | 4 | [
"MIT"
] | permissive | pub trait CaseExt {
type Owned;
/// Create a new string from a string slice with replacing the first character with its
/// to ASCII upper case counterpart (if one exists).
///
/// # Examples
///
/// ```
/// use case::CaseExt;
///
/// assert_eq!(&CaseExt::to_capitalized("stringy... | true |
c06c3159052217a4ec1985c75aac291038120c1c | Rust | SamHDev/luna_nbt | /src/decode.rs | UTF-8 | 4,591 | 2.953125 | 3 | [
"MIT"
] | permissive | use std::io::Read;
use std::collections::HashMap;
use crate::{Tag, TagIdent};
use byteorder::{ReadBytesExt, BE};
use crate::error::{digest_io, NBTResult, NBTError};
pub(crate) fn read_ident<R: Read>(reader: &mut R) -> NBTResult<TagIdent> {
let byte = digest_io(reader.read_u8())?;
match TagIdent::parse(&byte) {... | true |
36dd77778e2c242b0f715034574c2c6621b32786 | Rust | calam1/rust-examples | /queue/src/main.rs | UTF-8 | 890 | 3.828125 | 4 | [] | no_license |
pub struct Queue<T> {
in_values: Vec<T>,
out_values: Vec<T>
}
impl<T> Queue<T> {
pub fn push(&mut self, value: T) {
self.in_values.push(value);
}
pub fn pop(&mut self) -> Option<T> {
if self.out_values.is_empty() {
if self.in_values.is_empty() {
return... | true |
021adfd03a395fc2b9c31debe97b5f20e4578d90 | Rust | mkalam-alami/raytracing-kajam | /src/player.rs | UTF-8 | 3,330 | 2.578125 | 3 | [] | no_license | use crate::{core::{config::TARGET_FPS, game::GameState, math::clamp}, map::Map, point::Point, tileset::Tileset};
use winit::event::VirtualKeyCode;
use winit_input_helper::WinitInputHelper;
const MOV_SPEED: f32 = 0.09;
const ROT_SPEED: f32 = 4.0;
const PLAYER_SIZE: f32 = 0.4 / MOV_SPEED;
const TRIGGER_PERIOD: f32 = 0.5... | true |
e2f3e8273485a116fa0209200fd3f65d919da268 | Rust | wotsushi/competitive-snippet | /snippets/read/readi643/readi643.rs | UTF-8 | 749 | 2.828125 | 3 | [
"MIT"
] | permissive | #![allow(non_snake_case)]
#![allow(unused_variables)]
// https://onlinejudge.u-aizu.ac.jp/courses/lesson/8/ITP2/all/ITP2_3_A
fn main() {
// snip
let (_A, _B, _C): (i64, i64, i64) = {
let mut line: String = String::new();
std::io::stdin().read_line(&mut line).unwrap();
let mut iter = li... | true |
50f897738c7f0ab0746a509e240a4b46018a1d9f | Rust | dominictwlee/noc-nannou | /src/bin/0_2_random_distribution.rs | UTF-8 | 1,167 | 2.9375 | 3 | [
"MIT"
] | permissive | extern crate rand;
use nannou::prelude::*;
fn main() {
nannou::app(model).update(update).run();
}
struct Model {
counts: Vec<i32>,
}
const TOTAL: i32 = 20;
fn model(app: &App) -> Model {
app.new_window().size(640, 360).view(view).build().unwrap();
let mut counts = Vec::new();
for _ in 0..TOTAL {
cou... | true |
cb649d4b22b6c12a2863c0e8129eceeae93ef7de | Rust | johannesvollmer/oriole-text | /src/rectangle.rs | UTF-8 | 1,010 | 3.234375 | 3 | [] | no_license | use serde::{ Serialize, Deserialize };
#[derive(Serialize, Deserialize, Clone, Copy)]
pub struct Rectangle {
pub position: (f32, f32),
pub dimensions: (f32, f32),
}
impl Rectangle {
pub fn right(&self) -> f32 {
self.position.0 + self.dimensions.0
}
pub fn left(&self) -> f32 {
sel... | true |
2db6c291dd59a173630960ee45dbaa7efeca5d2b | Rust | rrybarczyk/intermodal | /src/platform_interface.rs | UTF-8 | 813 | 2.578125 | 3 | [
"CC0-1.0"
] | permissive | use crate::common::*;
pub(crate) trait PlatformInterface {
fn open(path: &Path) -> Result<(), Error> {
let mut command = Self::opener()?;
command.push(OsString::from(path));
let command_string = || {
command
.iter()
.map(|arg| arg.to_string_lossy().into_owned())
.collect::<... | true |
8f9e0d84a350ec441a21032b4f6f085c5454bb82 | Rust | block-cube-lib/lifegame-server-rs | /src/lifegame_field.rs | UTF-8 | 2,532 | 3.390625 | 3 | [] | no_license | use crate::lifegame::Cell;
#[derive(Clone)]
pub struct LifegameField {
width: u32,
height: u32,
cells: Vec<Cell>,
next_cells: Vec<Cell>,
}
impl LifegameField {
pub fn new(width: u32, height: u32) -> LifegameField {
let mut field = LifegameField {
width,
height,
... | true |
48afc73fe9bc930b19f0d3fe7d647c495e75c9bf | Rust | Lucky4Luuk/GlueCompiler | /lexer/src/token_kind.rs | UTF-8 | 1,932 | 3.234375 | 3 | [] | no_license | use std::fmt;
use logos::Logos;
#[derive(Logos, Debug, PartialEq, Copy, Clone)]
pub enum TokenKind {
#[token("func")]
KeywordFunc,
#[token("return")]
KeywordReturn,
#[token(":")]
Colon,
#[token(";")]
Semicolon,
#[token(",")]
Comma,
// #[regex(r#"/[*](~(.*[*]/.*))[*]/"#)]
... | true |
588de74aa4429c5c3c6f765dc1428dc55f921653 | Rust | tcmal/iroh | /iroh/src/fields/text_input.rs | UTF-8 | 3,290 | 3.296875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | use crate::{
app::AppState,
lens::{Lens, RootLens},
message::Message,
mutation::{LensSet, NopMutator},
Field, Kind, ObjectStore,
};
use iced::{text_input, Align, Element, Row, Text, TextInput};
use std::{
fmt::{Debug, Display},
marker::PhantomData,
str::FromStr,
};
/// A field which the... | true |
afce67fcd598b2c4e424160ef080dff0dcc8d9dc | Rust | burntcookie90/uniqtoo | /src/main.rs | UTF-8 | 3,146 | 3.21875 | 3 | [
"Apache-2.0"
] | permissive | use std::collections::HashMap;
use std::fs::File;
use std::io::stdin;
use std::io::stdout;
use std::io::BufRead;
use std::io::BufReader;
use std::io::BufWriter;
use std::io::Write;
use std::process::exit;
use structopt::StructOpt;
fn main() {
let args: Args = Args::from_args();
if args.debug {
dbg!(&args);
}
if... | true |
5a716dc6f61aa08e41c643d8c0ede846974cb8bd | Rust | emreyalvac/project-management-system | /commands/src/command_handlers/user_command_handlers/insert_board_to_user_command_handler.rs | UTF-8 | 1,479 | 2.625 | 3 | [] | no_license | use crate::commands::user_commands::insert_board_to_user_command::InsertBoardToUserCommand;
use domain::command::command::TCommandHandler;
use domain::common::command_response::CommandResponse;
use async_trait::async_trait;
use domain::common::command_type::CommandType;
use data_access::generic_repository::generic_repo... | true |
bb9190a1527fb5270b71dd2761b4a9b72c24d67c | Rust | Teaonly/tealang | /lisp/rust/src/main.rs | UTF-8 | 1,865 | 2.609375 | 3 | [
"MIT"
] | permissive | extern crate rustyline;
mod tealang;
use std::env;
use std::fs::File;
use std::io::{BufRead, BufReader};
use std::collections::HashMap;
use rustyline::error::ReadlineError;
use rustyline::Editor;
use tealang::*;
fn build_extern(env: &mut ExpEnv) {
let mut data: HashMap<String, ExpNode> = HashMap::new();
le... | true |
abf47e6a4e0a2f9b8d75905cee330b7a5321845c | Rust | andrewasd/RedditWallPaper | /src/fetchwallpaperdir/vendor/executors/src/parker.rs | UTF-8 | 27,698 | 3.078125 | 3 | [] | no_license | // Copyright 2017-2020 Lars Kroll. See the LICENSE
// file at the top-level directory of this distribution.
//
// Licensed under the MIT license
// <LICENSE or http://opensource.org/licenses/MIT>.
// This file may not be copied, modified, or distributed
// except according to those terms.
//! A reusable thread-pool-pa... | true |
b625c5e0ba31f20fedafeea6baf19dd1aef33b07 | Rust | RustyYato/once_cell | /src/imp_pl.rs | UTF-8 | 5,935 | 3.390625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::{
cell::UnsafeCell,
sync::atomic::{AtomicBool, Ordering},
hint::unreachable_unchecked,
panic::{UnwindSafe, RefUnwindSafe},
fmt,
};
use parking_lot::{
RawMutex,
lock_api::RawMutex as _RawMutex,
};
pub(crate) struct OnceCell<T> {
mutex: Mutex,
is_initialized: AtomicBool,
... | true |
78e84428e00c0b457b8de16b682fa0b95f75098c | Rust | jam1garner/binread | /binread/src/pos_value.rs | UTF-8 | 2,460 | 3.578125 | 4 | [
"MIT"
] | permissive | use super::*;
use core::fmt;
/// A wrapper where the position it was read from is stored alongside the value
/// ```rust
/// use binread::{BinRead, PosValue, BinReaderExt, io::Cursor};
///
/// #[derive(BinRead)]
/// struct MyType {
/// a: u16,
/// b: PosValue<u8>
/// }
///
/// let val = Cursor::new(b"\xFF\xFE\... | true |
bbde360882d07d82f2ee9b8aa5d3250b7d4e3cb0 | Rust | 01intelligence/hulk | /src/errors/mod.rs | UTF-8 | 2,003 | 2.53125 | 3 | [
"Apache-2.0"
] | permissive | mod api_errors;
mod encryption;
mod reducible_errors;
mod storage_errors;
mod typed_errors;
mod ui_errors;
use std::error::Error;
pub use api_errors::*;
pub use encryption::*;
pub use reducible_errors::*;
pub use storage_errors::*;
pub use thiserror::private::AsDynError;
pub use typed_errors::*;
pub use ui_errors::*;... | true |
3e11a20c83d01285620b956700e7ef421f9886eb | Rust | tikhono/tokio-server | /src/main.rs | UTF-8 | 2,825 | 2.84375 | 3 | [] | no_license | use futures::stream::StreamExt;
use rand::Rng;
use std::env;
//use std::{thread, time};
use tokio::net::TcpListener;
use tokio::prelude::*;
#[tokio::main]
async fn main() {
let args: Vec<String> = env::args().collect();
let arg_len = args.len();
match arg_len {
2 => println!("Get adress: \"{}\"", ... | true |
301ffb7f6494ec99ef30d739ddd1e00e82e17731 | Rust | winter-yuki/rust-rt | /src/main.rs | UTF-8 | 4,473 | 2.65625 | 3 | [] | no_license | extern crate image;
extern crate rt;
use std::{env, io, process};
use std::io::Write;
use std::num::NonZeroUsize;
use std::path::PathBuf;
use std::sync::atomic::{AtomicUsize, Ordering};
use image::Color;
use rt::{Camera, Lambertian, Logger, Metal, Positive, Ray, Scene, Sphere, UniFloat};
use rt::NormVector;
use rt::V... | true |
7f658645f343bd3f65041d4fc3d12aba2c685953 | Rust | EFanZh/LeetCode | /src/problem_0106_construct_binary_tree_from_inorder_and_postorder_traversal/recursive_cached.rs | UTF-8 | 1,873 | 2.765625 | 3 | [] | no_license | use crate::data_structures::TreeNode;
pub struct Solution;
// ------------------------------------------------------ snip ------------------------------------------------------ //
use std::cell::RefCell;
use std::collections::HashMap;
use std::rc::Rc;
impl Solution {
fn build_tree_helper(
inorder: &[i32... | true |
a82f201196af669323389de750fcf641722d7746 | Rust | logansquirel/advent_of_code | /aoc_2017/day_01/tests/aoc_2017_day_01.rs | UTF-8 | 312 | 2.546875 | 3 | [
"MIT"
] | permissive | use aoc_2017_day_01::part_one;
use aoc_2017_day_01::part_two;
#[test]
fn part_one_answer() {
let input = include_str!("../input/input.dat");
assert_eq!(1119, part_one(input));
}
#[test]
fn part_two_answer() {
let input = include_str!("../input/input.dat");
assert_eq!(1420, part_two(input));
}
| true |
6988db8143945a0b26bcbbb0b1a1001c43e36804 | Rust | lukaspustina/rs-collector | /src/collectors/rscollector.rs | UTF-8 | 3,060 | 2.703125 | 3 | [
"MIT"
] | permissive | use crate::bosun::{Metadata, Rate, Sample};
use crate::collectors::*;
use crate::config::Config;
use std::num::ParseFloatError;
#[cfg(target_os = "linux")]
use procinfo::pid;
pub static RS_COLLECTOR_STATS_SAMPLES_METRICNAME: &'static str = "rs-collector.stats.samples";
static VERSION: &'static str = env!("CARGO_PKG_V... | true |
4b48c4060177d3b6ba04272966cf00f46b3b5115 | Rust | imxiaohui/rust-examples | /api-std-vec.rs | UTF-8 | 2,037 | 3.890625 | 4 | [
"LicenseRef-scancode-other-permissive",
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"Apache-2.0",
"LicenseRef-scancode-public-domain"
] | permissive | /**
* http://doc.rust-lang.org/std/vec/
*
* @license MIT license <http://www.opensource.org/licenses/mit-license.php>
*/
/**
* ~[~str] is an owned pointer, allocated on the send heap, can be sent accross tasks.
* Vec<T> is what ~[T] was before it was removed.
*/
fn fill_strings() -> Vec<String> {
let mut strin... | true |
c3e8cf4828e243e58bfce2a5ae5b5b5064c39bc4 | Rust | rillrate-fossil/rillrate | /pkg-core/rate-core/src/actors/node/config.rs | UTF-8 | 838 | 3.046875 | 3 | [
"Apache-2.0"
] | permissive | use serde::{Deserialize, Serialize};
use std::net::SocketAddr;
/// Server configuration.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
pub struct NodeConfig {
/// An address where bind the server.
pub external_address: Option<SocketAddr>,
pub internal_address: Option<SocketAddr>,
}
//#[al... | true |
ef1b66ea6784b8f68059b031f9b617269256fe9f | Rust | IThawk/rust-project | /rust-master/src/test/ui/issues/issue-46069.rs | UTF-8 | 438 | 2.53125 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-other-permissive",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | // run-pass
use std::iter::{Fuse, Cloned};
use std::slice::Iter;
struct Foo<'a, T: 'a>(&'a T);
impl<'a, T: 'a> Copy for Foo<'a, T> {}
impl<'a, T: 'a> Clone for Foo<'a, T> {
fn clone(&self) -> Self { *self }
}
fn copy_ex() {
let s = 2;
let k1 = || s;
let upvar = Foo(&k1);
let k = || upvar;
k();... | true |
41dccacdb8d1c3edb242ddf0b287c84a15f39901 | Rust | Hentioe/irir | /ports/server/src/errors.rs | UTF-8 | 1,180 | 2.71875 | 3 | [] | no_license | use failure::Fail;
use libcore::errors::*;
use actix_web::{error, http, HttpResponse};
#[derive(Fail, Debug)]
pub enum WebError {
#[fail(display = "Internal error, reason: {}", _0)]
InternalError(String),
#[fail(display = "Not Found")]
NotFound,
}
impl WebError {
pub fn internal(e: Error) -> Self... | true |
2dd0f77844f2dd74b7642ff66d327e7f4b10bcf7 | Rust | thulyatech/tantivy | /columnar/src/column_index/optional_index/set.rs | UTF-8 | 1,300 | 3.40625 | 3 | [
"MIT"
] | permissive | use std::io;
/// A codec makes it possible to serialize a set of
/// elements, and open the resulting Set representation.
pub trait SetCodec {
type Item: Copy + TryFrom<usize> + Eq + std::hash::Hash + std::fmt::Debug;
type Reader<'a>: Set<Self::Item>;
/// Serializes a set of unique sorted u16 elements.
... | true |
6ca8e0f265de0f18315e55c09a81a76ccc335a4b | Rust | ale444113/AprendiendoRust | /src/inputs.rs | UTF-8 | 275 | 3.5 | 4 | [] | no_license | use std::io;
fn main(){
let mut input = String::new();
println!("Hey, di algo: ");
match io::stdin().read_line(&mut input){
Ok(_) => {println!("Perfecto, digiste {}", input)},
Err(e) => println!("Ocurrio un error... \n {}",e)
}
} | true |
4bd640b035a7bf1b4b2f2429c19fe45f8f7324f2 | Rust | millerjs/rubbledb | /src/table/block.rs | UTF-8 | 10,921 | 2.90625 | 3 | [] | no_license | use ::slice::Slice;
use ::errors::RubbleResult;
use ::util::coding;
use ::status::Status;
use ::comparator::SliceComparator;
use std::mem;
use std::str;
pub struct OwnedBlock {
data: Vec<u8>,
restart_offset: usize,
}
pub struct SliceBlock<'a> {
data: Slice<'a>,
restart_offset: usize,
}
pub trait Bloc... | true |
3f2575cefa0dfc5d5c34f94222d45d5db3b7bbce | Rust | mbarnett/koi | /src/parse.rs | UTF-8 | 2,143 | 3.484375 | 3 | [] | no_license | use lex::Lex;
use lex::Token;
use std::iter::Peekable;
use std::result;
type Result<T> = result::Result<T, String>;
#[derive(Debug)]
pub struct Invocation {
command: Invocable,
expression: Vec<Token>,
}
#[derive(Debug)]
pub struct Invocable {
token: Token,
}
pub struct Parse<'a> {
token_stream: Peek... | true |
6d72b13dd493e84aced16679c037dafd6c27a838 | Rust | pedagand/PSTL-crypto-async | /sandbox/threaded/src/runtime.rs | UTF-8 | 3,728 | 2.6875 | 3 | [
"MIT"
] | permissive | use crate::{Cell,Scheduler};
use std::sync::{Arc, Mutex};
use std::{thread, time};
///Cette partie s'occupe de l'algorithme du scheduler en faisant abstraction de l'architecture
/// client/serveur, les keys et plains sont donc générés auparavant.
pub fn demo_submit_job(buf: Arc<Mutex<Vec<Cell>>>, scheduler: Arc<Sch... | true |
04aa7a86c41889bfda56c65a49b27913c93b639c | Rust | SkiFire13/adventofcode-2017-rs | /src/day23.rs | UTF-8 | 3,619 | 3.3125 | 3 | [] | no_license | #[allow(unused_imports)]
use super::prelude::*;
type Input = Vec<Instruction>;
#[derive(FromStr, Debug, Copy, Clone)]
#[display("{0}")]
pub struct Register(char);
impl Register {
fn as_idx(&self) -> usize {
self.0 as usize - b'a' as usize
}
}
#[derive(FromStr, Debug, Copy, Clone)]
#[display("{0}")]
p... | true |
889fcf44e52982cf9b96973a8ad815b48fca90ae | Rust | Polygonalr/arbron-queryer | /src/requester.rs | UTF-8 | 2,910 | 2.828125 | 3 | [
"MIT"
] | permissive | use crate::hashes::{ self, HashType };
use crate::virustotal::VirustotalResponse;
use reqwest::{ Client, StatusCode };
use serde::{ Deserialize, Serialize };
const VIRUSTOTAL_FILES_URL:&'static str = "https://www.virustotal.com/api/v3/files";
#[derive(Debug, Clone, Error)]
pub enum RequestError {
#[error("a fatal... | true |
aba2ce7b3357dac650d606e8615e7a814c77d4a4 | Rust | seeekr/quanta | /src/counter.rs | UTF-8 | 1,267 | 2.671875 | 3 | [
"MIT"
] | permissive | use crate::ClockSource;
#[derive(Debug, Clone, Default)]
pub struct Counter;
impl Counter {
#[allow(dead_code)]
pub fn new() -> Self { Counter {} }
}
#[cfg(feature = "tsc")]
impl ClockSource for Counter {
fn now(&self) -> u64 {
let mut l: u32;
let mut h: u32;
unsafe {
... | true |
448f6f6e13a02f04b02dafa19ac7daf7124cd86e | Rust | zhang-ming-hao/rust | /LearningNotes/code/010/crate/crate.rs | UTF-8 | 191 | 2.53125 | 3 | [] | no_license | // 这个 crate 是一个二进制可执行文件
#![crate_type = "lib"]
// 库的名称为 “rary”
#![crate_name = "libcrate"]
pub fn print()
{
println!("我是crate中的函数");
} | true |
728a4b24e22feec3f235430e14b33bddf2dcdb2b | Rust | badmutex/shortest-path-server | /rust/src/graph.rs | UTF-8 | 8,800 | 3.265625 | 3 | [] | no_license | use std::vec::Vec;
use std::collections::{HashMap, LinkedList};
use std::default::Default;
type Weight = usize;
#[derive(Debug)]
pub enum Error {
UndefinedNode(usize),
EdgeExists(usize, usize, Weight),
CycleExists,
}
type Res = Result<(), Error>;
#[derive(Debug)]
pub struct DiGraph{
pub(crate) num_... | true |
b5a4cd053bfe54a33cb51d2619a01dbf6cf1ba53 | Rust | abs-tudelft/tydi | /src/generator/chisel/mod.rs | UTF-8 | 1,003 | 2.578125 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Chisel back-end.
use crate::design::Project;
use crate::generator::GenerateProject;
use crate::Result;
use std::path::Path;
/// Chisel back-end code generation result
#[allow(dead_code)]
type ChiselResult = Result<String>;
/// Chisel back-end configuration parameters.
pub struct ChiselConfig {
/// An optiona... | true |
6c7e165b8d8b67c588f5d520bc69ba9b5ef0d4b5 | Rust | denoland/deno | /test_util/src/factory.rs | UTF-8 | 2,615 | 2.59375 | 3 | [
"MIT"
] | permissive | // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
use glob::glob;
use std::collections::HashSet;
use std::path::PathBuf;
/// Generate a unit test factory verified and backed by a glob.
#[macro_export]
macro_rules! unit_test_factory {
($test_fn:ident, $base:literal, $glob:literal, [ $( $test:... | true |
eab5b2bced98eb2d75357a3943fc88c4d48521a3 | Rust | enyst/ampify | /rust/optparse.rs | UTF-8 | 15,976 | 3.21875 | 3 | [
"Unlicense",
"LicenseRef-scancode-public-domain",
"BSD-3-Clause",
"CC0-1.0"
] | permissive | // Public Domain (-) 2012-2013 The Ampify Authors.
// See the Ampify UNLICENSE file for details.
//= The optparse module provides support for handling command line options.
//
// Just specify the options that you want your program to take and `optparse`
// will automatically generate usage messages, validate arguments... | true |
b13dd1adceafcfb07ef5e2a2f13da9bf89c379ca | Rust | rice-hiroko/oftb | /src/ast/mod.rs | UTF-8 | 12,354 | 3.0625 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! The types for the initial AST.
mod helpers;
use std::collections::BTreeSet;
use std::path::Path;
use error::{Error, ErrorKind};
use literal::Literal;
use symbol::Symbol;
/// A module.
#[derive(Clone, Debug, PartialEq)]
pub struct Module {
pub name: Symbol,
pub exports: BTreeSet<Symbol>,
pub imports:... | true |
67db30477e4d2778acb1045f6368dc586e27acf6 | Rust | pit-rpg/Viz | /src/core/buffer_geometry.rs | UTF-8 | 11,001 | 2.6875 | 3 | [] | no_license | extern crate uuid;
extern crate heck;
extern crate specs;
use self::uuid::Uuid;
use self::heck::ShoutySnakeCase;
use std::vec::Vec;
use std::fmt;
use std::sync::{Arc,Mutex, LockResult, MutexGuard};
use std::mem;
use std::error::Error;
use self::specs::{Component, VecStorage};
use math::{
Vector,
Vector2,
Vector3... | true |
03644a02acf4e499fd130d04bcdb7a93bd19b41a | Rust | scaspin/RTSS21-Artifact | /transactional-memory/scratchpad/call.rs | UTF-8 | 169 | 2.65625 | 3 | [
"MIT"
] | permissive | fn foo() {
let mut b = 3;
b -= 1;
transaction {
let mut _a = 2;
_a += 3;
}
b += 4;
}
fn main() {
foo();
foo();
foo();
}
| true |
6f8c2315aa091a6664912be6130db00f6a11f7e2 | Rust | 4ppl3Hun73r/Rust_golang_springboot_study | /rust/ch3/datatypes/src/main.rs | UTF-8 | 1,233 | 3.5 | 4 | [] | no_license | fn main() {
// let guess = "42".parse() .expect("Not a number!");
let guess: u32 = "42".parse()
.expect("Not a number!");
let x = 2.0; // f64
let y: f32 = 3.0; // f32
println!("x is {}, y is {}, guess is, {}", x, y, guess);
let sum = 4 + 10;
let difference = 95.4 - 4.3;
let product = 4 * 30;
let quoti... | true |
dd489be082eee5e660aaeec169825b17f2e96b16 | Rust | yami2200/leetcode | /src/exercise993/exercise993.rs | UTF-8 | 1,416 | 3.078125 | 3 | [] | no_license | use std::rc::Rc;
use std::cell::RefCell;
use std::cmp;
#[derive(Debug, PartialEq, Eq)]
pub struct TreeNode {
pub val: i32,
pub left: Option<Rc<RefCell<TreeNode>>>,
pub right: Option<Rc<RefCell<TreeNode>>>,
}
impl TreeNode {
#[inline]
pub fn new(val: i32) -> Self {
TreeNode {
val,
left: None,... | true |
3251b2393dba950380bb094d64d43651fc5fd5d2 | Rust | condy0919/uuid | /src/node.rs | UTF-8 | 1,914 | 3.328125 | 3 | [] | no_license | //! NodeID represent a MAC address.
use std::convert::From;
use std::fs;
use std::path::Path;
use std::fmt;
use std::str::from_utf8_unchecked;
#[path = "util.rs"]
mod util;
use util::xtob;
#[path = "macros.rs"]
#[macro_use]
mod macros;
/// An IEEE 802 MAC address
#[derive(Debug, Clone, Copy)]
pub struct Node([u8; 6... | true |
3d556d6c92c41514bcaf0051155e5381a2e3ecf6 | Rust | Blatko1/wgpu-beginner-project | /src/uniform_matrix.rs | UTF-8 | 2,511 | 2.6875 | 3 | [] | no_license | use crate::camera::Camera;
use wgpu::util::DeviceExt;
#[repr(C)]
#[derive(Debug, Clone, Copy, bytemuck::Pod, bytemuck::Zeroable)]
pub struct Data {
pub proj_view_model_matrix: [[f32; 4]; 4],
pub view_position: [f32; 4],
}
#[repr(C)]
#[derive(Debug)]
pub struct MatrixUniform {
pub data: Data,
pub bind_... | true |
903fd8d72d6b729eaa6cb747d3e08838d72e9a76 | Rust | mokeshi3/study_nannou | /stripe_pattern.rs | UTF-8 | 1,011 | 2.53125 | 3 | [] | no_license | use nannou::prelude::*;
fn main() {
nannou::sketch(view).size(720, 260).run();
}
fn view(app: &App, frame: Frame) {
let mut draw = app.draw();
let win = app.window_rect();
draw.background().rgb(1., 1., 1.);
draw = draw.translate(vec3(win.left(), 0., 0.));
let length = 140.;
let max = win.... | true |
d84bebc98ea207f5350c79668f6d9551f09fb006 | Rust | three-rs/three | /src/material.rs | UTF-8 | 8,453 | 3.140625 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Material parameters for mesh rendering.
use color;
use color::Color;
use render::BasicPipelineState;
use texture::Texture;
use util;
#[doc(inline)]
pub use self::basic::Basic;
/// Basic material API.
pub mod basic {
use super::*;
/// Parameters for a basic solid mesh material.
///
/// Renders t... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.